test-driven-development
Implement a behavior change with a test-first loop when the contract can be tested. Use for bug fixes and regressions; adapt when the project cannot support a true red-green cycle.
Files1
View on GitHubSKILL.mdskills/test-driven-development/SKILL.md
GitHubTest-Driven Development
Use the project's existing test framework and conventions.
- Inspect the implementation, nearby tests, fixtures, and documented commands.
- Define the observable contract and the edge cases that matter.
- Add the smallest focused test that demonstrates the missing or incorrect behavior.
- Run it and confirm it fails for the intended reason.
- Implement the minimum change that makes the test pass.
- Run the focused test, then the relevant suite and additional checks justified by the change.
- Refactor only when clarity improves without changing behavior; rerun affected tests.
Prefer deterministic tests that exercise public behavior. Avoid broad mocks, brittle snapshots, arbitrary sleeps, or tests that pass without reaching the changed path. For exploratory work or an untestable UI path, state why strict TDD is impractical and use the strongest available verification. Never claim a red-green cycle happened unless you observed it.