一键导入
tdd
Test-Driven Development workflow using vertical slices. Use when implementing features with TDD, writing tests before code, or doing red-green-refactor cycles.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Test-Driven Development workflow using vertical slices. Use when implementing features with TDD, writing tests before code, or doing red-green-refactor cycles.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | tdd |
| description | Test-Driven Development workflow using vertical slices. Use when implementing features with TDD, writing tests before code, or doing red-green-refactor cycles. |
/tdd — start TDD from scratch (manual planning)
/tdd #123 — start TDD from GitHub issue #123 (pulls scope + acceptance criteria)
/tdd #123 #124 — batch related issues into one TDD session
When invoked with a GitHub issue, fetch the issue body with gh issue view <number> and use it as the scope for the planning step. The issue's acceptance criteria become the initial behavior list.
If a plan exists in ./plans/ for the feature being implemented, read it for architectural decisions and phase context. Plans are created by /carve and contain vertical slices, durable decisions, and dependency ordering that should inform your test strategy.
Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification — "user can checkout with valid cart" tells you exactly what capability exists.
Before writing any code:
./plans/, review architectural decisions and phase boundariesAsk: "What should the public interface look like? Which behaviors are most important to test?"
State assumptions before RED. Before writing the first failing test, write down — in a comment in the test file, in the session notes, or in the PR description — the assumptions the test will encode:
Silent assumptions become test design choices that are expensive to reverse later.
Stop and ask if an AC is ambiguous. If an acceptance criterion in the issue or plan admits more than one reasonable interpretation, do NOT pick silently. Pause, surface the options, and ask. The entire test suite hangs off your interpretation — a wrong guess at this stage cascades through every RED→GREEN cycle that follows.
Issue AC: "Returns user's recent orders." You: "Recent = last 30 days, last 10 orders, or whatever fits one screen? Each gives a different test design."
Write ONE test that confirms ONE thing about the system:
RED: Write test for first behavior → test fails
GREEN: Write minimal code to pass → test passes
This proves the path works end-to-end.
For each remaining behavior:
RED: Write next test → fails
GREEN: Minimal code to pass → passes
One test at a time. Only enough code to pass the current test. Don't anticipate future tests.
After all tests pass:
Never refactor while RED. Get to GREEN first.
Even while GREEN, keep changes surgical:
The test: imagine reading the diff cold. Could every changed line be traced to "needed for test X"? If not, the surplus lines need to come out.
DO NOT write all tests first, then all implementation.
Tests written in bulk test imagined behavior, not actual behavior. You end up testing the shape of things rather than user-facing behavior. Tests become insensitive to real changes.
WRONG (horizontal):
RED: test1, test2, test3, test4, test5
GREEN: impl1, impl2, impl3, impl4, impl5
RIGHT (vertical):
RED→GREEN: test1→impl1
RED→GREEN: test2→impl2
RED→GREEN: test3→impl3
foo.test.ts next to foo.ts (not a parallel __tests__/ tree)describe named after the unit under testMock only at system boundaries:
Date.now), randomness (Math.random), file systemNever mock things you control:
If you feel the need to mock an internal module, the code is doing too much or you're testing at the wrong level.
For patterns (dependency injection, SDK wrappers, examples of good vs bad mocks), see mocking.md.
[ ] Assumptions stated before the first RED (input/output/boundary)
[ ] AC interpretation confirmed with user (no silent picks on ambiguous ACs)
[ ] Test describes behavior, not implementation
[ ] Test uses the public interface
[ ] Test would survive an internal refactor
[ ] Mocks only at system boundaries
[ ] Co-located next to source file
[ ] Code is minimal for this test
[ ] No speculative features added
[ ] Every changed line traces to the current test (no adjacent improvements)
[ ] Pre-existing dead code left untouched (mentioned in PR description if noticed)
[ ] Coverage thresholds pass for the file under test
Audit a React/TSX repository for React anti-patterns by loading rule cards from the brainstormer card library, scanning via each card's declared detect strategy, and filing one grouped GitHub issue per `(skill, rule_id)` via the `gh` CLI. Phase 3 adds the full re-run lifecycle: `findIssueByLabel` lookup, in-place body rewrite bounded by `react-audit:managed:start/end` sentinels (human comments survive), close-with-dated-resolution on emptied findings, regression-with-backlink on resurfaced findings, label-collision protocol under concurrent runs, never-reopen invariant. Phase 2c grouped body (15 MVP cards, per-occurrence severity, `<details>` collapsibles) and Phase 2b smart scan (`SMART_SCAN_THRESHOLD=50`) unchanged. Manual invocation only — no hooks. Triggers on `/react-audit`, "audit this repo for react anti-patterns", "run a react audit". Skip design questions, scaffolding, audits of non-React frameworks (Vue, Svelte, Solid).
Discovery interview and requirements gathering session. Pressure-test an idea, architecture, or design decision through structured client interviews. Use when the user wants to be challenged on their thinking, explore trade-offs, or vet a plan before committing.
Create a Product Requirements Document through structured interview. Use when the user wants to write a PRD, define requirements, or plan a new feature.
Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved as a local Markdown file in ./plans/. Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions "tracer bullets".
Convert a PRD into independently-grabbable GitHub issues using vertical slices. Use when the user wants to create issues from a PRD, break down a PRD into tasks, or create GitHub issues from requirements.
Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.