tdd: Red, Green, Refactor for Agentic Coding
Install this skill:
npx skills add mattpocock/skills skill=tdd -y -g
Source: mattpocock/skills/tdd
What it does
tdd guides an agent through test-driven development with a red, green, refactor loop.
The central rule is that tests should verify behavior through public interfaces, not implementation details.
Good tests
Good tests read like specifications. They describe what the system does from the outside.
They survive refactors because they do not care about private functions, internal collaborators, or the exact shape of implementation code.
Bad tests
Bad tests couple themselves to implementation details. They mock internals, test private methods, or fail when code is refactored even though behavior did not change.
The skill pushes the agent away from those tests.
One behavior at a time
tdd rejects horizontal TDD:
WRONG:RED: test1, test2, test3, test4GREEN: impl1, impl2, impl3, impl4
Instead, it works vertically:
RIGHT:RED → GREEN: test1 → impl1RED → GREEN: test2 → impl2RED → GREEN: test3 → impl3REFACTOR: clean up after green
This keeps the agent from writing tests for imagined behavior before it understands the implementation.
How it fits the workflow
grill-me → domain-model → to-prd → to-issues → tdd
Use tdd after to-issues has produced a vertical slice. Then implement one behavior at a time through public interfaces.
Pairs well with
- to-issues, for vertical-slice GitHub issues
- to-prd, for the source PRD
- domain-model, when tests need stable domain language