tdd

tdd is a command for Claude Code from an8079/take-skills. It costs 21 tokens per session (626 once invoked), scanned A, original, MIT.

A test-driven development workflow, where tests are written first, the smallest passing implementation is added, and the code is then improved.

In plain words
What is it for?
Use it when developing or changing code with a test suite, especially when you want requirements expressed as executable tests.
Why use it?
It helps reveal missing behavior early and keeps refactoring tied to tests that must continue passing.

Command for Claude Code

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

Part of the claude-dev-assistant plugin — 21 skills, 39 commands shipped together

Good fit Use it when developing or changing code with a test suite, especially…

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/an8079/take-skills/tdd
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.

Clone the repo
git clone --depth 1 https://github.com/an8079/take-skills

Made for: Claude Code.

Or install claude-dev-assistant, the plugin that ships this one along with the rest of its 21 skills, 39 commands.

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/an8079/take-skills/tdd.svg)](https://agentmods.dev/commands/an8079/take-skills/tdd)
Your own site
<a href="https://agentmods.dev/commands/an8079/take-skills/tdd"><img src="https://agentmods.dev/badge/commands/an8079/take-skills/tdd.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 626 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.00021 $0.00626
Opus 5 $0.00010 $0.00313
Sonnet 5 $0.00004 $0.00125
Haiku 4.5 $0.00002 $0.00063

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

commands/tdd.md · 116 lines

What it actually says

/tdd - TDD 工作流

进入测试驱动开发模式。

使用方式

/tdd

TDD 流程

RED → GREEN → IMPROVE
  ↓       ↓        ↓
写测试   实现最小   重构优化
 代码    代码让    改善设计
         测试通过

三个步骤

1. RED - 编写失败的测试

describe('UserService', () => {
  it('should create user with valid data', async () => {
    const userData = { email: '[email protected]', password: 'pass123' };
    const result = await userService.createUser(userData);

    expect(result).toHaveProperty('id');
    expect(result.email).toBe('[email protected]');
  });
});

运行测试,确保失败:

npm test

2. GREEN - 实现最小代码

编写最少的代码让测试通过:

class UserService {
  async createUser(userData: UserData): Promise<User> {
    return {
      id: '1',
      email: userData.email,
      createdAt: new Date(),
    };
  }
}

运行测试,确保通过:

npm test

3. IMPROVE - 重构优化

在保持测试通过的前提下改善代码:

class UserService {
  constructor(private userRepository: UserRepository) {}

  async createUser(userData: UserData): Promise<User> {
    this.validateEmail(userData.email);
    const user = await this.userRepository.create(userData);
    return user;
  }

  private validateEmail(email: string): void {
    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    if (!emailRegex.test(email)) {
      throw new Error('Invalid email');
    }
  }
}

运行测试,确保仍然通过:

npm test

TDD 优点

优点 说明
清晰的设计需求 测试就是需求文档
降低 bug 风险 测试驱动确保代码正确
更容易重构 有测试保护,重构更安全
更好的代码结构 为了可测试性,代码更模块化

覆盖率目标

类型 目标覆盖率
语句覆盖 85%
分支覆盖 80%
函数覆盖 90%

提示: TDD 不是教条,而是工具。在合适的时候使用,能显著提高代码质量。

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 · 116 lines · 21 tokens per session scan A 99e6482b2eb8

Subscribe to this mod's changes

tdd is a command published in the GitHub repository an8079/take-skills (4 stars, last pushed 5mo ago), licensed MIT. It adds 21 tokens to every session and 626 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.