agentleFS
eyeixeyeix/skills/tdd/SKILL.md

tdd

Skill1 starsChanged 30 days agoMITView on GitHub

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor" or 测试先行, or wants integration tests.

194 other projects use a version of this.

Adopted by

Most recently taken up by

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-CompanySkill

    capture-learning-tools

    Turn technical conversations, bugs, CI failures, review comments,

    Also in 5 projects that use this

  • The-Vibe-CompanySkill

    design-frontend-dev

    Clean Impeccable frontend design skill. Use when the user wants to

    Also in 5 projects that use this

  • tristanphvnSkill

    ketchup-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

  • jaydubya818Skill

    figure-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

  • jaydubya818Skill

    principle-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

The file

Files
SKILL.md

测试驱动开发(TDD)

TDD 是红 → 绿循环。本 skill 是让这个循环产出值得保留的测试的参考:什么是好测试、测试放哪、反模式、循环规则。每一节在每个循环都适用:循环前与循环中查阅,不是循环后。

探索代码库时读 .agentdocs/glossary.md(若存在),让测试名与接口词汇对齐项目领域语言,并尊重所涉区域的决策记录(adr/)。

什么是好测试

测试通过公开接口验证行为,不验证实现细节。代码可以整个换掉,测试不应该动。好测试读起来像规格:"用户可用有效购物车结账"准确告诉你存在什么能力,且它在重构中存活,因为它不关心内部结构。

示例见 tests.md,mock 指南见 mocking.md。

接缝(seam):测试放在哪

接缝是你测试所在的公开边界:在不深入内部的情况下观察行为的接口。测试活在接缝上,永远不对内部。

只在预先约定的接缝测试。 写任何测试前,写下要测的接缝并与用户确认。未确认的接缝上不写测试。不可能测所有东西,预先约定接缝正是让测试投入命中关键路径与复杂逻辑,而不是每个边角。

问:"公开接口是什么?该测哪些接缝?"

接缝的形状本身存疑时(模块多深、接缝放哪、接口该暴露什么),调 Skill 工具执行 codebase-design 获取词汇:module、interface、depth、seam、adapter、leverage、locality,它是供查阅的参考,不是一个会话。

任务经 /task-spec 定稿时,接缝已在其"测试决策"章节约定——直接沿用,除非发现约定有误,此时回到用户重新确认。

反模式

  • 实现耦合:mock 内部协作者、测私有方法、走旁路验证(绕过接口查数据库)。特征:重构后行为没变,测试却红;
  • 同义反复:断言用代码自己的方式重算期望值(expect(add(a, b)).toBe(a + b)、手工按同样方式得到的快照、常量断言常量自身),构造上必然通过,永远无法与代码分歧。期望值必须来自独立的事实源:已知的字面量、手算的例子、规格;
  • 横向切片:先写全部测试,再写全部实现。成批测试验证的是想象中的行为:测的是事物的形状而非用户可见行为,测试对真实变化失去敏感,并在理解实现之前就锁死了测试结构。用纵向切片代替:一个测试 → 一段实现 → 重复,每个测试都是一片 tracer bullet,响应上一循环学到的东西。

循环规则

  • 先红后绿。先写失败的测试,再写恰好让它通过的代码。不预判未来的测试,不加投机的功能;
  • 一次一片。每循环一个接缝、一个测试、一段最小实现;
  • 重构不属于这个循环。它属于审查阶段(code-review),不属于红 → 绿的实现循环。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

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.