tdd
Skill5 starsChanged 3 months agoMITView on GitHub
测试驱动开发(TDD);当用户要求以 test-first 方式开发功能或修复缺陷、提到 red-green-refactor,或者需要 integration tests 时使用。
194 other projects use a version of this.
Adopted by
Most recently taken up by
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- trpc/trpctheir own version, first seen Nov 8, 2026
- wowyuarm/dsh-agent-teamtheir own version, first seen Nov 8, 2026
- Contexera/dsh-agent-teamtheir own version, first seen Nov 8, 2026
- Dimon94/dveritytheir own version, first seen Nov 8, 2026
- Dimon94/skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use capture-learning-tools, design-frontend-dev and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
The-Vibe-CompanySkillcapture-learning-tools
Turn technical conversations, bugs, CI failures, review comments,
Also in 5 projects that use this
The-Vibe-CompanySkilldesign-frontend-dev
Clean Impeccable frontend design skill. Use when the user wants to
Also in 5 projects that use this
tristanphvnSkillketchup-video
Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.
Also in 14 projects that use this
jaydubya818Skillfigure-it-out
Use when novel or multi-phase work needs an auditable workflow and no narrower playbook fits.
Also in 54 projects that use this
jaydubya818Skillprinciple-laziness-protocol
Apply when a refactor is adding wrappers or abstractions instead of simplifying.
Also in 45 projects that use this
- +2 more from The-Vibe-Company
- +5 more from jaydubya818
Other versions194 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 194
- mattpocock/skills★ 309ksame name
- trpc/trpc★ 41ksame name
- Yeachan-Heo/oh-my-claude-sisyphus★ 41ksame name
- Yeachan-Heo/oh-my-claudecode★ 41ksame name
- QuivrHQ/quivr★ 40ksame name
- The-Vibe-Company/quivr★ 40ksame name
- ccusage/ccusage★ 19ksame name
- ryoppippi/ccusage★ 19ksame name
- MODSetter/SurfSense★ 17ksame name
- GreyDGL/PentestGPT★ 16ksame name
184 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- documenting-codeSkill
- implementSkill
- implement-specSkill
- integrating-frontend-apisSkill
- organizing-frontend-componentsSkill
- prototypeSkill
- writing-vue-componentsSkill
- researchSkill
- teachSkill
- writing-for-agentsSkill
- codebase-designSkill
- domain-modelingSkill
- grill-with-docsSkill
- to-specSkill
- to-ticketsSkill
- code-reviewSkill
- diagnosing-bugsSkill
- improve-codebase-architectureSkill
- retroSkill
- ask-mattSkill
- execute-planSkill
- git-commitSkill
- grillingSkill
- grill-meSkill
- handoffSkill
- prSkill
- setup-matt-pocock-skillsSkill
- triageSkill
- usage-disclosureSkill
- wait-whatSkill
- wayfinderSkill
The file
Files
测试驱动开发(Test-Driven Development)
TDD 是红 → 绿循环(red → green loop)。本技能提供让该循环产出值得保留的测试所需的规范:什么是良好测试、测试应放在哪里、反模式(anti-patterns)以及循环规则。每一节都适用于每一轮循环:要在循环开始前和进行中查阅,而不是事后查阅。
探索代码库时,读取 GLOSSARY.md(如果存在),使测试名称和接口词汇符合项目的领域语言,并遵守所涉及区域的 ADR。
什么是良好测试
测试应当通过公共接口(public interfaces)验证行为,而不是验证实现细节。代码可以彻底改变,测试不应随之失效。良好测试读起来像规格:“用户可以使用有效购物车结账”明确说明了存在什么能力:并且因为不关心内部结构而能经受重构(refactors)。
示例见 tests.md,模拟指南见 mocking.md。
接缝:测试应放在哪里
**接缝(seam)**是进行测试的公共边界:在这个接口上,无需进入内部就能观察行为。测试位于接缝处,绝不针对内部实现。
**只在预先约定的接缝处测试。**编写任何测试之前,先写下要测试的接缝并让用户确认。不要在未经确认的接缝处编写测试。你无法测试一切:预先约定接缝,才能把测试精力投入关键路径和复杂逻辑,而不是每个边缘情形。
询问:“公共接口是什么,我们应当测试哪些接缝?”为每个提议的接缝附上一行说明,指出它能发现什么、会遗漏什么。
当该接口本身的形态需要设计时(模块有多深、接缝应放在哪里、接口应暴露什么),调用 Skill 工具加载“codebase-design”,查阅共享词汇。它是模块、接口、深度、接缝、适配器、杠杆效应和局部性这些术语的统一来源;它是供查阅的参考,而不是需要运行的会话。
反模式
- 与实现耦合(implementation-coupled):模拟内部协作者、测试私有方法,或者通过旁路验证(例如绕过接口直接查询数据库)。识别信号是:行为没有改变,测试却会因重构而失败。
- 同义反复(tautological):断言用与代码相同的方式重新计算期望值(
expect(add(a, b)).toBe(a + b)、以同样方式手工推导的快照、断言常量等于自身),因此它必然通过,永远不可能与代码产生分歧。期望值必须来自独立的事实来源:已知正确的字面值、完整演算的示例或规格。 - 水平切片(horizontal slicing):先写完所有测试,再写完所有实现。批量测试验证的是_想象中的_行为:测试的是事物的_形状_而非面向用户的行为;测试无法感知真实变化;而且你在理解实现之前就承诺了测试结构。应当改用垂直切片(vertical slices):一个测试 → 一个实现 → 重复;每个测试都是一枚曳光弹(tracer bullet),根据上一轮循环获得的认知作出响应。
循环规则
- **先红后绿。**先编写失败测试,再只写足以使其通过的代码。不要预判未来的测试,也不要添加推测性功能。
- **每次一个切片。**每轮循环只包含一个接缝、一个测试和一个最小实现。
- **重构不属于该循环。**它属于审查阶段(参见
code-review技能),不属于红 → 绿实现循环。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

