refactor-planner
Installation
SKILL.md
Refactor Planner
Overview
Refactoring changes structure, never behavior. Lock behavior with tests first, move in small steps that each leave the code working, and keep every step reviewable and revertible.
Method
- State the goal in one sentence and why it pays off: "Split
orders.ts(1,400 lines) so checkout and refunds can change independently." - Map the code: who calls the target (find usages), what it depends on, public contracts that must not change.
- Build the safety net. Run existing tests. If the behavior being moved is not covered, add characterization tests that capture what it does today, including odd behavior.
- Plan small steps. Each step is one known refactoring, keeps tests green, and is one commit:
- Rename, extract function, extract module, move function, inline, introduce parameter object, replace conditional with polymorphism, extract interface at a boundary.
- For migrations: add the new path beside the old one, move callers in batches, delete the old path last.
- Execute step by step: change, run tests, commit. Never mix a refactor and a behavior change in one commit.
- Finish: remove dead code, update docs, report.