red-synthesize-green

TDD implementation cycle: RED (failing test) → GREEN (minimal implementation) → REFACTOR (cleanup without regression).

When to use

Entry contract

Exit contract

Invariants

Why this shape

The RED-GREEN-REFACTOR cycle is the fundamental rhythm of TDD. Each micro-iteration produces a verified increment — feedback is immediate.

« The two rules of TDD: write new code only if an automated test has failed; eliminate duplication. » — Beck, K., Test-Driven Development by Example, 2003.

The RED phase is a diagnostic: if the test passes immediately, either the test is trivial or the code already does more than necessary. The GREEN phase is a synthesis: write the minimal code. The REFACTOR phase is cleanup: eliminate duplication without changing behaviour.

« Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code. » — Fowler, M., Refactoring, 2nd ed., 2018.

Allowed customisation

See also