What problem does it solve?
Refactoring safely when you must improve code structure without changing observable behavior, so you can reduce risk while improving maintainability.
Core Features & Use Cases
- Refactoring decision-making: Determines whether refactoring is actually the task, whether structure is blocking progress, or whether to leave code alone.
- Behavior-preserving workflow: Defines scope, establishes a green baseline with existing tests (or creates characterization tests when none exist), and applies small reversible refactoring moves.
- Delivery discipline: Enforces separation of refactoring from feature work by using distinct commits, reducing the chance of tangled regressions.
Real-world example: You are asked to add a new capability to a module, but the existing code mixes validation, business logic, and side effects in one large function; you extract seams for validation, refactor in small steps with tests to prove behavior stays the same, then commit the refactor separately before implementing the feature.
Quick Start
Use the refactoring skill to restructure a targeted function by defining the exact scope, capturing a passing test baseline (or writing characterization tests), applying small behavior-preserving refactoring steps with test verification after each step, and committing refactoring separately from any new feature work.