tdd
Test-Driven Development
Philosophy
核心原则:测试应该通过 public interfaces 验证行为,而不是验证 implementation details。代码可以完全改变;测试不该因此改变。
好测试偏 integration-style:它们通过 public APIs 执行真实 code paths。它们描述系统做_什么_,而不是_怎么做_。好测试读起来像 spec,比如 “user can checkout with valid cart” 清楚说明已有能力。这些测试能经受 refactor,因为它们不关心内部结构。
坏测试和 implementation 绑定。它们 mock 内部 collaborators、测试 private methods,或通过外部手段验证(例如直接查询 database,而不是使用 interface)。警示信号是:你 refactor 了,行为没变,但测试坏了。如果重命名内部函数导致测试失败,那些测试测的是 implementation,不是 behavior。
示例见 tests.md,mocking 指南见 mocking.md。
Anti-Pattern: Horizontal Slices
不要先写所有测试,再写所有实现。 这是 “horizontal slicing”,把 RED 当成“写所有测试”,把 GREEN 当成“写所有代码”。
这会产生糟糕测试:
- 批量写出的测试验证的是_想象中_的行为,不是_实际_行为
More from vinvcn/mattpocock-skills-zh-cn
grill-me
围绕 plan 或 design 持续 interview user,直到达成 shared understanding,并逐一解决 decision tree 的每个分支。Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
121grill-with-docs
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
117diagnose
面向棘手 bug 和性能回退的纪律化 diagnosis loop。Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
114setup-matt-pocock-skills
Sets up an `## Agent skills` block in AGENTS.md/CLAUDE.md and `docs/agents/` so the engineering skills know this repo's issue tracker (GitHub or local markdown), triage label vocabulary, and domain doc layout. Run before first use of `to-issues`, `to-prd`, `triage`, `diagnose`, `tdd`, `improve-codebase-architecture`, or `zoom-out` — or if those skills appear to be missing context about the issue tracker, triage labels, or domain docs.
113caveman
>
112zoom-out
让 agent zoom out,并给出更广的 context 或更高层 perspective。Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.
111