What problem does it solve?
Refactoring without changing behavior is risky and error-prone. This skill provides a disciplined approach to restructuring code safely, ensuring tests pass and behavior remains unchanged.
Core Features & Use Cases
- Extract Function / Method: Safely pull out a code block into a named function and replace the original with a call.
- Rename (Variable / Function / Class): Update identifiers with IDE-assisted refactors to avoid breaking references.
- Decompose Conditional: Break complex if/else into named, testable branches.
- Replace Magic Number / String: Move literals to named constants to improve clarity and maintainability.
- Remove Dead Code: Eliminate unused blocks with proper checks and history awareness.
- Consolidate Duplicate Logic: Factor common logic into a single utility and reuse it.
- Pre-Refactor Checklist: Ensure tests cover changes and goals are clearly understood.
- Anti-Patterns to Avoid: Do not refactor while adding features or skip tests.
Quick Start
Plan and execute a safe, one-thing-at-a-time refactor from the selected code section.