Test-Driven Development
Use before implementing any feature or bug fix.
Iron Rule
No production code without a failing test first.
If you wrote implementation code first, delete it and restart with tests.
Red-Green-Refactor Loop
-
Red
- Write one failing test for one behavior.
- Run it and confirm it fails for the expected reason.
-
Green
- Write minimal code to pass that test only.
- Run the test and confirm pass.
-
Refactor
- Improve clarity/duplication while staying green.
- Re-run tests.
Repeat for the next behavior.
Rules
- One behavior per test.
- Prefer behavior tests over implementation-detail tests.
- Keep mocks minimal and interface-aligned.
- Add regression tests for every bug fix.
Project Verification Commands
Use fast-first loop:
typecheck.sh <file>
bild --test <namespace>
Do not claim success until tests pass after your final code changes.