Tooluck logoTooluck
SKILL.md

tdd

Agent skill fromvinvcn/mattpocock-skills-zh-CN

测试驱动开发。适用于用户想用先写测试的方式构建功能或修复缺陷、提到 “red-green-refactor”,或需要集成测试时。

How to install tdd

install tdd
# install the mattpocock-skills-zh-CN pack with the skills CLI
npx skills add vinvcn/mattpocock-skills-zh-CN

# or add only this skill to Claude Code: copy the folder

skills/engineering/tdd/

# into

~/.claude/skills/tdd/ (all projects)

.claude/skills/tdd/ (one project)

skills/engineering/tdd/SKILL.md

MITFull file
1# 测试驱动开发
2
3TDD 是 red -> green loop。这个 skill 是让该 loop 产出值得保留的 tests 的 reference:什么是好 test、tests 应该放在哪里、anti-patterns,以及 loop 的规则。每个 cycle 前和 cycle 中都要参考这些内容,而不是事后才看。
4
5探索 codebase 时,读取 `GLOSSARY.md`(如果存在),让 test names 和 interface vocabulary 与项目 domain language 对齐,并尊重你触碰区域的 ADRs。
6
7## 什么是好 test
8
9Tests 应通过 public interfaces 验证 behavior,而不是 implementation details。代码可以完全改变;tests 不该随之改变。一个好 test 读起来像 specification:"user can checkout with valid cart" 能清楚说明存在什么能力;因为它不关心 internal structure,所以能承受 refactors。
10
11示例见 [tests.md](tests.md),mocking 规则见 [mocking.md](mocking.md)。
12
13## Seams:tests 放在哪里
14
15**Seam** 是你测试的 public boundary:可以观察 behavior、但不伸手进入内部的 interface。Tests 放在 seams 上,绝不针对 internals。
16
17**只测试预先认可的 seams。** 写任何 test 前,先写下要测试的 seams 并与用户确认。未经确认的 seam 不写 test。你无法测试所有东西;提前认可 seams,才能把测试精力放在 critical paths 和复杂 logic 上,而不是每个 edge case。
18
19询问:"What's the public interface, and which seams should we test?" 给每个提议的 seam 加一行说明:它能捕获什么,又会漏掉什么。
20
21当 interface 的形状本身就是问题所在时(module 该多深、seam 该放在哪里、interface 应该暴露什么),调用 Skill 工具并指定 `codebase-design` 获取词汇。它是 module、interface、depth、seam、adapter、leverage 和 locality 这些术语的共享来源,是供查阅的 reference,而不是要运行的 session。
22
23## 反模式
24
25- **Implementation-coupled**:mock internal collaborators、测试 private methods,或通过 side channel 验证(例如不用 interface 而直接查询 database)。特征是 refactor 时 test 失败,但 behavior 没变。
26…

Excerpt shown under the repository's MIT license.

More skills in mattpocock-skills-zh-CN

Keep exploring

Similar skill repositories

thedotmack /

claude-mem
116k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

CCCXGHGM+135 skills

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates