tdd: Claude Code Skill & Agent Tool
An open-source skill by mattpocock (opens in a new tab), published in the mattpocock/skills (opens in a new tab) repository on GitHub. Generates tests first and builds features or bug fixes through a strict red-green-refactor loop, with clear guidance on where tests belong and the anti-patterns that make suites brittle.
Install tdd
Requires Node.jsnpx skills add mattpocock/skills --skill tddRun this command in your project terminal to install this skill for Claude Code.
What this skill does
tdd is Matt Pocock's test-driven development skill for AI coding agents. It is the reference the agent consults on every red-green cycle so the loop produces tests worth keeping, not just tests that pass. Good tests, in this skill, verify behavior through public interfaces rather than implementation details: they read like a specification and survive a refactor.
Before writing anything, the agent agrees with you on the seams — the public boundaries where behavior is observed — and notes what each seam catches and what it misses. No test is written at an unconfirmed seam, so testing effort lands where it matters. The loop itself is strict: red before green, one seam, one test and one minimal implementation per cycle, with no speculative features.
The skill also names the anti-patterns that make suites brittle: implementation-coupled tests that mock internal collaborators, tautological assertions that recompute the expected value, and horizontal slicing, where all tests are written before any code. Refactoring is left to the review stage. Use it with Claude Code whenever you build a feature or fix a bug and want a regression test to prove it.
Key Capabilities
- Strict red-green loop: write the failing test first, then only enough code to pass
- Agrees the seams (public interfaces) with you before any test is written
- Tests behavior through public interfaces, never implementation details
- Flags anti-patterns: implementation-coupled, tautological and horizontally sliced tests
- Reads the project's GLOSSARY.md and ADRs so tests use your domain language
How to use with Claude Code & AI Agents
Install the skill
Run the command above at the root of your project. The CLI asks which agents to set up — Claude Code, Cursor and other supported agents — and adds tdd to the project, so teammates who pull the repository get it too. Add-gto install it for your user account across every project.Open a new agent session
Start a fresh Claude Code session in that project so the agent loads the new skill. This skill needs no extra tool or API key.Ask in plain words
Describe the task, for example:“Fix the rounding bug in invoice totals test-first, red then green.”The agent matches your request to the skill's description and follows its SKILL.md instructions step by step. Read them on GitHub before using the skill on a system that matters.