08
refactoring
Change structure, keep behaviour. An edit with no tests is not a refactor. It is a rewrite.
What is refactoring?
Refactoring is design under tests: rename, extract, move a boundary. Observable behaviour stays.
Why does refactoring matter when vibe coding?
The model hears “tidy this” as “invent a feature.” Split refactoring from behaviour change, and name the tests that must not move.
How do you do refactoring?
Bar is green. Name the structure to change. No new behaviour. Run the same tests. The diff should move code, not grow new branches.
How do you ask a model for refactoring?
Refactor (scope) only. Behaviour frozen. Tests frozen. No features on the side. The diff must not grow new business branches.
What goes wrong with refactoring?
“Refactor, and fix that bug while you’re in there.” The model does both, and you cannot tell which edit broke the build.