tdd

tdd is a command for coding agents from xu-xiang/everything-claude-code-zh. It costs 22 tokens per session (601 once invoked), scanned A, original, MIT.

A command that applies test-driven development (TDD), where you write a failing test before the code, then make it pass and improve the code. It targets at least 80% test coverage, with stricter targets for critical logic.

In plain words
What is it for?
Use it to build TypeScript features by defining their inputs and outputs, writing unit and integration tests, implementing the smallest solution, refactoring, and checking coverage.
Why use it?
It provides a fixed test-first process and checks that the implementation is covered by tests. This helps expose missing normal, boundary, and error cases during development.

Command

Part of the everything-claude-code-zh plugin — 17 skills, 26 commands, 13 agents shipped together

About the project

everything-claude-code-zh is a Chinese translation of a collection of configurations for Claude Code and other AI coding agents. It provides agents, skills, hooks, commands, rules, and MCP configurations intended to support development workflows such as memory persistence, security scanning, evaluation, and research-first work. The catalogue includes commands, skills, agents, instructions, and a plugin from this configuration set.

xu-xiang/everything-claude-code-zh · 1,929 stars · on GitHub · oneskill.one

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 commands/xu-xiang/everything-claude-code-zh/tdd
Clone the repo
git clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh

Or install everything-claude-code-zh, the plugin that ships this one along with the rest of its 17 skills, 26 commands, 13 agents.

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/commands/xu-xiang/everything-claude-code-zh/tdd.svg)](https://agentmods.dev/commands/xu-xiang/everything-claude-code-zh/tdd)
Your own site
<a href="https://agentmods.dev/commands/xu-xiang/everything-claude-code-zh/tdd"><img src="https://agentmods.dev/badge/commands/xu-xiang/everything-claude-code-zh/tdd.svg" alt="Measured on agentmods" height="20"></a>
Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 601 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.1 $0.00022 $0.00601
Opus 5 $0.00011 $0.00300
Sonnet 5 $0.00004 $0.00120
Haiku 4.5 $0.00002 $0.00060

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

.opencode/commands/tdd.md · 67 lines

What it actually says

TDD 命令 (TDD Command)

使用严格的测试驱动开发(TDD)实现以下内容:$ARGUMENTS

TDD 循环(强制执行)

RED → GREEN → REFACTOR → REPEAT
  1. 红 (RED)首先编写一个失败的测试
  2. 绿 (GREEN):编写最小化的代码以通过测试
  3. 重构 (REFACTOR):在保持测试通过的同时改进代码
  4. 重复 (REPEAT):持续进行直到功能开发完成

你的任务

步骤 1:定义接口 (SCAFFOLD)

  • 为输入/输出定义 TypeScript 接口(Interfaces)
  • 使用 throw new Error('Not implemented') 创建函数签名

步骤 2:编写失败的测试 (RED)

  • 编写测试接口的代码
  • 包含正常路径 (happy path)、边界情况 (edge cases) 和错误条件 (error conditions)
  • 运行测试 —— 验证其结果为 失败 (FAIL)

3 步:实现最小化代码 (GREEN)

  • 编写足以让测试通过的代码即可
  • 不要进行过早优化
  • 运行测试 —— 验证其结果为 通过 (PASS)

步骤 4:重构 (IMPROVE)

  • 提取常量,改进命名
  • 消除重复
  • 运行测试 —— 验证其结果仍为 通过 (PASS)

步骤 5:检查覆盖率 (Coverage)

  • 目标:最低 80%
  • 关键业务逻辑:100%
  • 如有需要,添加更多测试

覆盖率要求

代码类型 最低标准
标准代码 (Standard code) 80%
财务计算 (Financial calculations) 100%
身份验证逻辑 (Authentication logic) 100%
安全关键代码 (Security-critical code) 100%

应包含的测试类型

  • 单元测试 (Unit Tests):单个函数
  • 边界情况 (Edge Cases):空、null、最大值、边界
  • 错误条件 (Error Conditions):无效输入、网络故障
  • 集成测试 (Integration Tests):API 端点、数据库操作

强制执行:必须在实现之前编写测试。严禁跳过红 (RED) 阶段。

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. 6d ago First seen · 67 lines · 22 tokens per session scan A 4451cdebf449

Subscribe to this mod's changes

tdd is a command published in the GitHub repository xu-xiang/everything-claude-code-zh (1,929 stars, last pushed 6mo ago), licensed MIT. It adds 22 tokens to every session and 601 once invoked, about $0.0001 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.