tdd
TDD
The red → green loop, for whatever test framework the project already uses. Consult before and during the loop, not after.
Read GLOSSARY.md (or the older CONTEXT.md) if it exists so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
Before writing or reviewing tests, read
references/testing-best-practices.md
and apply its value gate and rejection rules throughout the loop.
Stack references. Identify the stack from its manifests (composer.json, package.json, pyproject.toml, go.mod, Cargo.toml, Gemfile). If a matching file exists below, read it before the first cycle: it maps the seams and rules here onto that stack's test tooling. Otherwise apply the rules through the suite's existing conventions.
- Laravel (
laravel/frameworkincomposer.json):references/laravel.md
Rules of the loop
- Red before green. Write the failing test first, watch it fail for the right reason (a missing route 404s, not a typo'd import), then write only enough code to pass. No speculative features.
- One slice at a time. One seam, one test, one minimal implementation per cycle. Each next test responds to what the last cycle taught you: never all tests up front, then all implementation (bulk tests verify imagined behavior and go insensitive to real changes).
- Refactoring is not part of the loop. It belongs to the review step (
code-review).