refactor-cleanup

Refactor source code in git diffs while preserving functional behavior.

9|3|Updated Jun 13, 2026
One-click install
npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill refactor-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-cleanup
Source: https://github.com/Sir-chawakorn/sanook-cli/tree/main/skills/refactor-cleanup
Command: npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill refactor-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses technical debt by simplifying messy, duplicated, or overly complex code without altering its functional behavior.

Core Features & Use Cases

  • Code Simplification: Identifies and resolves deep nesting, long functions, and magic values to improve maintainability.
  • Safety-First Refactoring: Enforces a strict test-driven approach, ensuring behavior remains identical before and after changes.
  • Use Case: After completing a feature implementation, use this skill to clean up the resulting diff, remove dead code, and extract helper functions to ensure the codebase remains clean and professional.

Quick Start

Use the refactor-cleanup skill to simplify the code changes in the current git diff while ensuring all existing tests continue to pass.

Frequently Asked Questions about refactor-cleanup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor code to improve readability without changing behavior?

Code refactoring simplifies messy, duplicated, or overly complex source code while preserving functional behavior. It eliminates deep nesting, long functions, and magic values to improve maintainability without altering existing logic or outputs.

Do I need a passing test suite before refactoring code?

Yes, a verified green test suite baseline is required for safe refactoring. It enforces a strict test-driven approach to validate that no logic or output changes occur during the cleanup process, ensuring behavior remains identical before and after changes.

What's the best way to clean up a messy git diff after feature implementation?

Refactoring localized code changes or specific git diffs cleans up the resulting diff by removing dead code, eliminating duplication, and extracting helper functions. This ensures the codebase remains clean and professional after completing a feature implementation.

When should I use a safety-first refactoring approach for technical debt?

Safety-first refactoring addresses technical debt after completing a feature implementation. It simplifies code by resolving deep nesting, long functions, and magic values while enforcing a strict test-driven approach to ensure behavior remains identical throughout the cleanup process.

Can refactoring eliminate dead code and excessive nesting in localized changes?

Yes, refactoring operates on localized code changes or specific git diffs to eliminate duplication, dead code, and excessive nesting. It improves structural quality, readability, and efficiency while preserving existing functional behavior validated by a green test suite.

Why does refactoring require a verified green test suite baseline?

A verified green test suite baseline validates that no logic or output changes occur during refactoring. It enforces a strict test-driven approach, ensuring the cleanup process improves structural quality and readability while preserving identical functional behavior.