tdd
Invoke test-driven development as an explicit one-at-a-time micro-cycle — one test, one piece of functionality, refactor, then repeat for the next behavior
- License 许可
- MIT
- 最近更新
- 2026-09-10
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- tdd
- description
- Invoke test-driven development as an explicit one-at-a-time micro-cycle — one test, one piece of functionality, refactor, then repeat for the next behavior
- user-invocable
- true
02 资源文件 3
- 参考文档evals/benchmark.json2.4 KB
- 参考文档evals/benchmark.md3.1 KB
- 参考文档evals/rationalizations.md4.7 KB
03 SKILL.md 正文
/tdd — One-at-a-Time TDD Micro-Cycle
/test-driven-development
The skill above is the core RED→GREEN discipline (watch every test fail before
writing code; no production code without a failing test first). /tdd adds
one thing on top of it: the cadence.
TDD is not "write the tests, then write the code." It is a tight loop run one behavior at a time:
one test → watch it FAIL → minimal code → watch it PASS → refactor → repeat
The Micro-Cycle
For a task with N behaviors you run the loop N times — not once:
- Write one failing test for the next single behavior. Nothing more.
- Run it. Watch it fail for the right reason (RED).
- Write the minimal code to make that one test pass — nothing the test didn't ask for.
- Run it. Watch it pass (GREEN). Confirm the rest of the suite is still green.
- Refactor while green — remove duplication, improve names. No new behavior.
- Go back to step 1 for the next behavior.
One test in flight at a time. One behavior implemented per cycle. The suite is green at the end of every cycle — not just at the end of the task.
The Anti-Pattern This Exists To Stop
Writing all the tests up front, then implementing everything in one pass. This is the single most common way "I used TDD" becomes false: it is batch development with the tests merely written first. You forfeit the per-behavior RED signal (you never watch this behavior's test fail in isolation), the minimal-code check, and the incremental design feedback that each cycle gives you.
If your test file has N tests for N behaviors and there is still no implementation, you are batching — stop and collapse back to one test.
Common Rationalizations
| Excuse | Reality |
|---|---|
| "Requirements are small / clear / independent — all-tests-first then one-pass impl is equivalent to cycling, just faster" | Equivalent output ≠ equivalent process. Batching forfeits the per-behavior RED and the minimal-code discipline. "Just faster" is the justification every batching agent reaches for — run the loop. |
| "The solution spans all requirements at once (one regex / one function) — there's no seam to implement one behavior and leave the rest failing" | There is a seam: implement behavior 1, let behaviors 2..N stay red. A general solution that passes everything at once was written without any of behaviors 2..N driving its design. Arrive at the general form one passing test at a time; don't start there. |
| "The combined / compound case forces a general solution anyway, so writing the whole parser now is just minimal code" | The minimal code for one combined case (e.g. 1h30m) is not the whole parser. If you reach for the general solution at the first compound requirement, the later cases (more units, each invalid input) pass on first write — they never go RED, and you've batched the implementation behind them. That is the batch-leak, one requirement later. Even when the general form is where you'll land, get there by letting each later test drive it. |
| "Strict cycling means hobbling the implementation to watch 'manufactured' red states — ceremony without safety" | The red state is not manufactured; it is the proof that each test can fail and tests exactly its own behavior. Skipping it is precisely the failure /test-driven-development's Iron Law names. |
| "Mental tracing / a dry-run substitutes for running the tests each cycle" | It does not. "I traced it in my head" is the exact thing TDD replaces with evidence. Run the test, each cycle. |
| "Per-behavior red→green only matters when requirements interact or the design is unclear" | You don't know which behavior will surprise you until it does — that's why you cycle. Reserving the discipline for "hard" cases means never running it, because everything looks easy up front. |
| "The lead said it's trivial — move fast" | Move fast by cycling fast, not by collapsing N cycles into one. The micro-cycle on a small task costs minutes; debugging a one-pass implementation that's subtly wrong costs more. |
| "Refactor wasn't needed — it came out clean on the first pass" | Maybe — but that's a judgment made while skipping the step. Pause at green and look. Skipping refactor silently is how duplication accretes. |
Red Flags — STOP
- Writing a second test before the first one is green.
- A test file with N tests for N behaviors and no implementation yet.
- An implementation that satisfies multiple behaviors you never wrote separate failing tests for.
- "I'll write all the tests first, then implement" — that's batch development, not the micro-cycle.
- Reaching for the fully-general solution before the specific tests forced it — especially writing the general implementation at the first compound / combined requirement, so the remaining cases (more units, invalid inputs) pass with no RED of their own. Each later behavior still gets its own failing test first; implement only what this test demands and let the next test force the generalization.
All of these mean: collapse back to one failing test and resume the loop.
This skill layers cadence on top of /test-driven-development; it does not
replace it. Invoke that skill for the RED→GREEN rules themselves.
04 同仓库更多 Skills
visual-aid
Use when the user asks for a quick visual aid, visual explainer, concept card, one-pager, poster, cheat sheet, infographic, visual summary, summary card, or mini explainer page — especially from input like a block of text, attached images, an attached song (lyrics/audio), a web link, a CSV/dataset, a math formula, a code snippet to walk through, a tutorial's steps, a timeline, or an A-vs-B comparison. Triggers include "make me a quick visual aid", "turn this into a one-pager / cheat sheet / explainer", "summarize this visually", "give me a visual of", "explain this on a single page", "make a concept card for", "whip up a page about", "build a mini page that shows", "something I can paste into a doc explaining X", or any request to render a topic/text/link/image-set/song/data into a standalone page. Prefer this skill over frontend-design when the ask is an explanatory single-file page (not a production UI), over playground when the output is static information display (not an interactive configurator), and over a Markdown/code answer when the user explicitly wants a *page* (HTML). Produces a single self-contained HTML file that opens on double-click without a server.
tesseract
Use when you've been poking at the same file, concept, or problem across many sessions and want to step outside time to see its whole arc — or when you want to leave a note for next-session-you. Triggers: 'I've been going in circles on X', 'what have I learned about X', 'what did past-me say about X', 'I keep rediscovering this'.
tdd-cat
TDD workflow with subagent-driven-development — /tdd composed with /cat, plus the A/B TDD execution-mode axis (split-phase vs micro-cycle) asked as a third question in /cat's combined pre-dispatch question
task-list
TaskCreate / TaskUpdate / render the current TaskList in response to `/task-list` (with or without flags). The skill body executes immediately on the syntax — no permission-seeking, no echoing the list back as plain text.
sync
Sync files between two local directories, repos, or git worktrees. Five modes (plan/interactive/push/pull/mirror), .gitignore-aware, Claude-workflow allowlist via --claude, dropbox-restore-style per-directory prompts.
super
Brainstorming (alias for /brainstorming)