test-first
Skill0 starsChanged 34 days agoMITView on GitHub
红-绿循环的参考:什么叫好测试、测试写在哪个接缝、三个反模式与循环规则。Triggers: test-first, TDD, 红绿, red-green, 写测试, 先写测试, 单元测试.
24 other projects use a version of this.
Adopted by
Most recently taken up by
- TheLunchTrae/claude-code-configstheir own version, first seen Nov 8, 2026
- sergvss/agents-best-teamstheir own version, first seen Nov 1, 2026
- JordanCoin/codemaptheir own version, first seen Nov 1, 2026
- claude-world/director-mode-litetheir own version, first seen Nov 1, 2026
- NoobyGains/godmodetheir own version, first seen Nov 1, 2026
- bmtrnavsky/disciplined-vibe-codingtheir own version, first seen Nov 1, 2026
Used with
Projects with it also use security-sweep, api-design and 1 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.
n24q02mSkillsecurity-sweep
Graph-driven security sweep -- scan for dangerous sinks, then rank each finding by whether an entry point can actually reach it, and triage the rest into suppressions.
Also in 3 projects that use this
MicrosoftSkillapi-design
Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.
Also in 3 projects that use this
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 4 projects that use this
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- JordanCoin/codemap★ 710same name
- llopresto87/Cypress★ 119same name
- NoobyGains/godmode★ 118same name
- claude-world/director-mode-lite★ 80same name
- s-hiraoku/synapse-a2a★ 17same name
- bmtrnavsky/disciplined-vibe-coding★ 15same name
- dfedoryshchev/weftworks★ 5same name
- eeshsaxena/agent-skills★ 2same name
- sergvss/agents-best-teams★ 2same name
- atgreen/hackinator★ 1same name
14 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 repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- evals/AGENTS.mdAGENTS.md
- conflictSkill
- diagnoseSkill
- harness-engineeringSkill
- modern-goSkill
- open-source-skillSkill
- refactorSkill
- triageSkill
- understandSkill
- graphSkill
- loop-itSkill
- merge-itSkill
- prdSkill
- review-itSkill
- ship-itSkill
- to-designSkill
- to-issuesSkill
- find-skillsSkill
- frontend-designSkill
- humanizer-zhSkill
- pptxSkill
- resume-optimizerSkill
- skill-creatorSkill
- svg-diagramSkill
- teachSkill
- ui-ux-pro-maxSkill
- web-design-guidelinesSkill
The file
Files
test-first — 红 → 绿
TDD 就是 red → green 这个循环。这个技能是让循环产出值得留下的测试的参考:什么算好测试、测试写在哪、反模式、循环规则。每一轮都适用——边写边看,不是事后补看。
什么是好测试
测试通过公开接口验证行为,不碰实现细节。代码可以整个重写,测试不该跟着改。好测试读起来像规格说明:"用户可以带有效购物车结账"直接告诉你存在什么能力,而且它熬得过重构,因为不关心内部结构。
接缝:测试写在哪里
接缝是你观察行为的公开边界。测试只写在接缝上,绝不写到内部。
只测事先约定好的接缝。写任何测试之前,先把"要测哪些接缝"写下来并与用户确认。测不了所有东西;先约定接缝,测试精力才会落在关键路径和复杂逻辑上,而不是每个边界情况。先问:公开接口是什么?我们该测哪几个接缝?
接口本身的形状还在摇摆时(模块该多深、接缝该在哪、暴露什么),先把它定下来再写测试——用 /to-design 把它写清楚。测试是给已经定下的契约上锁的;契约还在动的时候写测试,锁住的是你自己的草稿。
三个反模式
- 与实现耦合:mock 内部协作者、测私有方法、或从侧信道验证(绕开接口直接查数据库)。特征:重构时测试红了,但行为没变——这种测试把重构成本翻倍。
- 同义反复:断言用与实现相同的方式重算期望值(
expect(add(a,b)).toBe(a+b)、按同样逻辑手推的 snapshot、常量断言等于自身),于是它按构造就通过,永远不可能与代码意见相左。期望值必须来自独立的事实来源:已知good字面量、手算样例、规格。 - 横向切片:先把所有测试写完再写实现。批量测试验证的是想象出来的行为——你测的是形状,不是面向用户的行为。改成垂直切片:一个测试 → 一段实现 → 再来一个;每个测试都是一颗曳光弹,回应上一轮学到的东西。
循环规则
- 红先于绿:先写失败测试,再写刚好让它通过的最少代码。不预判后面的测试,不加投机功能。
- 一次一片:一轮 = 一个接缝 + 一个测试 + 一个最小实现。
- 重构不属于这个循环:它属于评审阶段(
/review-it)。混进来会让红绿循环失去"信号干净"这个唯一优势——你分不清红是被测行为坏了还是重构碰坏了。
在 DSH 里跑测试
每次 bash 调用都是新 shell,cd 不跨调用保留——用 workdir=<目录> 或 cd <目录> && …。长测试放后台任务。在 /graph 的节点里,路径必须是该节点 worktree 的绝对路径,否则你跑的是编排者的检出,测试结果与你的改动无关。收尾时按项目自己的门禁跑一次全量(mise run check、go test ./...、pnpm --dir web test …)。
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.

