gezel Gezel Handboek

Behavior-Preserving Refactor

Refactor a module to improve its structure, readability, or design WITHOUT changing observable behavior — the defining constraint is that the tests stay green throughout. Plans the refactor FIRST — the target structure, the seams to introduce, the safe step sequence, and the green-tests guardrail — then refactors in small reversible steps, then a reviewer confirms behavior is unchanged and the code is genuinely cleaner. Covers extract-function/module, dependency seams, removing duplication, naming, and test-green-as-invariant refactoring.

How it runs

#StepWho runs itWhat happens
1Plan the refactorPlannerlock target structure, steps, green-tests guardrail
2RefactorDeveloperapply small reversible steps, tests green throughout
3Verify behavior preservedReviewerconfirm tests green and code is genuinely cleaner
4EvaluateReviewerGrade the deliverable against every acceptance criterion. All pass → finish; any fail → loop back and fix the gap.
5FinishDeveloperAll acceptance criteria met. Stamp a short summary and report DONE.

Say something like "refactor this module" or "clean up the code" or "improve code structure" or "behavior-preserving refactor" or "reduce duplication" in chat to start it.

Watch this article as a slideshow