test-driven-development

test-driven-development is a skill for Claude Code, Codex from Azzygoatcoder/agent-useful-skills. It costs 17 tokens per session (865 once invoked), scanned A, original, MIT.

A development method called test-driven development, or TDD, where you write a test that fails, add the smallest code that makes it pass, and then improve the code.

In plain words
What is it for?
Use it when building production features, shared code, bug fixes, or other code that will remain in use.
Why use it?
It checks the intended behavior before implementation is complete and helps prevent regressions, which are old problems returning after a change.

Skill for Claude CodeCodex

Part of the superpowers plugin — 9 skills, 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/azzygoatcoder/agent-useful-skills/test-driven-development
Any agent
npx skills add Azzygoatcoder/agent-useful-skills --skill test-driven-development
Clone the repo
git clone --depth 1 https://github.com/Azzygoatcoder/agent-useful-skills

Made for: Claude Code, Codex.

Or install superpowers, the plugin that ships this one along with the rest of its 9 skills, 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/azzygoatcoder/agent-useful-skills/test-driven-development.svg)](https://agentmods.dev/skills/azzygoatcoder/agent-useful-skills/test-driven-development)
Your own site
<a href="https://agentmods.dev/skills/azzygoatcoder/agent-useful-skills/test-driven-development"><img src="https://agentmods.dev/badge/skills/azzygoatcoder/agent-useful-skills/test-driven-development.svg" alt="Measured on agentmods" height="20"></a>
Per session 17 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 865 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 $0.00017 $0.00865
Opus 5 $0.00009 $0.00432
Sonnet 5 $0.00003 $0.00173
Haiku 4.5 $0.00002 $0.00086

Measured 5d ago against content hash e31b8c861f16, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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.

plugins/superpowers/skills/test-driven-development/SKILL.md · 90 lines

How it starts

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

Test-Driven Development (TDD)

Overview

Write the test first. Watch it fail. Write minimal code to pass.

Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.

Violating the letter of the rules is violating the spirit of the rules.

场景判定(先定力度,再走流程)

不是所有代码都值得完整 TDD 仪式。先确认这块代码将来会不会被依赖/复用,再选择力度:

场景 力度
生产代码、共享库、正式项目、bug 修复、回归防护 完整 TDD:红 → 绿 → 重构,缺一不可
个人业余项目、探索性脚本、原型、一次性工具 轻量 TDD:先让它跑起来;只对“会长期存在”的核心逻辑补 1-2 个有意义的测试;不要为每个小函数都建测试
纯 throwaway / 临时验证 可以跳过测试,但不要把它混进生产代码

判断标准:这段代码如果出错,会不会影响别人/后续/生产? 不会,就走轻量路径,别让流程拖慢节奏。会,就走完整 TDD,不讨价还价。

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

写生产代码前没有失败测试?删掉重来。

No exceptions:

  • Don't keep it as "reference"
  • Don't "adapt" it while writing tests
  • Don't look at it
  • Delete means delete

适用边界: 这条铁律针对会成为生产/持久代码的部分。个人探索代码可以快速跑通再补测试,但不能把“没验证过的代码”直接当生产代码提交。

Red-Green-Refactor(速览)

digraph tdd_cycle {
    rankdir=LR;
    red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
    verify_red [label="Verify fails\ncorrectly", shape=diamond];
    green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
    verify_green [label="Verify passes\nAll green", shape=diamond];
    refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
    next [label="Next", shape=ellipse];

    red -> verify_red;
    verify_red -> green [label="yes"];
    verify_red -> red [label="wrong\nfailure"];
    green -> verify_green;
    verify_green -> refactor [label="yes"];
    verify_green -> green [label="no"];
    refactor -> verify_green [label="stay\ngreen"];
    verify_green -> next;
    next -> red;
}

完整流程、好测试标准、反模式和示例见 references/tdd-guide.md

核心检查

  • 每个新行为有一个失败测试,并且你亲眼看过它失败
  • 写最小代码让它通过
  • 重构时保持测试全绿
  • 测试关注真实行为,不测 mock
  • 完整 checklist / good tests / rationalization 表见 references/tdd-guide.md

Read the full file on GitHub · 90 lines

Files

What ships with it

2 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. 5d ago First seen · 90 lines · 17 tokens per session scan A e31b8c861f16

Subscribe to this mod's changes

test-driven-development is a skill published in the GitHub repository Azzygoatcoder/agent-useful-skills (4 stars, last pushed 6d ago), licensed MIT. It adds 17 tokens to every session and 865 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-31.