test-driven-development

test-driven-development is a skill for Claude Code from vinvcn/addyosmani-agent-skills-zh. It costs 48 tokens per session (3,690 once invoked), scanned A, original, MIT.

Instructions for test-driven development, or TDD: writing a failing test first, then the smallest code that makes it pass, followed by cleanup.

In plain words
What is it for?
They are for implementing logic, fixing bugs, changing behavior, and handling edge cases with a repeatable test-first process.
Why use it?
They provide evidence that new behavior and bug fixes work instead of relying on code that only appears correct. The tests also help protect existing behavior during changes.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions subagents.

Part of the agent-skills plugin — 23 skills, 8 commands, 3 agents, 1 hook shipped together

Good fit They are for implementing logic, fixing bugs, changing behavior, and handling edge cases with a repeatable test-first process.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vinvcn/addyosmani-agent-skills-zh/test-driven-development
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/addyosmani-agent-skills-zh --skill test-driven-development
Clone the repo
git clone --depth 1 https://github.com/vinvcn/addyosmani-agent-skills-zh

Made for: Claude Code.

Or install agent-skills, the plugin that ships this one along with the rest of its 23 skills, 8 commands, 3 agents, 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/vinvcn/addyosmani-agent-skills-zh/test-driven-development/github.svg)](https://agentmods.dev/skills/vinvcn/addyosmani-agent-skills-zh/test-driven-development)
Your own site
<a href="https://agentmods.dev/skills/vinvcn/addyosmani-agent-skills-zh/test-driven-development"><img src="https://agentmods.dev/badge/skills/vinvcn/addyosmani-agent-skills-zh/test-driven-development/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 test-driven-development

Your own site · 80×15
<a href="https://agentmods.dev/skills/vinvcn/addyosmani-agent-skills-zh/test-driven-development"><img src="https://agentmods.dev/badge/skills/vinvcn/addyosmani-agent-skills-zh/test-driven-development.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,690 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.
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.00048 $0.03690
Opus 5 $0.00024 $0.01845
Sonnet 5 $0.00010 $0.00738
Haiku 4.5 $0.00005 $0.00369

Measured 10d ago against content hash 87051034b58d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, 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 10d 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/test-driven-development/SKILL.md · 384 lines

How it starts

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

Test-Driven Development

概览

先写一个失败测试,再写让它通过的代码。修 bug 时,在尝试修复前先用测试复现 bug。测试是证据,“看起来对”不算完成。拥有良好测试的代码库是 AI agent 的超能力;没有测试的代码库则是一种负债。

何时使用

  • 实现任何新逻辑或行为
  • 修复任何 bug(Prove-It Pattern)
  • 修改现有功能
  • 添加边界情况处理
  • 任何可能破坏现有行为的变更

何时不要使用: 纯配置变更、文档更新,或没有行为影响的静态内容变更。

相关: 对基于浏览器的变更,将 TDD 与使用 Chrome DevTools MCP 的运行时验证结合使用。见下方 Browser Testing 部分。

TDD 循环

    RED                GREEN              REFACTOR
 Write a test    Write minimal code    Clean up the
 that fails  ──→  to make it pass  ──→  implementation  ──→  (repeat)
      │                  │                    │
      ▼                  ▼                    ▼
   Test FAILS        Test PASSES         Tests still PASS

步骤 1:RED,编写失败测试

先写测试。它必须失败。一个立即通过的测试什么都证明不了。

// RED: This test fails because createTask doesn't exist yet
describe('TaskService', () => {
  it('creates a task with title and default status', async () => {
    const task = await taskService.createTask({ title: 'Buy groceries' });

    expect(task.id).toBeDefined();
    expect(task.title).toBe('Buy groceries');
    expect(task.status).toBe('pending');
    expect(task.createdAt).toBeInstanceOf(Date);
  });
});

步骤 2:GREEN,让它通过

编写最少代码让测试通过。不要过度工程化:

// GREEN: Minimal implementation
export async function createTask(input: { title: string }): Promise<Task> {
  const task = {
    id: generateId(),
    title: input.title,
    status: 'pending' as const,
    createdAt: new Date(),
  };
  await db.tasks.insert(task);
  return task;
}

步骤 3:REFACTOR,清理

测试保持绿色后,在不改变行为的前提下改进代码:

  • 抽取共享逻辑
  • 改进命名
  • 移除重复
  • 必要时优化

每个重构步骤后都运行测试,确认没有破坏任何东西。

Prove-It Pattern(Bug 修复)

收到 bug 报告时,不要从尝试修复开始。 先写一个能复现它的测试。

Bug report arrives
       │
       ▼
  Write a test that demonstrates the bug
       │
       ▼
  Test FAILS (confirming the bug exists)
       │
       ▼
  Implement the fix
       │
       ▼
  Test PASSES (proving the fix works)
       │
       ▼
  Run full test suite (no regressions)

Read the full file on GitHub · 384 lines

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. 10d ago First seen · 384 lines · 48 tokens per session scan A 87051034b58d

Subscribe to this mod's changes

test-driven-development is a skill published in the GitHub repository vinvcn/addyosmani-agent-skills-zh (30 stars, last pushed 4mo ago), licensed MIT. It adds 48 tokens to every session and 3,690 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.

Related

Other skills, from other repositories

test-driven-development

Drives development with tests via Red-Green-Refactor and the Prove-It pattern, with hard rules against weakening assertions or faking green suites. Use when implementing any logic, fixing any bug, or changing any behavior. Triggers on "add a feature", "fix this bug", "write tests", or any task where done must be…

borhen68/SkillEngine · 79 tokens

spec-driven-development

Creates specs before coding, with hard rules against silently filled assumptions and untestable success criteria. Use when starting a new project, feature, or significant change and no specification exists yet. Triggers on "build me", "create a", "add a feature", or any requirement vague enough to need interpretation.

borhen68/SkillEngine · 66 tokens

test-driven-development

Drives development with tests using the red-green-refactor loop. Use when implementing any logic, fixing any bug, or changing any behavior. Use when you need to prove that code works, when a bug report arrives, or when you're about to modify existing functionality.

addyosmani/agent-skills · 57 tokens

chaos-engineering

Guides systematic fault injection and resilience testing. Use when designing for high availability, verifying disaster recovery, testing failure modes, or building fault-tolerant systems. Use when you need to prove your system survives infrastructure failures, network partitions, dependency outages, or cascading…

borhen68/SkillEngine · 59 tokens

test-driven-development

Red-green-refactor cycle with meaningful coverage. Tests are written before implementation. Coverage is a side effect of good tests, not the goal.

DevelopersGlobal/ai-agent-skills · 32 tokens

browser-testing-with-devtools

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be…

borhen68/SkillEngine · 68 tokens