| name | tdd |
| description | Run red-green-refactor with one failing test, one implementation, then cleanup. Use when building features or fixes test-first. |
Test-Driven Development
Quick Start
Use one vertical slice at a time: one behavior test, minimal implementation, refactor only after green. Read vertical-slices.md when you need philosophy, anti-pattern examples, or the per-cycle checklist.
Planning
Before writing code:
Ask: "What should the public interface look like? Which behaviors are most important to test?"
Red-Green Loop
1. Tracer bullet
Write one test that confirms one externally visible behavior:
RED: Write test for first behavior → test fails
GREEN: Write minimal code to pass → test passes
This proves the path works end-to-end.
2. Incremental cycles
For each remaining behavior:
- Write the next behavior-focused test.
- Watch it fail for the expected reason.
- Write only enough code to pass.
- Run the relevant test set.
- Commit or checkpoint when the slice is coherent.
Rules:
- One test at a time.
- Test public behavior, not private implementation.
- Do not anticipate future tests.
- Keep edge cases tied to user-visible behavior.
Refactor
Refactor only after green. Read refactoring.md when choosing refactor candidates.
Check:
Never refactor while red.
References