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
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.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
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.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)
Common Shortcuts to Reject
| Excuse | Why It’s Wrong |
|---|---|
| ”This is just a simple fix” | Simple code breaks. The test takes 30 seconds. |
| ”I’ll test after confirming the fix” | Tests passing immediately prove nothing. You never saw the test catch the bug. |
| ”Tests after achieve the same goals” | Tests-after answer “what does this do?” Tests-first answer “what should this do?" |
| "I already manually tested it” | Ad-hoc is not systematic. No record, can’t re-run, no regression protection. |
| ”I need to explore first” | Fine. Throw away the exploration. Start TDD fresh. |