refactor
Installation
SKILL.md
Refactor: Behavior-Preserving Structural Change
Overview
Refactor changes the structure of working code; it does not change behavior.
It differs from simplify by risk rather than size: simplify applies edits whose behavior preservation is verifiable on the spot, and refactor takes the edits that are not — the ones that move contracts, cross module boundaries, or touch files far from where the request started.
Those need a plan the user rules on before anything lands, because the resulting diff is too large to review after the fact.
Every move is approved individually and executed on its own, with verification green between moves.
When to Use
- A function or class has grown past the point where it can be read.
- Two modules import each other, or a layer imports something below it that it must not.
- An abstraction has one implementation, and collapsing it touches every call site.
- A simplify pass left structural proposals and the user wants to work through them.
- Code needs to move: extracted to a new module, merged into an existing one, renamed across the tree.