tdd
Implement a feature test-first with strict red-green-refactor
Files1
View on GitHubSKILL.md.claude/skills/tdd/SKILL.md
GitHubTDD Workflow
Implement $ARGUMENTS test-first. Never skip red.
Test conventions (suites, mocking, naming) are in .claude/rules/testing.md — read it, don't re-derive.
For a multi-step feature where you want the discipline enforced turn by turn, delegate to the tdd-coach agent instead.
RED
- Identify module and layer — Action in
Application/, value object inDomain/Data/, repository inInfrastructure/Repository/. - Declare the interface in
Domain/first. That is the requirement, written down. - Write one failing test.
tests/Unit/<Module>/unless it needs DB or HTTP, thentests/Feature/. - Run it and confirm it fails for the right reason:
Passing now means it proved nothing — fix the test, not the code.vendor/bin/phpunit tests/Unit/<Module>/<Name>Test.php
GREEN
- Minimal implementation. No speculative branches, no extra methods.
- Add the
$singletonsbinding. - Re-run.
REFACTOR
- Improve naming, extract methods, remove duplication — green after every step.
- Gate:
composer test
Loop back to RED for each additional behavior. Never batch several tests before implementing.