tdd

A guide to test-driven development (TDD), a way of writing a test before the code and then making the test pass. It focuses on tests that check what users can do through a public interface.

In plain words
What is it for?
Building features or fixing bugs by writing durable behaviour tests first, especially when using the red-green-refactor cycle.
Why use it?
It reduces tests that break whenever internal code is reorganised or that check implementation details instead of behaviour. It also gives the red-green loop a clear structure.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/assisjp/specflow/tdd
Any agent
npx skills add assisjp/specflow --skill tdd
Clone the repo
git clone --depth 1 https://github.com/assisjp/specflow

Made for: Claude Code, Codex.

Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 733 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00052 $0.00733
Opus 5 $0.00026 $0.00367
Sonnet 5 $0.00010 $0.00147
Haiku 4.5 $0.00005 $0.00073

Measured 2d ago against content hash d7506543c5fd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tdd scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/engineering/tdd/SKILL.md · 37 lines

How it starts

The opening of the file, as written. The whole thing — 37 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test-Driven Development

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

When exploring the code, read CONTEXT.md if it exists so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you touch.

What a good test is

A good test verifies behaviour through a public interface, not implementation details. The internals can change entirely; the test should not. It reads like a specification — "user can checkout with a valid cart" tells you exactly what capability exists — and it survives refactors because it does not care about internal structure.

The value of a test is the bugs it catches minus the refactors it obstructs. A test coupled to internals has that subtraction come out negative.

Seams — where tests go

A seam is the public boundary you test at: the interface where you observe behaviour 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 at an unconfirmed seam. You cannot test everything — agreeing seams up front is how effort lands on the critical paths and the complex logic instead of on every trivial edge case. Prefer the fewest, highest seams; the ideal is one.

Ask: "What is the public interface here, and which seams should we test?"

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 on a refactor when behaviour did not change.
  • Tautological — the assertion recomputes the expected value the same way the code does (expect(add(a, b)).toBe(a + b), a hand-derived snapshot, a constant equal to itself). 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 the tests first, then all the implementation. Bulk tests verify imagined behaviour, go insensitive to real changes, and lock in test structure before the implementation is understood. Work in vertical slices: one test → one implementation → repeat, each test a tracer bullet responding to what the last cycle taught you.

Read the full file on GitHub · 37 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 37 lines · 52 tokens per session scan A d7506543c5fd

Subscribe to this mod's changes

tdd is a skill published in the GitHub repository assisjp/specflow (17 stars, last pushed 22d ago), licensed MIT. It adds 52 tokens to every session and 733 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens