refactoring
Installation
SKILL.md
Refactoring
Refactoring is the third step of TDD. After GREEN, assess if refactoring adds value. Refactoring improves the structure of code that already works; it never changes observable behavior.
When to Refactor
- Always assess after green
- Only refactor if it improves the code
- Establish a reversible baseline with a known test result before refactoring
- Pin the behavior the refactor must preserve with a passing test first
Reversible Baseline
A refactor needs a state you can return to, so a broken slice costs one restore instead of a debugging session. A commit is one way to record that state, not a requirement. Refactoring uncommitted code is safe when the baseline is recorded another way.