Refactor
Rewriting code so it reads better or runs cleaner, without changing what it does.
Not the same as a rewrite
A rewrite changes what the code does. A refactor deliberately does not — which is what makes it verifiable: if behaviour changed, it was not a refactor, it was a bug.
Where it bites
Agents are good at refactors and bad at admitting when one turned into a rewrite. The defence is a test that passed before and must still pass after; without one you are comparing your memory of the behaviour against its description of the change.
Covered in these lessons
Related terms
Where this comes up
Also written as refactor, refactoring. Checked 2026-08-06.