TDD
You write the failing test before the code: the skill gives Claude rules for the red-green loop, for good tests and for mocking at system boundaries.
What is TDD?
TDD is a skill for Claude Code that structures test-driven development. It serves Claude as a reference for the red-green loop and defines what makes a useful test, where tests belong and which anti-patterns to avoid. The rules apply in every cycle, before and during implementation.
The workflow starts with an agreement: before Claude writes a test, it proposes the public interfaces where testing should happen and asks you to confirm them. Each cycle then produces exactly one failing test and just enough code to make it pass. The skill uses mocks only at system boundaries, such as external APIs, time or randomness. Refactoring is moved to a separate review stage.
The skill suits developers who build new functionality or repair defects with Claude and want tests that survive changes to the code. If the project has a glossary, Claude uses its terms for test names. The code examples in the skill are written in TypeScript. TDD is released under the MIT license and is installed with 'npx skills add mattpocock/skills --skill tdd'.
Who it is for
Developers and engineering teams who work test-driven with Claude Code and prefer integration tests through public interfaces.
Use cases
- You are adding a new feature to an existing codebase and want every function backed by a test written beforehand.
- A bug needs fixing, and you want to reproduce it with a failing test first before Claude writes the fix.
- Your test suite breaks during refactors even though behavior stays the same, and you want to move the tests to public interfaces.
What TDD does
Agree on test interfaces first
Before any test exists, Claude proposes the interfaces to test at, notes briefly what each one catches and misses, and waits for your confirmation.
One test, one implementation
Each cycle creates one failing test, followed by only as much code as needed to pass it. Speculative features for later tests are left out.
Spot anti-patterns
The skill names tests coupled to implementation details, tautological checks that compute the expected value the same way the code does, and writing every test before any implementation.
Mocking only at system boundaries
Mocks cover external APIs, time, randomness and, where needed, the database or file system. Your own modules stay real. Dependency injection and SDK-style interfaces make this easier.
Use the project's domain language
If the project has a glossary, Claude reads it so test names and interface terms match the domain language. Existing architecture decision records (ADRs) are respected.
Say this to activate the skill
"Let's build this feature test-driven.""Fix this bug with red-green-refactor, test first.""Write integration tests for this module.""Which interfaces should we test here?" Install
npx skills add mattpocock/skills --skill tdd
The command installs the original version from the author's repository (Vercel skills CLI, needs Node.js), add -g for all projects. We do not host a copy: updates come straight from the author. Need help with setup? How to install skills →
Checked automatically
- Automated check on 2026-11-06 (revision 4ae2317): 4 files in the skill folder read by pattern search. It found no hidden characters, no instructions to override rules, no download-and-run and no access to credentials.
Independent checks on skills.sh, as of 6 Nov 2026
| Gen Agent Trust Hub | Pass |
|---|---|
| Socket | Pass |
| Snyk | Pass |
Good to know
- Claude only writes tests after you have confirmed the proposed test interfaces. Plan for this agreement at the start of each task.
- The skill refers to the codebase-design skill for architecture terms and to code-review for refactoring. This command does not install either of them.
- The code examples are written in TypeScript in Jest style. For other languages you translate the patterns yourself.
- The check is an automated pattern search, not a security guarantee, and reads the skill folder only. The command always installs the author's current version; later versions have not been reviewed by us.
Frequently asked questions about TDD
What is TDD?
TDD is a Claude skill by mattpocock for test-driven development. It gives Claude rules for the red-green loop, describes good and bad tests and defines where mocks are allowed.
How do I install TDD?
You install TDD with 'npx skills add mattpocock/skills --skill tdd'. Claude then draws on the skill when you want to work test-driven, mention red-green-refactor or ask for integration tests.
Is TDD free?
Yes, TDD is released under the MIT license and is free to use. All you need is Claude with support for skills, for example Claude Code.
Who is TDD for?
TDD is worth it if you develop new functionality or repair defects with Claude and want the test written before the code. The skill helps most when your existing tests keep breaking during refactors.
What data does TDD send?
TDD sends no data itself. The skill consists of instructions and code examples in text files, contains no scripts and calls no external services.
Share this skill
About this skill
TDD comes from mattpocock and is an open-source project maintained by its author and community.
Author: mattpocock / github.com. Source: github.com/mattpocock/skills/tree/main/skills/engineering/tdd. Licence: MIT.
Curated by Collective Brain, an AI and automation digital agency from Hamburg, together with WhiteFox Automations. More vetted skills in the skills catalog.
Working in Germany, Austria or Switzerland? We help teams roll out Claude, in English or German.
Want this skill tailored to your team?
TDD is a strong starting point. A skill gets really powerful once it knows your workflows, templates and tone of voice. We build custom skills for teams, from analysis to rollout, and connect them to our work in AI consulting.
Request a custom skill →