tdd · diff
git:20260223.9194af7 to git:20260925.570ed1c
19 added, 90 removed. Audit A to A.
---
name: tdd
- description: Test-Driven Development enforcement skill - write tests first, always
+ description: Test-first at pre-agreed seams — one test, one implementation, tracer-bullet red/green; independent expected values; substitutions only at the seam's boundary class; launch Phase 4 reference.
---
- # TDD Mode
-
- [TDD MODE ACTIVATED]
-
- ## The Iron Law
-
- **NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST**
-
- Write code before test? DELETE IT. Start over. No exceptions.
-
- ## Red-Green-Refactor Cycle
-
- ### 1. RED: Write Failing Test
- - Write test for the NEXT piece of functionality
- - Run test - MUST FAIL
- - If it passes, your test is wrong
-
- ### 2. GREEN: Minimal Implementation
- - Write ONLY enough code to pass the test
- - No extras. No "while I'm here."
- - Run test - MUST PASS
-
- ### 3. REFACTOR: Clean Up
- - Improve code quality
- - Run tests after EVERY change
- - Must stay green
-
- ### 4. REPEAT
- - Next failing test
- - Continue cycle
-
- ## Enforcement Rules
-
- | If You See | Action |
- |------------|--------|
- | Code written before test | STOP. Delete code. Write test first. |
- | Test passes on first run | Test is wrong. Fix it to fail first. |
- | Multiple features in one cycle | STOP. One test, one feature. |
- | Skipping refactor | Go back. Clean up before next feature. |
-
- ## Commands
-
- Before each implementation:
- ```bash
- # Run the project's test command - should have ONE new failure
- ```
-
- After implementation:
- ```bash
- # Run the project's test command - new test should pass, all others still pass
- ```
-
- ## Output Format
-
- When guiding TDD:
-
- ```
- ## TDD Cycle: [Feature Name]
+ # TDD
- ### RED Phase
- Test: [test code]
- Expected failure: [what error you expect]
- Actual: [run result showing failure]
+ Red-green in small steps, at seams that were agreed in advance. In a launch run the seam list is C2's approved output; outside launch, agree the seams with the user before the first test exists — a seam nobody approved gets no tests.
- ### GREEN Phase
- Implementation: [minimal code]
- Result: [run result showing pass]
+ ## The loop
- ### REFACTOR Phase
- Changes: [what was cleaned up]
- Result: [tests still pass]
- ```
+ One test → one implementation → repeat:
- ## External Consultation (Optional)
+ 1. Write the next test at a seam. Run it. Watch it fail for the reason you expect — a test that cannot fail is not a test.
+ 2. Implement the smallest change that turns it green.
+ 3. Repeat. Each test is a tracer bullet: a narrow but complete path through the behavior, not a layer finished in isolation.
- The test-engineer agent MAY consult a Claude Task agent for test strategy validation.
+ ## Rules
- ### Protocol
- 1. **Form your OWN test strategy FIRST** - Design tests independently
- 2. **Consult for validation** - Cross-check test coverage strategy via a Claude Task agent
- 3. **Critically evaluate** - Never blindly adopt external suggestions
- 4. **Graceful fallback** - Never block if delegation is unavailable
+ - Expected values come from an independent source of truth — a spec line, a worked example, a documented output. Never from the implementation under test: a test that asserts what the code happens to do is a mirror, not a check.
+ - Substitute at the seam's declared boundary class only — in-process, locally substitutable, owned-remote port, or true-external, the class C2 records for each seam. No substitutes inside the boundary the test is exercising.
+ - Refactoring is not part of the loop. It belongs to the review stage; the repair worker owns it. Do not refactor mid-red-green.
+ - A bug fix starts with the failing test that reproduces it — reproduction before theory, the debugger's rule.
- ### When to Consult
- - Complex domain logic requiring comprehensive test coverage
- - Edge case identification for critical paths
- - Test architecture for large features
- - Unfamiliar testing patterns
+ ## When no seam fits
- ### When to Skip
- - Simple unit tests
- - Well-understood testing patterns
- - Time-critical TDD cycles
- - Small, isolated functionality
+ If the behavior cannot be tested at any approved seam, stop and say so: report the missing seam as a finding (it feeds `architecture-survey` and `refit`) rather than inventing a seam or testing through internals.
- ### Tool Usage
- Use `Task(subagent_type="oh-my-claudecode:test-engineer", ...)` for test strategy cross-validation.
+ ## Output
- **Remember:** The discipline IS the value. Shortcuts destroy the benefit.
+ - The seam list used, with boundary classes
+ - Red/green evidence — the failing run and the passing run
+ - Any seam-absence findings