test-driven-development
Use when implementing logic, fixing a bug, or changing behavior — write the failing test first (RED), then minimal code (GREEN), then refactor. Triggers on "write the failing test first", "Prove-It", or a bug that needs a reproduction test before the fix.
- License 许可
- MIT
- 最近更新
- 2026-10-28
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- test-driven-development
- type
- discipline
- bucket
- engineering
- description
- Use when implementing logic, fixing a bug, or changing behavior — write the failing test first (RED), then minimal code (GREEN), then refactor. Triggers on "write the failing test first", "Prove-It", or a bug that needs a reproduction test before the fix.
02 资源文件 7
- 参考文档references/browser-testing.md1.6 KB
- 参考文档references/prove-it-example.md1.3 KB
- 参考文档references/rationalizations.md2.9 KB
- 参考文档references/tdd-cycle-examples.md1.4 KB
- 参考文档references/test-shape.md2.2 KB
- 参考文档references/testing-patterns.md2.9 KB
- 参考文档references/testing-standards.md686 B
03 SKILL.md 正文
Test-Driven Development
Write-time discipline: a failing test before the code that makes it pass. "Seems right" is not done.
When to use
- New logic or behavior
- Bug fix (Prove-It: reproduction test before the fix)
- Behavior change that could regress
Skip: pure config/docs/formatting; throwaway spikes (return when code graduates).
Browser + runtime checks: references/browser-testing.md.
Cycle
RED (failing test) → GREEN (minimal code) → REFACTOR (tests stay green)
Bug path (Prove-It): reproduction test FAILS → fix → PASSES → full suite.
Examples: references/tdd-cycle-examples.md, references/prove-it-example.md.
Pyramid / writing style / anti-patterns: references/test-shape.md.
Procedure
- Name the behavior. One sentence: "After X, the system does Y." Completion: that sentence exists.
- RED — derive the expected result from the spec or a known example, not the implementation; write and run one failing test for one behavior. Completion: failure output captured.
- GREEN — make the minimum change that passes. Finish the RED → GREEN loop before writing the next behavior's test. Completion: the new test passes.
- Full suite. Completion: suite green; no new skips.
- REFACTOR. Cleanup only; re-run after each edit. Completion: suite still green.
- Commit after the full suite passes. Completion: no failing tests in the landing diff.
Complex bug, unbiased repro: spawn a writer that sees the bug description not the fix; verify RED yourself, then GREEN. Do not hard-wire a host-local persona path.
Acceptance Criteria
- [ ] Test for the new behavior existed before implementation (RED captured)
- [ ] Minimal implementation made that test pass (GREEN captured)
- [ ] Bug fixes include a reproduction test that failed before the fix
- [ ] Full suite green; no skips added to force green
- [ ] Test names describe behavior, not implementation
Rationalization Table
| Excuse | Reality |
|---|---|
| "Tests after it works" | Post-hoc tests lock implementation, not behavior |
| "Too simple to test" | Simple code grows; the test is the spec |
| "I tested it manually" | Manual does not persist across tomorrow's change |
| "Just a prototype" | Prototypes ship; debt starts on day one |
Extended playbook: references/rationalizations.md.
Red Flags
- Code with no corresponding test
- Test passes on first run (may prove nothing)
- "All tests pass" without running them
- Bug fix without reproduction test
- Skipping tests to go green
Verification
Skill type: discipline
Bar level: discipline
See Also
references/test-shape.md— pyramid, patterns, anti-patternsreferences/testing-patterns.md— code examples../code-review/references/spec-as-test.md— S4 review of test evidence against the specreferences/testing-standards.md— path conventions
04 同仓库更多 Skills
writing-plans
Use when turning a buildable spec into ordered tracer bullets after architecture-change-reviewer. Covers vertical slicing, dependency order, and headroom for the implementer. Triggers on 写计划, 拆任务, 任务分解, 制定方案, 跨文件改动, 计划.
wayfinder
Use when a chunk of work is more than one agent session can hold — plan it as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.
verification-before-completion
This skill should be used when claiming "完成" / "done" / "fixed" / "passing" / "ready to ship", before trusting a subagent success report, or when checking "对照计划" / "对照 spec" — whether this run's delivery matches its basis.
using-agent-skills
Use when starting a new session, switching tasks, or unsure which arthurpower skill applies. Routes incoming work to the matching skill via flowchart before invoking. Activates on phrases like "which skill should I use", "skill check", "pre-task skill check", "how to start", "router", "skill routing", or when multiple competing skills could apply. Does not auto-invoke user-invoked authoring skills (skill-authoring, self-evolving-rules).
systematic-debugging
Use when debugging a test failure, build break, unexpected runtime error, flaky test, or hanging process. Triggers on phrases like "fix this bug", "getting an error", "failing test", "flaky", "hanging", "halfway through debugging", "this used to work", "intermittent failure", "stack trace shows X", or any case where behavior does not match expectations. Prevents shotgun debugging.
spec-driven-development
Use when the work isn't a spec yet — a one-line ask, multi-file change, ambiguous scope, or architectural decision on the table. Spec-driven-development captures what to build, why, and how to know it's done before any plan or commit. Skip for single-line fixes or bounded bug fixes.