agentsclimarketplace

Tdd

Skill toRolex/rolex-skills/skills/engineering/tdd

测试驱动开发。当用户希望测试先行地构建功能或修复 bug、提到 "red-green-refactor"、或需要集成测试时使用。From its SKILL.md

Install
npx -y skills add toRolex/rolex-skills --skill tdd

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 27 days oldThe repository was created 27 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.3 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

TDD(测试驱动开发)

术语约定: 以下关键术语保持固定译法,含英文源词以便对照:

English中文
seamseam
specspec
mockmock
tracer bullettracer bullet
vertical slices垂直切片
anti-patterns反模式
red / green红 / 绿

TDD 是 红 → 绿 的循环。本 skill 是让这个循环产出有价值测试的参考指南:什么是好测试、测试放在哪里、反模式有哪些、以及循环的规则。每个部分在每个循环中都适用——在循环开始前和循环期间查阅,而不是之后。

浏览代码库时,请阅读 CONTEXT.md(如果存在),确保测试名称和接口词汇与项目的领域语言一致,并尊重你正在接触区域的 ADR。

什么是好测试

测试通过公共接口验证行为,而不是实现细节。代码可以完全重写,但测试不应该变。好测试读起来像一份规约——"用户可以用有效的购物车结账"精确告诉你存在什么能力——并且能经受重构,因为它不关心内部结构。

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

Seams — where tests go

A seam 是你进行测试的公共边界:在不窥探内部的情况下观察行为的接口。测试存在于 seam 上,绝不针对内部实现。

只在预先约定的 seam 上测试。 在编写任何测试之前,写下要测试的 seams 并让用户确认。未经确认的 seam 上不写测试。你不可能测试所有东西——预先约定 seams 是让测试精力落在关键路径和复杂逻辑上,而不是每个边缘情况。

问:"公共接口是什么?我们应该测试哪些 seams?"

Anti-patterns

  • 耦合实现 —— mock 内部协作者、测试私有方法、或通过旁路验证(查询数据库而不是使用接口)。典型特征:重构时测试失败,但行为并没有变化。
  • 同义反复 —— 断言用代码相同的方式重新计算预期值(expect(add(a, b)).toBe(a + b)、用手工相同方式推导的快照、断言等于自身的常量),所以它必然通过,永远不可能与代码不一致。预期值必须来自独立的真相来源——一个已知正确的字面量、一个手工推算的示例、或 spec。
  • 水平切片 —— 先写完所有测试,再写所有实现。批量测试验证的是_想象出来的_行为:你测试的是代码的_形状_而不是面向用户的行为,测试对真正的变化不敏感,而且你在理解实现之前就承诺了测试结构。应当采用垂直切片——一个测试 → 一段实现 → 重复,每个测试都是一颗tracer bullet,回应上一个周期教给你的东西。

Rules of the loop

  • 先红后绿。 先写失败的测试,然后只写足够让它通过的代码。不要预期未来的测试或添加推测性的功能。
  • 一次一个切片。 每个周期一个 seam、一个测试、一个最小实现。
  • 重构不属于循环。 重构属于 review 阶段(见 code-review skill),不属于红→绿的实现周期。

What ships with it: 2 files

3.6 KB alongside SKILL.md

Gives 2 of the 12 instructions most tdd skills give in ~1.1k tokens

Counted across 439 of the 443 authors here whose files we hold, read 2026-08-07

  • Write minimal code to pass the testhere, and in 304 of 439, across 222 files
  • Write a failing test firsthere, and in 174 of 439, across 111 files
  • Refactor code only after tests passin 172 of 439, across 102 files
  • Watch the test fail before writing codein 145 of 439, across 97 files
  • Test one behavior per testin 108 of 439, across 46 files
  • Refactor code while keeping tests greenin 100 of 439, across 88 files
  • Delete code written before testsin 99 of 439, across 55 files
  • Run tests after each refactor stepin 88 of 439, across 57 files
  • Confirm the test fails for the right reasonin 66 of 439, across 62 files
  • Use real code instead of mocks unless unavoidablein 60 of 439, across 17 files
  • Reproduce bugs with a test before fixingin 53 of 439, across 36 files
  • Write tests before implementationin 51 of 439, across 43 files

Said here and by no other author read

  • Align test names with domain language

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 326,758. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.