test-first
Test-first
TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.
When reading or updating project agreements and work records, follow project-documents.md; its terms (authorized, obligation, lazy, pointer) apply. Derive expected behavior from the authorized agreement and applicable requirements: a task, specifications, or a user-approved batch in working state. Keep unresolved proposals distinct from agreed behavior. An assertion changes only when the agreement changes.
Record unfinished cycles and verification evidence in working state under the shared model. Tests establish only what they exercise; appearance and interaction acceptance may require human judgment. The calling implementation workflow records completed authorized agreements and deliveries in the changelog using the shared format.
When exploring the codebase, read the glossary and the decision records AGENTS.md points to, so test names and interface vocabulary match the project's domain language, and respect the decision records in the area you're touching.
What a good test is
Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.
See tests.md for examples and mocking.md for mocking guidelines.
Seams: where tests go
A seam is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.