tdd
Installation
SKILL.md
TDD
Drive implementation through the red-green-refactor cycle.
Workflow
- Understand the behavior: read enough code to know what the change should do and where it belongs.
- Write one failing test: the test describes the next behavior to add, written as
test-writingsays. It must fail for the right reason. - Make it pass: write the minimum code to pass the test. Nothing more.
- Refactor: clean up while green. Improve naming, remove duplication, simplify structure. Run tests after each change. No comments: a why goes into a name, type or test.
- Repeat: pick the next behavior and go back to step 2.
One test at a time. Each cycle is vertical — one test, one implementation, one refactor pass. Do not write multiple tests before implementing.
See also
buildfor slice-by-slice executiontest-writingfor what to test, assertions, and mockingtest-reviewfor review-time test adequacy checks