TDD
pietheinstrengholt/rssmonster
Test-driven development. An agent skill from pietheinstrengholt/rssmonster.
“在实现任何功能或修复 bug 时使用,在编写实现代码之前”
$ npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install jnMetaCode/superpowers-zh test-driven-development --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/jnMetaCode/superpowers-zh.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/test-driven-development .claude/skills/test-driven-development && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "test-driven-development" agent skill from https://github.com/jnMetaCode/superpowers-zh/tree/main/skills/test-driven-development into .claude/skills/test-driven-development/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "test-driven-development", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/jnMetaCode/superpowers-zh/tree/main/skills/test-driven-developmentType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install jnMetaCode/superpowers-zh test-driven-development --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jnMetaCode/superpowers-zh.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/test-driven-development .agents/skills/test-driven-development && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "test-driven-development" agent skill from https://github.com/jnMetaCode/superpowers-zh/tree/main/skills/test-driven-development into .agents/skills/test-driven-development/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "test-driven-development", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install jnMetaCode/superpowers-zh test-driven-development --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jnMetaCode/superpowers-zh.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/test-driven-development .cursor/skills/test-driven-development && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "test-driven-development" agent skill from https://github.com/jnMetaCode/superpowers-zh/tree/main/skills/test-driven-development into .cursor/skills/test-driven-development/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "test-driven-development", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/jnMetaCode/superpowers-zh.git --path skills/test-driven-development--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install jnMetaCode/superpowers-zh test-driven-development --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jnMetaCode/superpowers-zh.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/test-driven-development .gemini/skills/test-driven-development && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "test-driven-development" agent skill from https://github.com/jnMetaCode/superpowers-zh/tree/main/skills/test-driven-development into .gemini/skills/test-driven-development/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "test-driven-development", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install jnMetaCode/superpowers-zh test-driven-developmentInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/jnMetaCode/superpowers-zh.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/test-driven-development .github/skills/test-driven-development && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "test-driven-development" agent skill from https://github.com/jnMetaCode/superpowers-zh/tree/main/skills/test-driven-development into .github/skills/test-driven-development/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "test-driven-development", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install jnMetaCode/superpowers-zh test-driven-development --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jnMetaCode/superpowers-zh.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/test-driven-development .opencode/skills/test-driven-development && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "test-driven-development" agent skill from https://github.com/jnMetaCode/superpowers-zh/tree/main/skills/test-driven-development into .opencode/skills/test-driven-development/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "test-driven-development", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
test-driven-developmentTest Driven Development is a skill in jnMetaCode/superpowers-zh (8.3k stars). Its SKILL.md is about 1.4k tokens, with 1 other file in the folder. Licence: MIT.
Read from SKILL.md and the folder at commit fe34019. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
npmcargoFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Test Driven Development loads about 1.4k tokens when it runs. Until then it costs about 13 tokens; SKILL.md has 233 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from jnMetaCode/superpowers-zh at commit fe34019, republished under its MIT licence (© jnMetaCode). 233 words, ~1,434 tokens.
.claude/skills/test-driven-development/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.先写测试。看它失败。写最少的代码让它通过。
核心原则: 如果你没有看到测试失败,你就不知道它是否测试了正确的东西。
违反规则的字面意思就是违反规则的精神。
始终使用:
例外(需询问你的人类伙伴):
想着"就这一次跳过 TDD"?停下来。那是在给自己找借口。
没有失败的测试,就不写生产代码先写了代码再写测试?删掉它。从头来过。
没有例外:
从测试出发,重新实现。句号。
digraph tdd_cycle {
rankdir=LR;
red [label="红灯\n编写失败的测试", shape=box, style=filled, fillcolor="#ffcccc"];
verify_red [label="验证正确失败", shape=diamond];
green [label="绿灯\n最少代码", shape=box, style=filled, fillcolor="#ccffcc"];
verify_green [label="验证通过\n全部绿灯", shape=diamond];
refactor [label="重构\n清理代码", shape=box, style=filled, fillcolor="#ccccff"];
next [label="下一个", shape=ellipse];
red -> verify_red;
verify_red -> green [label="是"];
verify_red -> red [label="错误的\n失败"];
green -> verify_green;
verify_green -> refactor [label="是"];
verify_green -> green [label="否"];
refactor -> verify_green [label="保持\n绿灯"];
verify_green -> next;
next -> red;
}写一个最小的测试来展示期望行为。
<Good>
```typescript
test('retries failed operations 3 times', async () => {
let attempts = 0;
const operation = () => {
attempts++;
if (attempts < 3) throw new Error('fail');
return 'success';
};
const result = await retryOperation(operation);
expect(result).toBe('success'); expect(attempts).toBe(3); });
名称清晰,测试真实行为,只测一件事
</Good>
<Bad>
```typescript
test('retry works', async () => {
const mock = jest.fn()
.mockRejectedValueOnce(new Error())
.mockRejectedValueOnce(new Error())
.mockResolvedValueOnce('success');
await retryOperation(mock);
expect(mock).toHaveBeenCalledTimes(3);
});名称模糊,测试的是 mock 而非代码
</Bad>
要求:
必须执行。绝不跳过。
npm test path/to/test.test.ts确认:
测试通过了? 你在测试已有的行为。修改测试。
测试报错了? 修复错误,重新运行直到它正确地失败。
写最简单的代码让测试通过。
<Good>
```typescript
async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
for (let i = 0; i < 3; i++) {
try {
return await fn();
} catch (e) {
if (i === 2) throw e;
}
}
throw new Error('unreachable');
}
```
刚好够通过测试
</Good>
<Bad>
```typescript
async function retryOperation<T>(
fn: () => Promise<T>,
options?: {
maxRetries?: number;
backoff?: 'linear' | 'exponential';
onRetry?: (attempt: number) => void;
}
): Promise<T> {
// YAGNI
}
```
过度设计
</Bad>
不要添加功能、重构其他代码或做超出测试要求的"改进"。
必须执行。
npm test path/to/test.test.ts确认:
测试失败了? 修改代码,不是测试。
其他测试失败了? 立即修复。
"其他测试"指的是项目的整个测试套件,不只是你那个文件。 你写的那个测试跑绿了,不等于测试套件是绿的。在宣称改动完成之前,运行项目的测试命令(直接 pytest、npm test、cargo test——仓库用什么就跑什么),即使你的任务只点名了一个测试文件。任务里的范围说明约束的是交付物,不是你的验证。那次运行暴露出的任何失败——包括不是你造成的——都要在报告里点名写出;一个你眼看着滚过去却没提的红色测试,就是一份靠遗漏造假的报告。
只有在绿灯之后才重构:
保持测试绿灯。不要添加行为。
为下一个功能写下一个失败的测试。
| 特质 | 好的 | 差的 |
|---|---|---|
| 最小化 | 只测一件事。名称中有"和"?拆分它。 | test('validates email and domain and whitespace') |
| 清晰 | 名称描述行为 | test('test1') |
| 展示意图 | 展示期望的 API | 掩盖了代码应该做什么 |
写任何测试、或修改任何测试时,阅读 writing-good-tests.md,那里是让测试保持诚实的规则:
| 借口 | 现实 |
|---|---|
| "太简单了不用测" | 简单的代码也会出 bug。测试只需 30 秒。 |
| "我之后补测试" | 后写的测试立即通过——而立即通过什么都证明不了。它可能测错了对象、测的是实现而不是行为、或者漏掉你忘了的那个边界情况。你从没看着它失败过,所以你从没证明它能抓住 bug。先写测试逼你看到那次失败。 |
| "后补测试也能达到相同目的(重的是精神不是仪式)" | 后补测试回答的是"这做了什么?";先写测试回答的是"这应该做什么?"后写的测试已经被你写好的代码带偏了——你验证的是你记得的那些情况,而不是你本该发现的那些。有覆盖率,没有测试有效的证明。 |
| "已经手动测试过了" | 手动测试是临时的:没有记录你覆盖了什么、代码一改就没法重跑、压力之下极易漏掉情况。"我试的时候是好的" ≠ 全面。自动化测试每次都以同样的方式运行。 |
| "删除 X 小时的工作太浪费" | 沉没成本谬误——那些时间无论怎样都已经花掉了。真正的选择是:用 TDD 重写(高置信度)vs 留着它事后补测试(低置信度、很可能有 bug)。留着你无法信任的代码才是浪费。 |
| "留作参考,然后先写测试" | 你会去改编它。那就是后补测试。删除就是删除。 |
| "需要先探索一下" | 可以。探索完了扔掉,从 TDD 开始。 |
| "测试难写 = 设计不清楚" | 听测试的。难以测试 = 难以使用。 |
| "TDD 会拖慢我" | TDD 就是务实的那条路:在提交前抓住 bug、防止回归、让你能无所畏惧地重构。所谓"务实"的抄近道,等于在生产环境里调试——更慢,不是更快。 |
| "手动测试更快" | 手动测试无法证明边界情况。每次修改你都得重新测。 |
| "现有代码没有测试" | 你在改进它。为现有代码补测试。 |
以上所有情况都意味着:删除代码。用 TDD 从头开始。
Bug: 空邮箱被接受了
红灯
test('rejects empty email', async () => {
const result = await submitForm({ email: '' });
expect(result.error).toBe('Email required');
});验证红灯
$ npm test
FAIL: expected 'Email required', got undefined绿灯
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: 'Email required' };
}
// ...
}验证绿灯
$ npm test
PASS重构 如果需要,提取验证逻辑以支持多个字段。
在标记工作完成之前:
不能全部勾选?你跳过了 TDD。从头开始。
| 问题 | 解决方案 |
|---|---|
| 不知道怎么测试 | 写出你期望的 API。先写断言。问你的人类伙伴。 |
| 测试太复杂 | 设计太复杂。简化接口。 |
| 必须 mock 所有东西 | 代码耦合太紧。使用依赖注入。 |
| 测试 setup 太庞大 | 提取辅助函数。还是复杂?简化设计。 |
发现 bug?写一个重现 bug 的失败测试。按 TDD 循环走。测试既证明了修复有效,又防止了回归。
绝不在没有测试的情况下修复 bug。
生产代码 → 测试存在且先失败
否则 → 不是 TDD没有你的人类伙伴的许可,没有例外。
© jnMetaCode, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 1 other file in skills/test-driven-development of jnMetaCode/superpowers-zh.
Open the folder on GitHubat commit fe34019
Test Driven Development next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Test Driven Development this skilljnMetaCode/superpowers-zh | 8.3k | — | ~1.4k | Automated safety check: Pass | MIT | |
| TDDpietheinstrengholt/rssmonster | 564 | 30 repos | ~906 | Automated safety check: Pass | MIT | |
| TDD WorkflowhellangleZ/burn-in-cceverywhere-ralph | 112 | 11 repos | ~2.4k | Automated safety check: Pass | None | |
| TDDsanity-io/sanity | 6.4k | 20 repos | ~1k | Automated safety check: Pass | MIT | |
| Test Driven Developmentfarm-fe/farm | 5.6k | 51 repos | ~2.5k | Automated safety check: Pass | MIT | |
| Tapd Story PipelineTencentBlueKing/bk-bcs | 840 | — | ~2.6k | Automated safety check: Pass | Custom licence |
pietheinstrengholt/rssmonster
Test-driven development. An agent skill from pietheinstrengholt/rssmonster.
hellangleZ/burn-in-cceverywhere-ralph
A skill your agent uses when writing new features, fixing bugs, or refactoring code.
sanity-io/sanity
Test-driven development with red-green-refactor loop. An agent skill from sanity-io/sanity.
farm-fe/farm
A skill your agent uses when implementing any feature or bugfix, before writing implementation code
TencentBlueKing/bk-bcs
单需求实现流水线——把一个 TAPD 需求从零推进到代码提交。自动串联技术澄清、 开发计划、任务拆分、TDD 实现、架构/安全校验、代码提交六个阶段。
maddhruv/absolute
One-time setup for absolute: interview how you want it to behave (output style, autonomy, TDD strictness, spec dir, families) + detect the stack once, then write .absolute.config.json (project…
jnMetaCode/superpowers-zh
Turns a rough idea into an approved design before any code is written, sorting the request into spike, bounded or architectural and enforcing an approval gate.
jnMetaCode/superpowers-zh
Reference for Chinese-language git commits and changelogs: Conventional Commits adapted for Chinese teams, with templates, breaking-change notes and issue links for several platforms.
jnMetaCode/superpowers-zh
Executes a written implementation plan task by task in the current session, with a progress ledger, test-first gates and one fresh-context review at the end.
jnMetaCode/superpowers-zh
Sets up an isolated workspace before feature work or plan execution, preferring native worktree tools and falling back to git worktree, with instructions in Chinese.
jnMetaCode/superpowers-zh
Runs agency-orchestrator YAML workflows inside the current agent session, with the session's own model playing each role in turn and no API key needed.
jnMetaCode/superpowers-zh
Gives Chinese-language templates and priority labels for code review feedback, plus guidance on bilingual comments, commit messages and common team anti-patterns.
Categories
Run `npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a claude-code`. Or copy the skill folder (skills/test-driven-development in jnMetaCode/superpowers-zh) into .claude/skills/test-driven-development in your project. Claude Code loads it when a task matches its description.
Run `npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a codex`. Or copy the skill folder (skills/test-driven-development in jnMetaCode/superpowers-zh) into .agents/skills/test-driven-development in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jnMetaCode/superpowers-zh --skill test-driven-development -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/test-driven-development, .gemini/skills/test-driven-development, .github/skills/test-driven-development and .opencode/skills/test-driven-development in your project.
Going by SKILL.md and its folder, Test Driven Development needs the command-line tools its instructions call (npm and cargo).
SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Test Driven Development is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Test Driven Development: TDD (pietheinstrengholt/rssmonster, 564 stars), TDD Workflow (hellangleZ/burn-in-cceverywhere-ralph, 112 stars), TDD (sanity-io/sanity, 6.4k stars) and Test Driven Development (farm-fe/farm, 5.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
jnMetaCode (a GitHub user) maintains it in jnMetaCode/superpowers-zh, which has 8,270 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on October 4, 2026.
Source: jnMetaCode/superpowers-zh on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.