# /tdd: Test-driven development for coding agents

Source: https://trendhub.net/skills/mattpocock-skills/tdd
Skill folder: https://github.com/mattpocock/skills/tree/main/skills/engineering/tdd
Pack: Skills for Real Engineers (https://trendhub.net/skills/mattpocock-skills)
Works with: Claude Code, Codex, GitHub Copilot, Gemini CLI, Cursor, OpenCode, Windsurf, Amp and others

The tdd skill makes a coding agent work test-first: it writes one failing test, adds just enough code to pass it, and repeats in thin slices. Tests are placed only at public seams you have approved, so they describe behavior and keep passing when the internals are refactored.

## When to use it

- You are building a feature or fixing a bug and want each step proven by a test.
- Your agent keeps writing code that looks right but fails at runtime.
- You want integration tests at a module's public edges rather than tests of private details.

## How it works

1. **Agree the seams**: Before any test, the agent proposes the public boundaries to test, notes what each catches and misses, and asks you to confirm.
2. **Red**: It writes one failing test at a confirmed seam.
3. **Green**: It writes only enough code to make that test pass, with no speculative features.
4. **Repeat in vertical slices**: One test and one implementation per cycle; refactoring is left to the review stage.

## What it steers the agent away from

- Tests that mock internals and break on every refactor
- Tautological tests that compute the expected value the same way the code does
- Writing all tests up front and all implementation afterwards

## What it can touch

Reads and edits files in your repository, reads GLOSSARY.md and ADRs if present, and runs your test command in the shell. It does not call external services itself.

## Pairs well with

- `/code-review`
- `/diagnosing-bugs`
- `/codebase-design`
- `/implement`

## Questions

### Does the tdd skill only work with TypeScript?

No. It describes a way of working rather than a framework, so it applies to any language that has a test runner.

### Will the agent refactor during the loop?

No. The skill keeps refactoring out of the red-green cycle and leaves it to the code-review stage.
