gezel Gezel Handboek

Behavior-Preserving Refactor

Restructure code without changing what it does, with proof at every stage: a green suite recorded before anything moves (characterization tests pinned first when coverage is thin), small reversible stages that keep the tests green, a re-measured structure target, and an enforced independent review.

How it runs

#StepWho runs itWhat happens
1Capture the baselineDeveloperRecord the current truth before changing anything: suite green, structural measurements, and the guardrail โ€” with characterization tests added first where coverage is thin.
2Plan reversible stagesDeveloperDesign the target structure and an ordered sequence of small stages, each individually reversible and each leaving the tree working. No source edits.
3Restructure stage by stageDeveloperExecute the planned stages at the real sites, keeping the suite green between stages.
4Re-measure and verifyDeveloperRe-measure with the same method as the baseline, quote both figures, and record the suite green.
5Evaluate the deliverableReviewerIndependently grade the observable deliverable and route it to finish, repair, or user escalation.
6Repair the deliverableDeveloperFix only the concrete gaps from the latest independent review.
7FinishDeveloperAll deterministic and reviewer criteria passed.
8Escalate unresolved concernsDeveloperThe bounded repair loop ended without a defensible pass.

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