| name | tdd |
| description | Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development. |
Test-Driven Development
NB: referenced sibling files (tests.md, mocking.md, deep-modules.md,
interface-design.md, refactoring.md) are cohort-only content at the source.
DR-specific versions will be written under DR-724-B; until then, use the
skill's inline guidance and fall back to your own judgement. (Matt's
upstream copies of these files are also bundled here as a courtesy — they
are terse but usable starter content and will be replaced by DR versions.)
Philosophy
Core principle: Tests should verify behaviour through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behaviour hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behaviour.
See tests.md for examples and mocking.md for mocking guidelines.
Anti-Pattern: Horizontal Slices
DO NOT write all tests first, then all implementation. This is "horizontal slicing" - treating RED as "write all tests" and GREEN as "write all code."