使用 RED-GREEN-重构(red-green-refactor)循环进行测试驱动开发。适用于用户希望用 TDD 构建新功能或修复 bug,提到 “red-green-refactor”,希望使用集成测试,或询问“test-first development(先写测试)”。

MITAuto-check passedTesting & QA

Install TDD

skills CLI
$ npx skills add ProgrammerAnthony/Anything-Extract --skill tdd -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ProgrammerAnthony/Anything-Extract tdd --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ProgrammerAnthony/Anything-Extract.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/tdd .claude/skills/tdd && rm -rf skills-src

Use ~/.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/

Facts

Skill name
tdd
GitHub stars
139
Token cost
~572 tokens
SKILL.md length
96 words
Files
6
Skills in repo
13
Repo updated
First seen
Licence
MIT

At a glance

使用 RED-GREEN-重构(red-green-refactor)循环进行测试驱动开发。适用于用户希望用 TDD 构建新功能或修复 bug,提到 “red-green-refactor”,希望使用集成测试,或询问“test-first development(先写测试)”。

  • Works in 4 steps: 规划(Planning) → tracer bullet(示踪子弹) → 逐步循环(Incremental Loop) → …
  • Tasks that involve Test-driven development
  • SKILL.md covers 哲学(Philosophy), 反模式:横向切片(Horizontal Slices), 工作流(Workflow) and 每一轮循环的清单(Checklist Per Cycle)
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

TDD is an agent skill from ProgrammerAnthony/Anything-Extract. 使用 RED-GREEN-重构(red-green-refactor)循环进行测试驱动开发。适用于用户希望用 TDD 构建新功能或修复 bug,提到 “red-green-refactor”,希望使用集成测试,或询问“test-first development(先写测试)”。

Its SKILL.md is about 570 tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files (for example `deep-modules.md`, `interface-design.md` and `mocking.md`).

It sits in Testing & QA, covering Test-driven development. The repository describes itself as: 高效文档识别&知识库&本地启动,前后端;整合QAnything、dify等思想和源码,快速批量可靠提取文档关键信息并导出. The licence is MIT.

When your agent uses it

  • Tasks that involve Test-driven development

Example prompts

  • “red-green-refactor”
  • “test-first development(先写测试)”
  • “/tdd”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. 规划(Planning)
  2. tracer bullet(示踪子弹)
  3. 逐步循环(Incremental Loop)
  4. 重构(Refactor)

What it can do on your machine

Read from SKILL.md and the folder at commit f1ed557. It shows what the files ask for, not the result of running them.

  • Tool permissions

    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.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

TDD loads about 572 tokens when it runs. Until then it costs about 36 tokens; SKILL.md has 96 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~36
When it runs · the whole SKILL.md, loaded when a task matches
~572

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.

Safety

Auto-check passed

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.

SKILL.md

The full file from ProgrammerAnthony/Anything-Extract at commit f1ed557, republished under its MIT licence (© ProgrammerAnthony). 96 words, ~572 tokens.

Download SKILL.mdSave it as .claude/skills/tdd/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
tdd
description
使用 RED-GREEN-重构(red-green-refactor)循环进行测试驱动开发。适用于用户希望用 TDD 构建新功能或修复 bug,提到 “red-green-refactor”,希望使用集成测试,或询问“test-first development(先写测试)”。

测试驱动开发(TDD)

哲学(Philosophy)

核心原则:测试应当通过公共接口验证行为,而不是依赖实现细节。代码可以被完全重写;测试不应该随之频繁改变。

好的测试具有集成式特征:它会通过公共 API 实际跑通真实代码路径。它描述系统“做什么”,而不是“怎么做”。好的测试读起来像规范——例如“用户在使用有效购物车时可以结账”,你就能明确知道系统具备这个能力。由于测试不关心内部结构,它能在重构后继续存活。

坏的测试会耦合到实现。它们 mock 内部协作者、测试私有方法,或用“绕过接口”的方式验证(例如直接查询数据库而不是使用接口)。危险信号是:当你重构但行为没有变化时,测试却失败了;如果你重命名了某个内部函数导致测试失败,但用户可观察行为却没有变,这些测试是在测实现而不是在测行为。

查看 tests.md 获取更多示例,并查看 mocking.md 了解 mock 指南。

反模式:横向切片(Horizontal Slices)

不要写“先写完所有测试,再写所有实现”。

这是一种“把 RED 当成写所有测试”的横向切片:把 RED 理解成“先写完所有测试”,把 GREEN 理解成“一次性写完所有代码”。

这会产生 烂测试(crap tests),包括:

  • 大量批量编写的测试验证的是“想象出来的行为”,而不是“真实的行为”
  • 测试会变成在测“结构形状”(数据结构、函数签名),而不是用户可见的行为
  • 测试会对真实变化变得不敏感:行为坏了反而测试仍可能通过;行为没坏时反而会失败
  • 你会在还没理解实现之前就“把车灯开出来”,过早承诺测试结构

正确做法:通过 tracer bullets 进行竖向切片(vertical slices)。一个测试 → 一个实现 → 重复。每一轮测试都会基于上一轮你从代码/理解中学到的东西来推进。由于你刚刚写完代码,所以你会非常清楚“哪些行为重要”以及“用什么方式验证它”。

WRONG(横向):
  RED:   test1, test2, test3, test4, test5
  GREEN: impl1, impl2, impl3, impl4, impl5

RIGHT(竖向):
  RED→GREEN: test1→impl1
  RED→GREEN: test2→impl2
  RED→GREEN: test3→impl3
  ...

工作流(Workflow)

1. 规划(Planning)

在写任何代码之前:

  • 与用户确认需要如何修改接口(interface changes)
  • 与用户确认需要测试哪些行为(优先级更高)
  • 识别可以提取的 深模块(deep modules)(小接口、深实现)
  • 为 可测试性(testability) 设计接口
  • 列出要测试的行为(而不是实现步骤)
  • 让用户批准该计划

提问:公共接口应当长什么样?哪些行为最重要、最需要先测?

你无法把所有东西都测完。 请与用户明确“哪些行为最关键”。把测试资源集中在关键路径与复杂逻辑上,而不是覆盖所有可能的边界情况。

2. tracer bullet(示踪子弹)

写出 一个测试,用来确认系统的 一个要点:

RED:   为第一个行为写测试 → 测试失败
GREEN: 写最小代码让测试通过 → 测试通过

这就是你的 tracer bullet——它证明这条路径能端到端跑通。

3. 逐步循环(Incremental Loop)

对剩余的每个行为:

RED:   写下一个测试 → 失败
GREEN: 最小实现让它通过 → 通过

规则:

  • 一次一个测试
  • 只写足够通过当前测试的代码
  • 不要提前为未来测试“预埋”
  • 保持测试聚焦在可观察的行为
4. 重构(Refactor)

当所有测试都通过之后,再查看 重构候选(refactoring.md):

  • 抽取重复逻辑
  • 加深模块(把复杂度移到简单接口背后)
  • 在自然的地方应用 SOLID 原则
  • 评估新代码暴露出的、对现有代码的潜在问题
  • 每完成一个重构步骤就运行测试

不要在 RED 状态下重构。 先到 GREEN 再谈重构。

每一轮循环的清单(Checklist Per Cycle)

[ ] 测试描述的是行为,而不是实现
[ ] 测试只使用公共接口
[ ] 测试在内部重构后仍能存活
[ ] 针对该测试的代码足够最小
[ ] 没有加入“为了以后而猜”的功能

© ProgrammerAnthony, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files in .agents/skills/tdd of ProgrammerAnthony/Anything-Extract.

  • SKILL.md
  • deep-modules.md
  • interface-design.md
  • mocking.md
  • refactoring.md
  • tests.md

Open the folder on GitHubat commit f1ed557

Compare with similar skills

TDD 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.

TDD compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
TDD this skillProgrammerAnthony/Anything-Extract139—~572Automated safety check: PassMIT
TDDfossasia/eventyay-interpretation1.6k28 repos~1.1kAutomated safety check: PassApache-2.0
TDD WorkflowhellangleZ/burn-in-cceverywhere-ralph11211 repos~2.4kAutomated safety check: PassNone
TDDsanity-io/sanity6.4k20 repos~1kAutomated safety check: PassMIT
Test Driven Developmentfarm-fe/farm5.6k49 repos~2.5kAutomated safety check: PassMIT
Tapd Story PipelineTencentBlueKing/bk-bcs840—~2.6kAutomated safety check: PassCustom licence

Similar skills

  • TDD

    fossasia/eventyay-interpretation

    Test-driven development. An agent skill from fossasia/eventyay-interpretation.

    1.6k GitHub starsUsed in 28 repos~1.1k tokens
    Testing & QAAuto-check passed
  • TDD Workflow

    hellangleZ/burn-in-cceverywhere-ralph

    A skill your agent uses when writing new features, fixing bugs, or refactoring code.

    112 GitHub starsUsed in 11 repos~2.4k tokens
    Testing & QAAuto-check passed
  • TDD

    sanity-io/sanity

    Official

    Test-driven development with red-green-refactor loop. An agent skill from sanity-io/sanity.

    6.4k GitHub starsUsed in 20 repos~1k tokens
    Testing & QAAuto-check passed
  • A skill your agent uses when implementing any feature or bugfix, before writing implementation code

    5.6k GitHub starsUsed in 49 repos~2.5k tokens
    Testing & QAAuto-check passed
  • Tapd Story Pipeline

    TencentBlueKing/bk-bcs

    单需求实现流水线——把一个 TAPD 需求从零推进到代码提交。自动串联技术澄清、 开发计划、任务拆分、TDD 实现、架构/安全校验、代码提交六个阶段。

    840 GitHub stars~2.6k tokensUpdated 13 days ago
    Testing & QAAuto-check passed
  • Absolute Init

    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…

    218 GitHub starsUsed in 1 repo~3k tokens
    Testing & QAAuto-check passed

More from ProgrammerAnthony/Anything-Extract

All 13 skills in this repo
  • Backend Code Review

    ProgrammerAnthony/Anything-Extract

    指导在项目(python项目)中队后端代码进行质量、安全、可维护性与最佳实践审查,基于既定规则清单。适用于用户请求对 backend/ 下后端文件(如 .py)进行审查、分析或改进。不用于前端文件(如 .tsx、.ts、.js)。支持待提交变更审查、代码片段审查、按文件审查。

    139 GitHub stars~791 tokensUpdated 4 mo ago
    Auto-check passed
  • Frontend Code Review

    ProgrammerAnthony/Anything-Extract

    指导在项目中对前端代码(Next.js/React/TypeScript/Tailwind 等)进行结构、可维护性、性能与一致性审查,基于既定规则清单。适用于用户请求审查 .tsx/.ts/.js/.jsx 等前端文件或前端目录下的页面与组件。不用于后端代码(如 .py)。

    139 GitHub stars~957 tokensUpdated 4 mo ago
    Auto-check passed
  • Design An Interface

    ProgrammerAnthony/Anything-Extract

    使用并行子 agent 为某个模块生成多个根本不同的接口设计。适用于用户希望设计某个 API、探索接口选项、对比模块形状(module shapes),或提到“design it twice(把它设计两遍)”。

    139 GitHub stars~448 tokensUpdated 4 mo ago
    Auto-check passed
  • Ubiquitous Language

    ProgrammerAnthony/Anything-Extract

    从当前对话中抽取 DDD 风格的“统一语言”术语表(ubiquitous language glossary),标记歧义,并提出规范的术语选择。保存为 UBIQUITOUSLANGUAGE.md。适用于用户希望定义领域术语、构建术语表、固化用词并强化术语一致性,或提到 “domain model” / “DDD”(领域模型与 DDD)。

    139 GitHub stars~647 tokensUpdated 4 mo ago
    Auto-check passed
  • Write A Skill

    ProgrammerAnthony/Anything-Extract

    以正确的技能结构、渐进式披露与打包资源来创建新的 agent 技能。适用于用户希望创建、编写或构建新的技能. An agent skill from ProgrammerAnthony/Anything-Extract.

    139 GitHub stars~407 tokensUpdated 4 mo ago
    Auto-check passed
  • Architecture Doc

    ProgrammerAnthony/Anything-Extract

    指导在项目中编写、更新与使用架构文档(ARCHITECTURE.md)。在根目录维护架构文档,修改前后需阅读文档;文档关注最终结果与流程串联,不陷入实现细节。适用于新增/变更功能、重构、或需要理解系统整体时。

    139 GitHub stars~606 tokensUpdated 4 mo ago
    Auto-check passed

Categories

Questions about TDD

What does TDD do?

使用 RED-GREEN-重构(red-green-refactor)循环进行测试驱动开发。适用于用户希望用 TDD 构建新功能或修复 bug,提到 “red-green-refactor”,希望使用集成测试,或询问“test-first development(先写测试)”。. TDD is an agent skill from ProgrammerAnthony/Anything-Extract.

When should I use TDD?

TDD fits situations like: tasks that involve Test-driven development.

How do I install TDD in Claude Code?

Run `npx skills add ProgrammerAnthony/Anything-Extract --skill tdd -a claude-code`. Or copy the skill folder (.agents/skills/tdd in ProgrammerAnthony/Anything-Extract) into .claude/skills/tdd in your project. Claude Code loads it when a task matches its description.

How do I install TDD in Codex?

Run `npx skills add ProgrammerAnthony/Anything-Extract --skill tdd -a codex`. Or copy the skill folder (.agents/skills/tdd in ProgrammerAnthony/Anything-Extract) into .agents/skills/tdd in your project. Codex loads it when a task matches its description.

Can I use TDD in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ProgrammerAnthony/Anything-Extract --skill tdd -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tdd, .gemini/skills/tdd, .github/skills/tdd and .opencode/skills/tdd in your project.

What does TDD need to run?

SKILL.md names no scripts, command-line tools or credentials: TDD is instructions for the agent only.

Does TDD access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is TDD safe to install?

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.

What licence does TDD use?

TDD is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does TDD use?

About 572 tokens (SKILL.md is roughly 2.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to TDD?

Skills that share tags, products or a category with TDD: TDD (fossasia/eventyay-interpretation, 1.6k 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.

Who maintains TDD?

ProgrammerAnthony (a GitHub user) maintains it in ProgrammerAnthony/Anything-Extract, which has 139 GitHub stars. The repository holds 13 skills in this directory. The repository was last updated on May 13, 2026.

Source: ProgrammerAnthony/Anything-Extract on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.