← skills.oriz.in

tdd

Red-Green-Refactor TDD loop for AI-implemented features. Writes ONE failing test first, verifies red, minimum code to green, then refactors. Blocks AI test-cheating (writing tests AFTER implementation to match code, not spec).

tdd — Red-Green-Refactor for AI-coded features

Trigger

Fire when:

Precondition

Test loop <60s per [[feedback-loops-are-the-ceiling]]. Slow loop? Fix loop FIRST. Never skip TDD to dodge slow tests.

Process — strict order

Step Action Verify
1. RED Write ONE failing test. Smallest observable behavior. Run. MUST see FAIL with expected error.
2. GREEN Minimum code to pass. No extras. No untested error handling. Run. MUST see PASS.
3. REFACTOR Clean impl + test. Tests stay green. Extract deep modules per [[deep-modules-over-shallow]]. Rename for clarity. Run. Stays green.
4. LOOP Next behavior. Back to RED.

Anti-cheat — hard rules

Test written AFTER code = code-shaped test, not spec-shaped. Rejects the point.

Output shape per cycle

RED: <test name> → <expected fail message>
GREEN: <files changed, LOC delta>
REFACTOR: <what got extracted/renamed>

Source

Kent Beck, Test-Driven Development: By Example (1999). AI-coding context: Matt Pocock workshop, 2026-07-03.

Cross-refs