tdd

tdd is a skill for Claude Code, Codex from devcxl/mattpocock-skills-zh. It costs 39 tokens per session (898 once invoked), scanned A, original, MIT.

Guidance for test-driven development (TDD), a method where you write a failing test, make it pass with a small change, and then improve the code. It focuses on tests that check user-visible behavior through public interfaces.

In plain words
What is it for?
Use it when building features or fixing bugs test-first, following the red-green-refactor cycle, planning which public boundaries to test, choosing test seams, and writing integration tests.
Why use it?
It helps keep tests useful during refactoring by avoiding tests tied to private implementation details. It also encourages small vertical slices so each test and implementation change responds to what was learned in the previous cycle.

Skill for Claude CodeCodex

Written for Claude Code and Codex: shipped in a Claude Code plugin, but also agents/openai.yaml present.

Part of the mattpocock-skills plugin — 37 skills shipped together

Good fit Use it when building features or fixing bugs test-first, following the red-green-refactor cycle, planning which public boundaries to test, choosing test seams, and writing integration tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/devcxl/mattpocock-skills-zh/tdd
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.

Any agent
npx skills add devcxl/mattpocock-skills-zh --skill tdd
Clone the repo
git clone --depth 1 https://github.com/devcxl/mattpocock-skills-zh

Made for: Claude Code, Codex.

Or install mattpocock-skills, the plugin that ships this one along with the rest of its 37 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tdd

README.md
[![agentmods](https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/tdd/github.svg)](https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/tdd)
Your own site
<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/tdd"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/tdd/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tdd

Your own site · 80×15
<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/tdd"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/tdd.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 898 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00039 $0.00898
Opus 5 $0.00019 $0.00449
Sonnet 5 $0.00008 $0.00180
Haiku 4.5 $0.00004 $0.00090

Measured 11d ago against content hash 55e92a608050, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, 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 11d 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 · 39 lines

What it actually says

测试驱动开发(Test-Driven Development)

TDD 是红 → 绿的循环。本技能是让这个循环产出值得保留的测试的参考:好测试是什么、测试放在哪里、反模式有哪些、循环的规则是什么。每一节在每一个循环中都适用——在循环之前和之中查阅它们,而不是之后。

探索代码库时,读 CONTEXT.md(如果存在),让测试名称和接口词汇与项目的领域语言一致,并尊重你正在触碰的区域的 ADR。

好测试是什么

测试通过公共接口验证行为,而不是实现细节。代码可以彻底改变;测试不应该。好测试读起来像一份规格——"用户可以用有效购物车结账"精确地告诉你存在什么能力——而且因为它不关心内部结构,能在重构中存活。

示例见 tests.md,mocking 指南见 mocking.md

接缝——测试放在哪里

**接缝(seam)**是你测试所在的公共边界:在不伸手进内部的情况下观察行为的接口。测试住在接缝处,绝不对着内部。

只在预先约定的接缝处测试。 写任何测试之前,写下要测试的接缝并与用户确认。没有测试写在未经确认的接缝上。你不可能测试所有东西——提前约定接缝,正是让测试精力落在关键路径和复杂逻辑上、而不是每个边界情况上的方法。

问:"公共接口是什么,我们应该测试哪些接缝?"

当接口的形态本身存疑时——模块该有多深、接缝该在哪里、接口应该暴露什么——调用 Skill 工具并传入 "codebase-design" 来获得词汇。它是 module、interface、depth、seam、adapter、leverage、locality 这些词的共享来源,是一份供查阅的参考,而不是要跑的一场会话。

反模式

  • 与实现耦合(Implementation-coupled) — mock 内部协作者、测试私有方法、或通过旁路渠道验证(查数据库而不是用接口)。识别信号:重构时行为没变,测试却挂了。
  • 同义反复(Tautological) — 断言用与代码相同的方式重新计算期望值(expect(add(a, b)).toBe(a + b)、以同样方式手工推导出的快照、断言常量等于自身),所以它构造性地通过,永远不可能与代码相左。期望值必须来自独立的真实来源——已知正确的字面量、手算的示例、规格。
  • 水平切片(Horizontal slicing) — 先写完所有测试,再写所有实现。成批的测试验证的是想象出来的行为:你测试的是事物的形状而不是面向用户的行为,测试对真实变化变得不敏感,而且你在理解实现之前就锁定了测试结构。改用垂直切片——一个测试 → 一个实现 → 重复,每个测试都是一颗示踪子弹,对上一循环教会你的东西作出回应。

循环的规则

  • 先红后绿。 先写会失败的测试,然后只写恰好能通过它的代码。不要预想未来的测试,也不要加投机性的功能。
  • 一次一个切片。 每个循环一个接缝、一个测试、一个最小实现。
  • 重构不是循环的一部分。 它属于审查阶段(见 code-review 技能),不属于红 → 绿实现循环。
Files

What ships with it

3 files 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. 11d ago First seen · 39 lines · 39 tokens per session scan A 55e92a608050

Subscribe to this mod's changes

tdd is a skill published in the GitHub repository devcxl/mattpocock-skills-zh (331 stars, last pushed 5d ago), licensed MIT. It adds 39 tokens to every session and 898 once invoked, about $0.0002 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

writing-skills

A guide for creating and testing reusable instructions for AI agents, called skills. It applies test-driven development, or TDD—the practice of writing tests before implementation—to instruction documents.

jnMetaCode/superpowers-zh · 23 tokens

test-driven-development

Test-driven development, or TDD, is a way to build software by writing a test that fails, adding the smallest code that makes it pass, and then cleaning up the code. These instructions require that process for features, bug fixes, refactors, and behavior changes.

jnMetaCode/superpowers-zh · 20 tokens

dsh-test-first

A test-first process for fixing bugs or adding features: write a failing test, make the smallest change that passes it, then improve the code.

hackerFish/awesome-dsh-skills · 28 tokens

pair-programming

AI-assisted pair programming with multiple modes (driver/navigator/switch), real-time verification, quality monitoring, and comprehensive testing. Supports TDD, debugging, refactoring, and learning sessions. Features automatic role switching, continuous code review, security scanning, and performance optimization with…

frankxai/claude-skills-library · 85 tokens

test-driven

A test-driven development guide. TDD means writing a test for the desired behaviour first, seeing it fail, then writing the smallest implementation that makes it pass.

Wade-DevCode/awesome-coding-skills-cn · 22 tokens

test-driven-development

Use when implementing any feature or bugfix, before writing implementation code.

w4ngyu/openclaw-superpowers · 17 tokens