TDD
按需先红后绿:按改动类型决定要不要先写失败检查、放在哪层,期望值来自独立预期,并用真跑的探针证明检查能拒绝错误实现。用于实现功能或修复缺陷时测试先行,或用户提到 TDD、红绿、先写测试。
Install
npx skills add Dimon94/skills --skill tddgit clone --depth 1 https://github.com/Dimon94/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/skills/tdd ~/.claude/skills/tddPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# TDD TDD 是 red → green 循环。本 Skill 决定每条验收要不要循环、在哪层循环,以及怎样证明留下的检查有价值。 开工前读目标项目的测试规范:首选根 `AGENTS.md` 中以 `测试规范:` 开头的索引行,其次是 `docs/agents/quality-standards.md`、`TESTING.md`、`CONTRIBUTING.md`。项目规范与本 Skill 冲突时,项目规范优先。测试名和断言用词沿用项目的 `GLOSSARY.md` 或 `CONTEXT.md`。 ## 1. 分流 按改动类型选择路径: | 改动 | 路径 | | --- | --- | | 没有可观察的行为变化:改名、零调用删除、文档、格式 | 不新写测试。跑现有最近测试与静态检查,作为基线和结果 | | 缺陷 | 用同一输入先复现,复现就是 red | | 行为已定的功能 | 每条验收走一次第 3–5 步 | | 行为未定 | 先确认合同,再写检查。对未定行为写的测试会钉住错误行为 | | 并发、重试、幂等、状态机、资金或去重承诺 | 照常走红绿,另按第 2 步判断要不要形式验证 | 不写测试的改动,在提交说明写一行理由和已跑的检查。 完成条件:每条验收都有路径;不写测试的理由可读。 ## 2. 独立预期与选层 **独立预期**是期望值的来历:不看实现也能写出的值。每条验收要有三项:输入或动作、期望结果、来源。 - 合格来源:用户确认的例子、spec 原文、外部标准或真实系统响应、历史缺陷的复现输入、手算结果;纯重构可用旧版本行为。 - 不合格来源:跑当前实现得到的值、从实现复制的常量或映射、同一模型的第二次判断。 验收缺独立预期时,从 spec 或计划补齐;指不出来源就停下来问,不写这条检查。`implement` 列出的失败方式同样是验收,同样走这一步。 层按缺陷藏在哪里选,依次问三个问题: 1. 缺陷在单个 owner 内部,还是跨 owner 的接线?前者往下放,后者往上放。 2. 这一层能真实触发并观察到结果吗?不能就换层。 3. 组合有多少?组合多的下沉到最快的公开 seam 穷举,上层只留一条代表路径。 | 情况 | 层 | | --- | --- | | 组件合同、持久化、权限、IPC、真实宿主 | E2E 或合同检查,并读回结果 | | 规则、金额、分支组合 | 最快的公开 seam 穷举,加 1 条 E2E 验接线 | | 没有 seam 的遗留代码 | 先用 E2E 兜底,再重构 | | 并发、重试、幂等的时序交错 | 项目已有的 `formal-verify-<area>`,加 1 条 E2E | | 形状错误 | 类型检查 | | 性能、使用性 | 基准或人工评估,不走红绿 | seam 优先用 spec 指定的;没有指定时选最高的现有公开入口,并在交付说明里写明选了哪个。测试穿过公开入口,不为测试扩大公开 API。替身只放在外部系统边界:第三方服务、时间、随机。 完成条件:每条要写的检查都有独立预期和层。 ## 3. Red 一次只写一条检查,按 vertical slice 推进:一条检查、一份最小实现,再下一条。先写全部测试再写实现,会钉住想象中的行为。 运行新检查,确认它失败,且失败原因正是目标行为缺失。环境、拼写或导入错误造成的失败先修好再判定。断言公开结果、错误、读回的状态或外部副作用;“不该发生”的合同同时断言副作用没有发生,例如报错后没有保存。
Details
- Skill name
tdd- Repository
- Dimon94/skills
- Path
skills/tdd/SKILL.md- Repo updated
- 18 November 2026
FAQ
What does the TDD skill do?
按需先红后绿:按改动类型决定要不要先写失败检查、放在哪层,期望值来自独立预期,并用真跑的探针证明检查能拒绝错误实现。用于实现功能或修复缺陷时测试先行,或用户提到 TDD、红绿、先写测试。
How do I install the TDD skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add Dimon94/skills --skill tdd. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is TDD popular?
It lives in Dimon94/skills, which has 107 GitHub stars and 21 forks.
Related skills
Maintain Verification Skill
107Dimon94/skills
Periodic pass that keeps a project's verification skill and feature map honest: parallel source readers per feature, one live session driving every feature, at most one PR of proven corrections. Use for /maintain-verification-skill or "audit the verify skill".
Create Verification Skill
107Dimon94/skills
Generate a project-local verification skill that drives your app the way a user does — any language, framework, or platform. Use for /create-verification-skill, "make a control skill for this repo", or when a project has no scripted way to prove UI/CLI/service behavior.
How
107Dimon94/skills
Use for "how does X work", code walkthroughs before changing something, and placement / ownership / layering questions ("where should this live", "which package owns this", "is this the right layer"). Explains subsystem architecture, runtime flow, onboarding mental models. Use why for motivation.
Test Discipline
107Dimon94/skills
用户要求建立或补齐项目测试规范,或明确点名 test-discipline 自检时使用。常规写测试由 hook 提醒。
Principle Test Behavior Not Implementation
107Dimon94/skills
Apply when you write, change, or keep a test. Assert what the code's users can observe, so that the test fails when that behavior breaks and keeps passing when only the internals change.
Test Review
107Dimon94/skills
专项审查分支、PR/MR 或 WIP 中测试的正确性与必要性。按二八原则聚焦高价值覆盖,结合目标项目规范、BDD 业务结果、独立预期与消融测试识别假绿、脆弱测试及有效覆盖,分别审查 Standards 与 Spec,核实 fixture、mock 和 CI 接线。
Browse the most popular Claude skills, all testing & qa skills, or write your own with the skills generator.