tdd

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

A reference for Test-Driven Development (TDD), a method where you write a failing test, make it pass, and then improve the code. It covers how to write durable tests, where to place them, and which patterns to avoid.

In plain words
What is it for?
Use it while planning and writing each TDD cycle. It helps choose test boundaries, name tests clearly, check important behavior, and avoid tests tied to private implementation details.
Why use it?
It helps prevent tests from breaking whenever internal code changes. It also keeps testing focused on the behavior users can observe through public interfaces.

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 — 36 skills shipped together

Good fit Use it while planning and writing each TDD cycle. It helps choose test boundaries, name tests clearly, check important behavior, and avoid tests tied to private implementation details.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vinvcn/mattpocock-skills-zh-cn/tdd
About the project

mattpocock-skills-zh-CN is a Simplified Chinese localization of a collection of reusable instructions for coding agents. Chinese-speaking developers use the translated skills to support engineering workflows while keeping their original commands, paths, identifiers, and behavior. The catalogue contains the localized skills, instructions, and plugin components.

vinvcn/mattpocock-skills-zh-CN · 4,149 stars · on GitHub

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 vinvcn/mattpocock-skills-zh-CN --skill tdd
Clone the repo
git clone --depth 1 https://github.com/vinvcn/mattpocock-skills-zh-CN

Made for: Claude Code, Codex.

Or install mattpocock-skills, the plugin that ships this one along with the rest of its 36 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/vinvcn/mattpocock-skills-zh-cn/tdd/github.svg)](https://agentmods.dev/skills/vinvcn/mattpocock-skills-zh-cn/tdd)
Your own site
<a href="https://agentmods.dev/skills/vinvcn/mattpocock-skills-zh-cn/tdd"><img src="https://agentmods.dev/badge/skills/vinvcn/mattpocock-skills-zh-cn/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/vinvcn/mattpocock-skills-zh-cn/tdd"><img src="https://agentmods.dev/badge/skills/vinvcn/mattpocock-skills-zh-cn/tdd.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 787 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
  • Socket pass 6 May 2026
  • Snyk pass 6 May 2026
  • 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.00042 $0.00787
Opus 5 $0.00021 $0.00394
Sonnet 5 $0.00008 $0.00157
Haiku 4.5 $0.00004 $0.00079

Measured 12d ago against content hash a36a6860bb0e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, 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 12d 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

How it starts

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

Test-Driven Development

TDD 是 red -> green loop。这个 skill 是让该 loop 产出值得保留的 tests 的 reference:什么是好 test、tests 应该放在哪里、anti-patterns,以及 loop 的规则。每个 cycle 前和 cycle 中都要参考这些内容,而不是事后才看。

探索 codebase 时,读取 CONTEXT.md(如果存在),让 test names 和 interface vocabulary 与项目 domain language 对齐,并尊重你触碰区域的 ADRs。

What a good test is

Tests 应通过 public interfaces 验证 behavior,而不是 implementation details。代码可以完全改变;tests 不该随之改变。一个好 test 读起来像 specification:"user can checkout with valid cart" 能清楚说明存在什么能力;因为它不关心 internal structure,所以能承受 refactors。

示例见 tests.md,mocking 规则见 mocking.md

Seams — where tests go

Seam 是你测试的 public boundary:可以观察 behavior、但不伸手进入内部的 interface。Tests 放在 seams 上,绝不针对 internals。

只测试预先认可的 seams。 写任何 test 前,先写下要测试的 seams 并与用户确认。未经确认的 seam 不写 test。你无法测试所有东西;提前认可 seams,才能把测试精力放在 critical paths 和复杂 logic 上,而不是每个 edge case。

询问:"What's the public interface, and which seams should we test?"

当 interface 的形状本身就是问题所在时——module 该多深、seam 该放在哪里、interface 应该暴露什么——用 /codebase-design skill 获取词汇。它是 module、interface、depth、seam、adapter、leverage 和 locality 这些术语的共享来源,是供查阅的 reference,而不是要运行的 session。

Anti-patterns

  • Implementation-coupled — mock internal collaborators、测试 private methods,或通过 side channel 验证(例如不用 interface 而直接查询 database)。特征是 refactor 时 test 失败,但 behavior 没变。
  • Tautological — assertion 以和代码相同的方式重新计算 expected value(expect(add(a, b)).toBe(a + b)、手工按同一逻辑生成 snapshot、把 constant 断言等于它自己),因此天然 pass,永远无法与代码 disagree。Expected values 必须来自独立 source of truth:known-good literal、worked example 或 spec。
  • Horizontal slicing — 先写所有 tests,再写所有 implementation。批量 tests 验证的是 想象中的 behavior:你测试的是东西的 shape,不是 user-facing behavior;tests 会对真实变化迟钝,并在理解 implementation 前承诺 test structure。改用 vertical slices:一个 test -> 一个 implementation -> repeat,每个 test 都是回应上一轮学习的 tracer bullet

Rules of the loop

  • Red before green. 先写 failing test,再只写足够让它通过的代码。不要预判未来 tests,也不要添加 speculative features。
  • One slice at a time. 每个 cycle 只处理一个 seam、一个 test、一个 minimal implementation。
  • Refactoring is not part of the loop. Refactoring 属于 review stage(见 code-review skill),不属于 red -> green implementation cycle。

Read the full file on GitHub · 39 lines

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. 12d ago First seen · 39 lines · 42 tokens per session scan A a36a6860bb0e

Subscribe to this mod's changes

tdd is a skill published in the GitHub repository vinvcn/mattpocock-skills-zh-CN (4,149 stars, last pushed 4d ago), licensed MIT. It adds 42 tokens to every session and 787 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.