refactoring
Installation
SKILL.md
Refactoring
Refactoring is the third step of TDD: after GREEN, assess whether refactoring adds value. A refactor improves the structure of working code; it never changes observable behaviour.
When to Refactor
- Assess after every GREEN: once per behaviour, not once after a batch
- Refactor only if it improves the code; if the code is already clean, move on
- Establish a reversible baseline with a known test result before refactoring (
principle-capture-the-baseline) - Pin the behaviour the refactor must preserve with a passing test first
- Refactor only code that green tests already cover; characterize anything else first or leave it alone, however trivial it looks
- Refactor in small reversible steps; never refactor code you cannot restore
- Keep external APIs unchanged and keep every test result unchanged