test-driven-development

test-driven-development is a skill for Claude Code from Leodorareluctant259/superpowers-zh. It costs 20 tokens per session (2,866 once invoked), scanned A, a copy of test-driven-development, MIT.

A test-driven development (TDD) workflow: write a test first, confirm that it fails, add the smallest implementation, and then clean up the code.

In plain words
What is it for?
Use it when adding features, fixing bugs, changing behavior, or refactoring code, except where its stated exceptions apply.
Why use it?
It makes the expected behavior explicit before implementation and helps show that a test actually detects the missing behavior.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the superpowers-zh plugin — 20 skills, 3 commands, 1 agent, 1 hook shipped together

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/leodorareluctant259/superpowers-zh/test-driven-development
Any agent
npx skills add Leodorareluctant259/superpowers-zh --skill test-driven-development
Clone the repo
git clone --depth 1 https://github.com/Leodorareluctant259/superpowers-zh

Made for: Claude Code.

Or install superpowers-zh, the plugin that ships this one along with the rest of its 20 skills, 3 commands, 1 agent, 1 hook.

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 test-driven-development

README.md
[![agentmods](https://agentmods.dev/badge/skills/leodorareluctant259/superpowers-zh/test-driven-development.svg)](https://agentmods.dev/skills/leodorareluctant259/superpowers-zh/test-driven-development)
Your own site
<a href="https://agentmods.dev/skills/leodorareluctant259/superpowers-zh/test-driven-development"><img src="https://agentmods.dev/badge/skills/leodorareluctant259/superpowers-zh/test-driven-development.svg" alt="Measured on agentmods" height="20"></a>
Per session 20 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,866 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.00020 $0.02866
Opus 5 $0.00010 $0.01433
Sonnet 5 $0.00004 $0.00573
Haiku 4.5 $0.00002 $0.00287

Measured 5d ago against content hash b089af965957, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

test-driven-development 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 5d 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.

Origin

This is a copy

100% identical to test-driven-development — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/test-driven-development/SKILL.md · 372 lines

How it starts

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

测试驱动开发(TDD)

概述

先写测试。看它失败。写最少的代码让它通过。

核心原则: 如果你没有看到测试失败,你就不知道它是否测试了正确的东西。

违反规则的字面意思就是违反规则的精神。

何时使用

始终使用:

  • 新功能
  • Bug 修复
  • 重构
  • 行为变更

例外(需询问你的人类伙伴):

  • 一次性原型
  • 生成的代码
  • 配置文件

想着"就这一次跳过 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;
}

红灯 - 编写失败的测试

写一个最小的测试来展示期望行为。

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 而非代码

要求:

  • 一个行为
  • 清晰的名称
  • 使用真实代码(除非不得已才用 mock)

验证红灯 - 看它失败

必须执行。绝不跳过。

npm test path/to/test.test.ts

确认:

  • 测试失败(不是报错)
  • 失败信息符合预期
  • 失败原因是功能缺失(不是拼写错误)

测试通过了? 你在测试已有的行为。修改测试。

测试报错了? 修复错误,重新运行直到它正确地失败。

Read the full file on GitHub · 372 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. 5d ago First seen · 372 lines · 20 tokens per session scan A b089af965957

Subscribe to this mod's changes

test-driven-development is a skill published in the GitHub repository Leodorareluctant259/superpowers-zh (5 stars, last pushed today), licensed MIT. It adds 20 tokens to every session and 2,866 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to test-driven-development, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

tui-screen

Create TUI screens, components, and views for the agents-in-a-box terminal UI. Use when building new ratatui components, adding panels, creating list views, or styling any terminal interface element. Provides color palette, component patterns, and quality checklist.

stevengonsalvez/agents-in-a-box · 56 tokens

ship-it

End-to-end ship loop: atomic commits, PR, tiered review (lite|heavy), fix every finding, re-review until zero remain, then merge-commit. lite runs a single /review pass; heavy spins up a dynamic Workflow with diff-aware review personas plus a Codex cross-model peer. Use when Stevie says "/ship-it", "ship it", "ship…

stevengonsalvez/agents-in-a-box · 96 tokens

tmux-ui-tripwire

Write or debug tmux-driven end-to-end TUI tests ("tripwires") for the ainb terminal app. Use when the user asks to "write a tmux test", "add a tripwire", "verify the TUI in tmux", "test feature X by pressing key Y", "validate plugin Z renders", or when editing any file under crates/ainb-core/tests/tripwire.rs.…

stevengonsalvez/agents-in-a-box · 185 tokens

tmux-verify

The outer "is this TUI feature ACTUALLY done?" proof loop for the ainb terminal app. Use when the user asks to "verify the TUI is actually done", "prove this TUI feature works", "validate per tmux-verify", "vhs verify each journey", "frame-truth check the UI", "is the diff actually shown correctly", or to define the…

stevengonsalvez/agents-in-a-box · 231 tokens

ainb-fleet:daemons

Runtime-health view of the four fleet daemons — phone bridge, notifyd, ATC, and the fleet auto-continue daemon — in one table. Each row reports state (running / stopped / unknown), pid, uptime, last activity, error count, and a HEALTH reason that distinguishes a clean stop from a crash (stale heartbeat) or a…

stevengonsalvez/agents-in-a-box · 126 tokens

ainb-fleet

Fleet orchestration overview — the ainb fleet ... Rust subcommand namespace for driving every claude session on the host. Routes to the sub-skills (ainb-spawn / standup / broadcast / sequence / needs / daemon / atc). Invoke this for an at-a-glance map of what fleet can do; reach for the specific sub-skill for the verb…

stevengonsalvez/agents-in-a-box · 88 tokens