What problem does it solve?
This guide provides a repeatable red-green-refactor loop to safely overhaul, refactor, or harden a code path using strict failing-tests-first TDD; it ensures contracts, tests, and implementation stay aligned while mitigating risk.
Core Features & Use Cases
- Map the existing contract before touching code to capture durable behavior boundaries.
- Write purposeful red tests that express explicit contract gaps.
- Run the smallest relevant test slice to verify the targeted surface.
- Make the smallest green change that satisfies the new contract.
- Refactor after the contract is green to simplify and consolidate.
- Sync internal docs, prompts, and policy to reflect the new runtime contract.
- Broaden verification to adjacent subsystems and related suites.
- Report the red → green timeline for auditable change.
Quick Start
Apply the red-green-refactor loop to a subsystem by mapping the contract, writing red tests for gaps, executing the smallest green change, and recording the red→green timeline.