TDD with integration tests

Drives test-first work through public interfaces: agrees the seams to test with the user, runs one red-green cycle per test, mocks only at system boundaries and leaves refactoring to review. Use when building a feature or fixing a bug test-first.

TestingPack: Matt Pocock's skills38 linestdd
Author
Source
mattpocock/skills/skills/engineering/tdd @ abeeaf9
License
MIT · Copyright (c) 2026 Matt Pocock

About this skill

What it does

A reference for the red-green loop that aims at tests worth keeping. Before any test, the agent names the seams, the public boundaries where behaviour can be observed without reaching inside, notes what each catches and misses, and has you confirm them. Each cycle is one seam, one failing test and the least code that passes. Refactoring is moved out of the loop to review.

Three anti-patterns are named: tests coupled to the implementation (mocked internals, private methods, checking the database instead of the interface), tautological tests whose expected value is computed the way the code computes it, and horizontal slicing, all tests first and all code after. It reads GLOSSARY.md, if present, for the domain's words, and respects ADRs.

Two helper files ship with it. tests.md sets good tests against bad ones in TypeScript: checkout through the public API, a user checked through getUser instead of SQL, a total compared with a literal rather than a recomputed sum. mocking.md limits mocks to system boundaries such as external APIs, time and randomness, and shows dependency injection and SDK-style clients with one function per external call.

When to use it, and when not

Use it for a feature or bug fix done test-first, with integration-style tests through real interfaces instead of a suite of mocks.

Skip it for throwaway code, which the author's Throwaway prototype leaves untested on purpose, and for covering existing code, where Unit test writer fits better.

How to run it

The install command below puts the whole folder in place. The agent picks it up by its description for test-first work; to call it yourself:

  • Claude Code: /tdd, or ask for the skill by name.
  • Codex: $tdd.
  • Cursor: type / in the Agent chat and pick tdd.

Example: /tdd Add discount codes to checkout. Propose the seams first.

For interface questions it calls Deep module design, and it leaves refactoring to Code review against standards and spec; install both. Implement a spec runs it in each implementer subagent.

How it differs from similar skills

The other three TDD skills keep refactoring inside the cycle. Our Test-driven development adds a baseline run and a red/green report, the Superpowers version deletes code written before its test, and Addy Osmani's aims for mostly unit tests. Only this one agrees seams with you first and tests only there. Those three install into test-driven-development; this one goes into tdd and clashes with none of them.

Install

Run one command — it saves SKILL.md and the files it uses into your agent's skills folder. Claude Code and Codex pick up a new skill without a restart; if it does not show up, restart the agent.

Claude Code — macOS, Linux
curl -fsSL --create-dirs -o ~/.claude/skills/tdd/SKILL.md https://anymodel.org/en/skills/matt-pocock/tdd/SKILL.md -o ~/.claude/skills/tdd/LICENSE https://anymodel.org/en/skills/matt-pocock/tdd/LICENSE -o ~/.claude/skills/tdd/agents/openai.yaml https://anymodel.org/en/skills/matt-pocock/tdd/agents/openai.yaml -o ~/.claude/skills/tdd/mocking.md https://anymodel.org/en/skills/matt-pocock/tdd/mocking.md -o ~/.claude/skills/tdd/tests.md https://anymodel.org/en/skills/matt-pocock/tdd/tests.md
Codex, Cursor — macOS, Linux
curl -fsSL --create-dirs -o ~/.agents/skills/tdd/SKILL.md https://anymodel.org/en/skills/matt-pocock/tdd/SKILL.md -o ~/.agents/skills/tdd/LICENSE https://anymodel.org/en/skills/matt-pocock/tdd/LICENSE -o ~/.agents/skills/tdd/agents/openai.yaml https://anymodel.org/en/skills/matt-pocock/tdd/agents/openai.yaml -o ~/.agents/skills/tdd/mocking.md https://anymodel.org/en/skills/matt-pocock/tdd/mocking.md -o ~/.agents/skills/tdd/tests.md https://anymodel.org/en/skills/matt-pocock/tdd/tests.md
Claude Code — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE','agents/openai.yaml','mocking.md','tests.md') { $p = Join-Path "$HOME\.claude\skills\tdd" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/matt-pocock/tdd/$f" -UseBasicParsing -OutFile $p }
Codex, Cursor — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE','agents/openai.yaml','mocking.md','tests.md') { $p = Join-Path "$HOME\.agents\skills\tdd" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/matt-pocock/tdd/$f" -UseBasicParsing -OutFile $p }

Any other agent: save the file into its skills folder, or give it the link to the file: https://anymodel.org/en/skills/matt-pocock/tdd/SKILL.md

SKILL.md

Raw

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 for examples and 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.

Connect through AnyModel API

This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.

More from the pack Matt Pocock's skills

Code review against standards and spec

Reviews the diff since a commit, branch or tag on two axes in parallel subagents: the repo's written standards plus a baseline of Fowler code smells, and the originating spec or issue. Use when a branch or PR needs checking against its spec.

Deep module design

Fixes a shared vocabulary for deep modules (interface, seam, adapter, depth, leverage), with the deletion test, dependency categories and a design-it-twice pattern on parallel subagents. Use when designing a module's interface or deciding where a seam goes.

Diagnosing hard bugs

Diagnoses hard bugs and slowdowns by first building a fast, deterministic command that reproduces the exact symptom, then minimising it, ranking falsifiable hypotheses and adding a regression test at a real seam. Use when something fails, throws or got slow.

Domain modeling

Sharpens a project's domain language during design: challenges fuzzy or conflicting terms, writes resolved ones to GLOSSARY.md at once and offers a short ADR only for hard-to-reverse trade-offs. Use when discussing terminology or recording an ADR.

Implement a spec

Implements a spec and its tickets on one integration branch: a fresh implementer subagent per ticket in its own worktree, run in parallel along the blocking graph, then a code review and one fix pass. Use when the tickets from to-tickets are ready.

Improve codebase architecture

Finds shallow modules worth deepening, starting from the code that changes most, shows the candidates in an HTML report with before/after diagrams and grills the chosen one with you. Use when a codebase has grown hard to test or navigate.

Throwaway prototype

Builds throwaway code to answer one design question: a single-file clickable HTML demo for a state model, or several structurally different UI variants on one route switched by a URL param. Use when checking whether logic holds or how a page should look.

Coding session retrospective

Reviews a finished coding session from its logs and proposes changes to the agent's environment: navigation pointers, lint rules, pre-commit and CI checks, reviewer standards, tool use. Use when an agent session went slowly or made avoidable mistakes.

Conversation to spec

Turns the current conversation and codebase into a spec with user stories, implementation and testing decisions, and publishes it to the issue tracker as ready-for-agent, without interviewing the user. Use when a discussed feature needs writing up.

Spec to tickets

Splits a spec, plan or conversation into tracer-bullet tickets, vertical slices that each fit one agent session, with blocking edges, and publishes them as local files or tracker issues. Use when work is too big for one session and needs a task graph.

Issue and PR triage

Triages issues and external PRs on the tracker: gives each a category and a state, checks for existing code and past rejections, reproduces bugs and writes agent briefs for ready work. Use when a maintainer works through incoming issues and PRs.

Wayfinder for huge work

Charts work too big for one agent session as a map issue with child decision tickets on the tracker, then resolves one ticket per session until the route to the goal is clear. Use when a large effort has open questions that block a spec or plan.

Bash wizard for manual steps

Generates an interactive bash script that walks a person through manual steps such as dashboard setup, API keys and CI secrets, opening each URL and saving values to .env and GitHub secrets. Use when setup or a migration needs steps only a human can take.

Git guardrails for Claude Code

Installs a Claude Code PreToolUse hook that stops the usual forms of git push, reset --hard, clean -f, branch -D and checkout or restore of the whole tree, for one project or all, then tests it. Use when you want a safety net against an agent pushing or discarding work on its own.

Migrate tests to shoehorn

Replaces as and as unknown as casts in TypeScript tests with fromPartial and fromAny from @total-typescript/shoehorn, adds the imports and runs the type check. Use when tests fake whole objects or cast partial test data to satisfy the compiler.

Pre-commit hooks setup

Sets up Husky and lint-staged in a Node repo so each commit runs Prettier on staged files, then the typecheck and test scripts, matched to the lockfile, and makes the first commit through the hook. Use when a repo has no commit-time checks.

Grilling a plan

Questions the user about a plan or decision in rounds of numbered questions with recommended answers, looks facts up itself through subagents and stops only when no decision is left assumed. Use when a plan needs stress-testing before work starts.

Teach me a topic

Runs a multi-session course in the current folder: a mission, trusted sources, short HTML lessons with quizzes, reference sheets and learning records that set the next lesson. Use when the user wants to learn a topic over time, not get one answer.

Decision questionnaire

Writes a Markdown questionnaire for someone who holds knowledge the user lacks, after asking only who it goes to and what answers are needed, with the most important questions first. Use when a decision depends on facts from another person.

Writing for agents

Gives the rules for writing text agents read: skill descriptions as context pointers, what to keep inline and what to move to a separate file, completion criteria, leading words and pruning. Use when creating or editing a skill, AGENTS.md or CLAUDE.md.