Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Agent Skill

TDD (Matt Pocock)

Matt Pocock's short test-driven development skill: agree the seams first, then write one failing test and one minimal fix at a time, with notes on mocks.

name: tddBy Matt PocockChecked
View source on GitHub
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark

Install

Commands are pinned to commit abeeaf9, the version we read, wherever the install method supports it.

npx skills

Terminal
npx skills add mattpocock/skills@abeeaf95660ba9e8b7c753eb38f441ca707a8823 --skill tdd -a claude-code

Copies the skill into .claude/skills/ in this project, pinned to the reviewed commit.

Plugin marketplace

Claude Code prompt
/plugin install mattpocock-skills@claude-plugins-official

Run inside Claude Code. Installs the whole mattpocock-skills plugin from its default branch, not the pinned commit; the official marketplace is available by default.

What it does

A compact take on test-driven development. The SKILL.md is under 40 lines and puts the detail in two side files, tests.md and mocking.md. Its definition of a good test is one that checks behaviour through a public interface and survives a refactor. The distinctive rule is about seams: before writing any test, the agent writes down the public boundaries it plans to test, gives each a one-line note on what it catches and misses, and gets you to agree. Then it works in vertical slices, one failing test and the smallest change to pass it, and leaves refactoring to the review stage. It names three anti-patterns: tests coupled to implementation, tautological assertions that recompute the expected value the way the code does, and writing all the tests before any code.

How it compares with test-driven-development

obra’s test-driven-development is longer and stricter about process: it insists you watch every test fail, and it lists the excuses agents use to skip that. This skill spends its words on test design instead: which seams to test and how to avoid tests that cannot fail. If your agent already follows red-green but writes brittle or meaningless tests, use this one. If it skips the red step, use obra’s. They also work together.

When to use it

New features or bug fixes where you want tests that are still useful in six months, and teams that want a say in what gets tested.

When to skip it

Spikes and throwaway prototypes. The seam agreement step also adds a round trip with you, which you may not want for a one-line fix.

Try it

Add rate limiting to the /login route, test first. Propose the seams you
want to test and what each one catches before writing anything. Then one
test at a time.

What it can touch

Bundles scripts
No
Pre-approved tools
None declared
Needs
Nothing beyond the agent
Client-specific fields
None, spec fields only

Its instructions steer what your agent does, and it may have changed since the commit we read. How to check a skill.

Instructions only. It writes tests and code and runs your test suite. It refers to a codebase-design skill and a code-review skill from the same repository for vocabulary and refactoring; without them it still works.

At commit abeeaf9 the SKILL.md is 38 lines long. Alongside it:

  • agents/ (1 entry)
  • mocking.md
  • tests.md

Alternatives

Property-based testing for code where a handful of examples cannot cover the inputs. For legacy code with no tests, start with our unit tests for legacy code workflow.

SKILL.md

The file exactly as published at the reviewed commit, reproduced under its MIT licence.

skills/engineering/tdd/SKILL.md
---
name: tdd
description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
---

# Test-Driven Development

TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.

When exploring the codebase, read `GLOSSARY.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.

## What a good test is

Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.

See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.

## Seams: where tests go

A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.

**Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything, so agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.

Ask: "What's the public interface, and which seams should we test?" Give each proposed seam a one-line note on what it catches and what it misses.

When the shape of that interface is itself in question (how deep the module is, where the seam belongs, what the interface should expose), call the Skill tool with "codebase-design" for the vocabulary. It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.

## Anti-patterns

- **Implementation-coupled**: mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
- **Tautological**: the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth: a known-good literal, a worked example, the spec.
- **Horizontal slicing**: writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead: one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.

## Rules of the loop

- **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
- **One slice at a time.** One seam, one test, one minimal implementation per cycle.
- **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
  • Test-driven development

    Enforces red-green-refactor: write a failing test, watch it fail, write the least code to pass, then clean up. Part of obra's Superpowers set.

    Jesse Vincent (obra)Checked at 22f0b46

  • Property-based testing (Trail of Bits)

    Writes and reviews property tests with Hypothesis, fast-check, proptest and others, and tells a wrong property from a real bug when one fails.

    Testing and QAChecked at 149d7b2

  • Systematic debugging

    obra's root-cause-first debugging process from Superpowers: investigate, compare against working code, test one hypothesis at a time, and only then fix.

    Jesse Vincent (obra)Bundles scriptsChecked at 22f0b46