Overview
Therecursive-tdd subskill makes test-driven development mandatory for all Phase 3 implementation work — new features, bug fixes, refactors, and behavior changes. It enforces the cycle rigorously and requires you to record evidence in the Phase 3 artifact so recursive-mode tooling can verify compliance.
The Iron Law
When to Use
Apply this subskill in Phase 3 for every type of implementation work:- New features
- Bug fixes
- Refactoring
- Behavior changes
The RED-GREEN-REFACTOR Cycle
1
RED — Write one failing test
Write the smallest possible test that describes what the code should do. One behavior per test, clear name, real assertion against real code.Good test:Bad test (tests mock behavior, not real behavior):Run the test and confirm it fails — not errors, fails — and for the right reason:Record the failure output in the Phase 3 artifact under
RED Evidence.2
Verify RED — Never skip this step
Confirm three things before moving on:
- The test fails (not errors out)
- The failure message matches what you expected
- The failure is because the feature is missing, not because of a typo
3
GREEN — Write the minimum code to pass
Write the simplest possible code that makes the test pass. Nothing more.Good implementation:Bad implementation (adding YAGNI options not required by the test):Run the test again. Confirm it passes. Record the result under
GREEN Evidence.4
REFACTOR — Clean up while staying green
Only after the test passes: remove duplication, improve names, extract helpers. Never add new behavior during a refactor pass.After every change, run the tests again and confirm they are still green. Record what you cleaned up in the Phase 3 artifact.
Pragmatic Mode
When strict RED-first flow is genuinely infeasible, declare it explicitly. Do not silently skip the process. In the Phase 3 artifact, include:/.recursive/run/<run-id>/evidence/.
Phase 3 Artifact Requirements
Every Phase 3 artifact must include three sections.TDD Compliance Log
Coverage Gate
Approval Gate
Red Flags
Stop and delete code if you encounter any of these:Signs you need to start over with TDD
Signs you need to start over with TDD
- Code was written before the test
- The test passed immediately (it is not testing what you think)
- You planned to add tests later
- You described the change as “too simple to test”
- You cannot explain why the test failed (or why it didn’t fail)
- The test asserts mock behavior instead of real behavior
- The test name contains “and” (multiple behaviors in one test)