tdd-feature-build
Use when the user describes a NEW feature to add ("add X to Y", "implement Z", "build a feature that…", "make it possible to…"). Enforces TDD — failing test first, minimum code to pass, refactor. Refuses to ship code without a test that demonstrably catches its absence. Does NOT trigger on bug fixes (use bug-fix-discipline) or refactors (use test-first-extract). Will ask 1-3 clarifying questions before writing any code; safe to delegate from /feature command.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-09
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- tdd-feature-build
- description
- Use when the user describes a NEW feature to add ("add X to Y", "implement Z", "build a feature that…", "make it possible to…"). Enforces TDD — failing test first, minimum code to pass, refactor. Refuses to ship code without a test that demonstrably catches its absence. Does NOT trigger on bug fixes (use bug-fix-discipline) or refactors (use test-first-extract). Will ask 1-3 clarifying questions before writing any code; safe to delegate from /feature command.
03 SKILL.md 正文
TDD Feature Build
You are building a new feature using strict test-driven development. The user describes WHAT they want; you decide HOW, and you build it the right way.
Pre-flight (do this once, before any code)
- Read the standards. Look for
QUALITY-BAR.mdat the project root. If absent, fall back to the plugin's at${CLAUDE_PLUGIN_ROOT}/QUALITY-BAR.md. Internalize: naming, formatting, types, error handling, forbidden patterns. - Read the project's CLAUDE.md (if present) for any project-specific conventions that override the defaults.
- Detect the test framework. Look at
package.json/pyproject.toml/ existing*.test.*files. If no framework is set up at all, STOP and tell the user to run/init-guardrailsfirst — TDD without a test runner is a non-starter. - Check git state. If there are uncommitted changes, tell the user and ask whether to (a) commit them as a separate WIP first, (b) stash, or (c) include them in the upcoming feature commits.
- Create a feature branch from the current HEAD:
git switch -c feature/<short-slug>. Do not work onmain/master.
Clarifying questions (ask 1–3 before writing any code)
If the feature is ambiguous in any of these dimensions, ASK before proceeding. Do not assume.
- Behavior boundary: what does success look like? What are 2-3 happy cases and 2-3 edge cases?
- Data shape: any new state, props, fields, schema changes?
- UI surface (if applicable): where does this appear? Does it need to integrate with existing components or is it standalone?
- Persistence: does this need to survive reload (localStorage / DB)?
- Auth scope: who can do this — anonymous, logged-in, owner-only?
- Failure modes: what should happen on network error / invalid input / concurrent modification?
If the user has already answered all of these in their request, skip to the next section.
The TDD cycle (one cycle per scenario)
For each scenario you identified above, run a complete red-green-refactor cycle. Do not write multiple scenarios in one cycle.
Red
- Write a failing test that captures exactly this scenario. Use
the project's existing test structure as a guide. Apply the strict
assertions from
QUALITY-BAR.md:getByRole('button', { name: /Save/ })notqueryAllByText.- Exact equality where possible;
toHaveLength(N)not>= 1unless duplicates are inherent. - Mock external dependencies (fetch, timers, DOM APIs); never let a unit test hit the network.
- Run the test. It must fail. Read the failure message — does it
fail for the RIGHT reason (the behavior under test isn't there yet)
or the WRONG reason (typo, missing import, fixture mismatch)?
- Wrong reason → fix the test, re-run, get to the right red.
- Right reason → proceed to green.
Green
- Write the minimum code to pass the test. Not the most general solution, not the most "correct" abstraction — the smallest change that turns the red into green. YAGNI applies aggressively here.
- Run the test. Should pass.
- Run the entire test suite. Confirm no other tests broke. If they did, your minimum code was too aggressive — pull back.
Refactor
- Look at what you wrote with fresh eyes. Is there duplication you should remove? A name that's wrong? A type missing? A QUALITY-BAR rule violated?
- Refactor in small steps, running tests after each. Tests must
stay green throughout. Common refactors at this stage:
- Extract a helper if you wrote inline logic that has 2+ uses.
- Rename for clarity (
x→userId). - Add type annotations where inference is awkward.
- Add a comment explaining WHY (never WHAT).
Commit
- Commit the cycle. Use the format from QUALITY-BAR.md:
feat(scope): imperative summary What changed and why. Behavior visible to user. Trade-offs noted. Behavior: … Tests: +N tests covering …; suite NN/NN green. Assisted-by: Claude (claude-tdd-pro 0.3.0)
Repeat for the next scenario.
After all scenarios are green
- Final lint + format + typecheck + test pass. Everything must be green. If any step fails, fix it before declaring done.
- Re-read your own diff. Look for: dead code from refactor,
commented-out code, leftover
console.log, TODOs you forgot to resolve. - Tell the user the feature is done with a one-line summary plus
the suggestion:
Ready for /pr.
What to refuse / push back on
- "Just write it without tests; I'll add them later" — refuse. Tests-after almost never happen, and the test isn't a regression-catcher unless it was actually red first. Politely explain and proceed with the test.
- "Don't bother with edge cases for now" — push back gently. Identify the most important 1-2 edge cases (null inputs, empty collections, network failure) and at least cover those.
- "Make it work in the existing god-file" — push back if the god-file is over ~1000 lines. Suggest the new code goes in a separate file from day one; integrate via import.
What to delegate
For multi-scenario autonomous work where the user wants minimal
involvement until PR time, delegate to the tdd-driver subagent:
"I'm going to delegate this to the tdd-driver agent which will run the
full red-green-refactor loop autonomously and report back when ready
for /pr."
04 同仓库更多 Skills
test-first-extract
Use when the user asks to EXTRACT or RELOCATE existing code into its own file, module, or component ("extract X", "split out Y", "pull Z into its own file", "decompose god-file"). NOT for net-new features (use tdd-feature-build) or behavior changes (use fix-bug). Enforces the 9-step extraction with isolated unit tests + integration regression tests as a two-tier safety net.
sync
Multi-machine git-backed sync of local TDD Pro state via the `tdd-pro-sync` branch. Use when operators run claude-tdd-pro on more than one machine and want their FAILURE-LOG, decisions, audit checkpoints, workflow state, operator-curated URL registries, operator/community trees, and paywalled attestations to follow them between hosts.
strict-component-tests
Use when writing or reviewing test files. Enforces strict assertions that actually catch regressions (getByRole, exact counts, jest-dom matchers) in contrast to permissive tests (queryAllByText length > 0) that pass against broken UIs. References QUALITY-BAR.md for the canonical strictness rules.
spec
暂无简介
spec-first
Use when the user describes a non-trivial feature or system that should be specified in writing before any code is written. Pattern from Geoffrey Huntley's "Ralph" loop, OpenSpec, intent-driven.dev, and Kent Beck's "augmented coding" framing — specs+tests are the durable artifact, code is the disposable one. Produces a Markdown spec document that the user reviews; only after approval does any code get written (typically via tdd-feature-build or /feature).
reject-bad-tooling
Use whenever the conversation involves dependency suggestions, CI/CD design, "automated code improvement," lint/security fixes, or "tools to make my code better." Refuses specific anti-patterns from a prior session that produced more harm than help — and explains why, with the better alternative. Triggers on suggestions of force-fix flags, auto-commit CI workflows, jscodeshift codemods on untested code, fake package names, and similar.