refactoring-optimization
refactoring-optimization
Purpose
Change the shape of working code without changing what it does. The input is code that is hard to read, hard to change, or repeated in four places; the output is the same behavior in a better structure, with the tests still green after every step and a diff a reviewer can actually follow.
The discipline is the whole point. Anyone can rewrite a function so it reads better; the hard part is proving it still does the same thing. So the ordering here is always the same — establish a safety net, make one small reversible change, verify, repeat — and the value of the skill is in refusing to skip that, not in knowing clever refactorings.
This is the apply half of a pair. code-analyzer surveys a project and reports what is wrong;
this skill takes one of those findings and actually changes the code.