/dev-process-toolkit:tdd <FR-id> [--resume-at <AC-id>|refactor|audit] [--tests-provided <path...>]from dev-process-toolkit
Orchestrates a multi-agent TDD cycle (RED → GREEN → REFACTOR → AUDIT) for a single functional requirement by forking subagents for test writing, implementation, refactoring, and spec review.
Ships in dev-process-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Execute the TDD cycle for $ARGUMENTS (an FR ID — STE-NNN, ULID, or specs/frs/<id>.md path) by orchestrating three forked-subagent stages. Each stage runs in an isolated context paired via Claude Code's context: fork + agent: mechanism, so the test-writer cannot see the implementer's plan, the implementer cannot see other ACs' implementations, and the refactorer cannot see per-AC reasoning.
The orchestrator itself runs in the main context (no context: fork on this skill) so it can drive the loop, parse hand-off blocks, and halt on bounded-retry exhaustion.
| Stage | Child skill | Subagent | Cycle granularity |
|---|---|---|---|
| RED | tdd-write-test | tdd-test-writer | once per FR, batched across all ACs |
| GREEN | tdd-implement | tdd-implementer | once per AC — N forks for N ACs |
| REFACTOR | tdd-refactor | tdd-refactorer | exactly once at end after all GREEN |
| AUDIT | tdd-spec-review | tdd-spec-reviewer | exactly once at end, post-REFACTOR |
Children carry context: fork + user-invocable: false + an agent: field naming the subagent. The orchestrator invokes them via the Skill tool with the rendered prompt body.
$ARGUMENTS resolves to a single FR, optionally followed by --resume-at <AC-id>, --resume-at refactor or --resume-at audit to resume a run that halted — see § Resume after a halt.--tests-provided <path...> takes one or more paths to existing test files the run uses instead of writing its own. Combined with --resume-at it is accepted, and Stage RED is skipped as on any resume.specs/frs/<id>.md § Acceptance Criteria.Read specs/frs/<id>.md. Extract the AC list (every AC-<prefix>.<N> line under ## Acceptance Criteria). This is the batched input for the test-writer and the per-AC dispatch list for the implementer.
On a --tests-provided run, check every path first: one that does not exist, or lies outside the repository, refuses in the NFR-10 shape (Refusing: --tests-provided <path> <does not exist | is outside the repository>) before the receipt is recorded and before any fork is dispatched.
Once that FR file is resolved, its checkout is the one this cycle runs for. Record the run against it, before any stage is dispatched, with bun run "${CLAUDE_PLUGIN_ROOT}/adapters/_shared/src/gate_receipt.ts" tdd "<that checkout root>". If it refuses, stop and report its block verbatim — the commit gate reads that receipt in the repository the commit targets, so without it the commit is refused later with no explanation.
Only if that call also printed outcome: on, record the cycle's verdict with bun run "${CLAUDE_PLUGIN_ROOT}/adapters/_shared/src/gate_receipt.ts" outcome tdd "<that checkout root>" <pass|fail>: pass after § 5 AUDIT returns status: ok, or fail on the Halt path.
Then, before any stage, run the stranded-plant check (§ Stage GREEN) over every AC directory already under <git-dir>/dpt-defect-check/, whichever FR it came from: a run that died during a defect check left its plant in the source and its backup there. Since then the operator may have found the plant and kept working, so this sweep restores only what the rule below proves is a plant, and asks about the rest.
tdd-write-test once with the batched AC listSkipped on a resume (--resume-at): the tests from the halted run stand, the hand-fixed one included.
On a --tests-provided run no test-writer fork is dispatched: the orchestrator runs the named files with the project's test command and requires at least one failing test. When every named test passes, the run halts with failure mode provided-tests-pass and no implementer fork is dispatched.
Pass the test-writer:
The child fork runs in isolation with tools: Read, Grep, Glob, Write, Edit, Bash (allowlist; no Agent, no Web tools). It writes failing tests for every AC, runs them once to confirm RED, and ends with a single tdd-result fenced block.
tdd-implement once per ACFor each AC in order:
--tests-provided run that failing-test command is the project's test command run on the named files, the same for every AC.tdd-result fenced block.The defect check is what makes RED load-bearing. A test that failed before the code existed may have failed only because a symbol was missing; the check plants the smallest bug in the end state the AC's test reads and requires that test to go RED at its assertion, then restores the source. The implementer reads the AC's test file to place the plant, which narrows the per-AC isolation for this check: the file may hold other ACs' tests, so it reads the file only to place the plant and never implements toward them. It proves each plant changed the file (cmp), and a test that stays GREEN gets a second, different plant before any verdict — one plant can be an equivalent mutant or sit in a branch the test never takes. It records the check in notes, which this stage always fills: defect check: <plant> → red at <test>; defect check: n/a — <reason> when there was no source line to plant in; defect check: not run — <reason> when no turn was left, no plant reached the assertion (it changed nothing, or went RED before it — a compile error, setup), or one plant left the test GREEN and no second valid plant ran — that line names the plant. Two plants that leave the test GREEN are never not run. A status: failed whose notes reads defect check: <plant 1>; <plant 2> → still GREEN is a test that does not guard its AC: failure mode not-load-bearing. recordTddFailure(…, "not-load-bearing") halts on the first attempt and spends no budget, because the implementer may not edit tests and two plants already failed to turn it RED; formatHaltReport renders it with its own header and a remedy naming the AC: fix the test by hand so it fails at its assertion when the behavior breaks, then resume at that AC — through /implement when /implement started the run.
Check for a stranded plant after every implementer fork — whatever its status, and when it returned no block at all. The implementer backs the planted file up under <git-dir>/dpt-defect-check/<AC-id>/ at its repository-relative path, <git-dir> being git rev-parse --absolute-git-dir of the checkout — a path both sides derive the same way, outside the working tree and one per worktree — and records each planted version beside the backup (<path>.plant1, <path>.plant2) before applying it. Its trap cannot run when its shell is killed outright, and a plant left in an uncommitted file looks to git diff exactly like the implementation. So, before the next AC or a retry of this one, compare every backed-up file with its counterpart in the checkout:
plant restored by the orchestrator in <file> against the AC (that check is unverified), and remove the directory.diff <backup> <file>, and ask the operator whether to restore the backup or keep the file and drop the backup. Record backup kept for <file> until they answer.A notes line that reports a plant (red at, still GREEN) with no directory to check has no proof of its restore: re-run the command to see GREEN and record no backup to check the restore against — that check is unverified too.
The orchestrator dispatches N forks for N ACs — each implementer invocation sees one AC, never the full list. This per-AC isolation is the load-bearing property: it stops the implementer from optimizing across ACs in ways the test-writer didn't anticipate. The defect check's read of the AC's test file, above, is its one exception.
tdd-refactor exactly once at end of FRAfter every AC is GREEN, run the refactorer once with the full list of source files modified across the per-AC implementer runs — on a resume, the implementer runs belong partly or wholly to the halted run, so pass every source file the working tree changes (git status --porcelain, tests excluded). The refactorer cleans up cross-AC duplication while keeping every test GREEN — empty refactor is a valid outcome (files: []).
The single-once-at-end batching is by design. Per-AC isolation matters most for the test-writer-cannot-see-implementation guarantee; refactor isolation matters less because by then all tests are GREEN and the refactorer's correctness gate is "tests still pass." A single global pass costs less and sees cross-AC duplication that per-AC refactor wouldn't catch.
tdd-spec-review exactly once after REFACTORAfter tdd-refactor returns status: ok and re-running the refactor command still shows GREEN, the orchestrator forks tdd-spec-review exactly once — at end of FR, after every AC is GREEN and the cross-AC refactor pass has landed. The audit fork is the final stage in the state machine and runs post-REFACTOR, never per-AC.
Pass the spec-reviewer:
The child fork runs in isolation with a read-only toolset (no Write, no Edit, no Bash, no Agent). It traces each AC to the implementation + tests, classifies each as ✓ Done / ✗ Missing / ⚠ Partial, scans for cross-cutting spec drift, and ends with a single tdd-spec-review-result fenced block.
The orchestrator parses the returned block via parseTddSpecReviewBlock(...) from adapters/_shared/src/tdd_spec_review_result.ts (the AC.3 helper). Only if the § 1 receipt call also printed review_findings: on, write the fork's full output to a temp file and record its counts with bun run "${CLAUDE_PLUGIN_ROOT}/adapters/_shared/src/review_findings_receipt.ts" record "<that checkout root>" tdd-audit "<that file>" once per audit. It then branches on missing_acs.length:
missing_acs.length === 0 ⇒ exit-ok. The audit passed. partial_acs, drift_count, advisory_findings, and cross_cutting_drift are advisory only — they are surfaced in the human-readable report but do not halt the FR or consume the retry budget. A clean first audit always exits successfully regardless of advisory fields.missing_acs.length > 0 on the first audit ⇒ retry path. The orchestrator re-enters the RED→GREEN sub-loop for the missing ACs only (write-test + implement), capped at a single audit-round retry (recordAuditRoundFailure(...) budget, cap = 1).missing_acs.length > 0 on the second audit ⇒ halt. The orchestrator emits a halt report listing the unresolved missing_acs and exits non-zero. The audit-round retry budget is independent from the per-AC semantic budget — burning per-AC retries does not consume audit retries, and vice versa.The AUDIT stage's halt path uses the same formatHaltReport channel as the other stages, with mode set to the audit-specific failure mode and missingAcs populated from the returned block.
This RED→GREEN→AUDIT-and-retry shape is the canonical instance of the audit-fix loop pattern — see docs/patterns.md#pattern-audit-fix-loop for the cross-skill catalogue (TDD's AUDIT stage, /spec-review, /implement Phase 3 Stage B, /simplify) and the in-process-fix exception.
tdd-result fenced blockEvery child ends its turn with exactly one fenced ```tdd-result block, parsed deterministically by parseTddResultBlock(...) from adapters/_shared/src/tdd_result.ts. Locate via extractTddResultBlock(stdout) against the child's full output.
Required fields per role:
role: test-writer | implementer | refactorer
status: ok | failed
files:
- path/to/file.ts
command: bun test path/to/file.test.ts
output_excerpt: |
first 40 lines of test runner output
notes: optional one-liner
role must equal the role being invoked (test-writer / implementer / refactorer).files may be empty ([]) for the refactorer when no refactor was needed.output_excerpt is the first 40 lines of test runner output — must show RED for test-writer, GREEN for implementer + refactorer.notes is optional in the schema; the implementer always fills it with its defect-check line.The orchestrator distinguishes:
tdd-result says status: ok, but re-running its command does not produce a failure (the tests don't actually fail).tdd-result says status: failed (other than a failed defect check), or status: ok but re-running the command shows RED.tdd-result says status: failed, or status: ok but re-running the command shows RED.extractTddResultBlock or parseTddResultBlock rejects the child's output (no fenced block, multiple fences, missing role, missing required field, wrong role for the invocation, invalid status).maxTurns: 8 without producing a parseable block. Counts as a failed attempt under whichever of (A) / (B) / (C) applies to the calling role.status: failed with defect check: <plant 1>; <plant 2> → still GREEN: the AC's test stayed GREEN under two different plants with the behavior broken. Not retried — see Stage GREEN.--tests-provided run, every named test passed at Stage RED. Not retried: recordTddFailure halts on the first occurrence and spends no budget.Backed by recordTddFailure(...) from adapters/_shared/src/tdd_retry_state.ts:
tdd-result block." After the second format failure, halt.Format and semantic budgets are independent — a format violation does not consume the semantic-failure budget.
When retrying a child after a semantic failure, the orchestrator's retry prompt injects only raw failing-test output — no orchestrator-side analysis, no "the test fails because X — fix Y." Anything more leaks information that defeats the test-writer-cannot-see-implementation guarantee. The retry prompt template is:
The previous attempt did not satisfy the success criterion. Below is the
raw output of running the failing-test command. Re-emit your work as a
single `tdd-result` fenced block at the end of your turn.
<raw stdout/stderr from the test runner — no analysis>
For a mode-D format violation, the retry prompt is even narrower: "re-emit your last message with a valid tdd-result fenced block at the end of your turn." No semantic re-prompt.
When AUDIT exits ok, the orchestrator ends with one row per AC dispatched in this run: the AC id and its defect-check line as the implementer recorded it, with plant restored by the orchestrator in <file> appended where the stranded-plant check fired. Below the rows comes a list headed Unverified tests (the defect check covers one test per AC), so none there never reads as every new test having passed it. It names, each with the reason, every AC whose ok block carries any line other than defect check: … → red at … — n/a, not run, still GREEN on an ok, any other text, or no defect check: line at all (the parser accepts that block, so it is not retried) — and every AC whose plant the orchestrator restored or could not check; or it reads none. On a resume, ACs before --resume-at were not dispatched in this run, so this run cannot vouch for their checks: the list names each with not dispatched in this run — resumed at <point>.
On a --tests-provided run the report says the tests were provided, not written, and names the files.
A last list, Backups, names every restore and every kept backup the stranded-plant check produced in this run, the start-of-run sweep included — whichever AC or FR it belongs to — or reads none.
Unverified tests do not halt or fail the run — a test that stayed GREEN under two plants already halted it, so it never reaches this list. They are reported so the check cannot vanish unseen: /implement states in its step-14 AC checklist how many ACs carry an unverified defect check.
A halt leaves the code of every AC before it GREEN and every test the test-writer wrote in place — including, after a not-load-bearing halt, the halted AC's test, which the operator fixes by hand. A plain re-run from the top restarts at Stage RED: the test-writer is dispatched again over tests that include the hand fix, and once every test is GREEN — after a halt on the last AC, in REFACTOR or in AUDIT — Stage RED reads as mode A.
/dev-process-toolkit:tdd <FR-id> --resume-at <point> resumes instead. Step 1 runs as usual — the receipt and the stranded-plant sweep — after the point is checked: an <AC-id> that is not one of the FR's ACs, or any other word but refactor and audit, refuses before the receipt is recorded. Stage RED is skipped at every point, so no test-writer fork touches the tests; the AUDIT stage's retry round, scoped to the ACs the audit reports missing, still dispatches the test-writer for those.
<AC-id> (a first-pass halt in Stage GREEN) — starts Stage GREEN at that AC, telling its implementer this is a resume: its test may already be GREEN, and then it goes straight to the defect check. Later ACs run as usual, then REFACTOR and AUDIT.refactor (a refactorer halt, after the operator fixed or reverted the refactor) — skips Stage GREEN, confirms the failing-test command is GREEN, then runs REFACTOR and AUDIT.audit (any spec-reviewer halt, or an implementer halt in the audit retry round — every AC is GREEN by then, so none is re-dispatched — after the operator fixed what stopped it, implemented the ACs it reported missing or corrected the FR) — confirms the command is GREEN, then runs AUDIT with its retry round.When /implement started the run, the operator resumes through it instead — /dev-process-toolkit:implement <FR-id> --resume-at <point> — so Phase 2 passes the flag here and the later phases still run. A halt report names the right one.
When the bounded budget is exhausted — or at once on a not-load-bearing failure, which spends no budget — the orchestrator:
formatHaltReport(...) from adapters/_shared/src/tdd_halt_report.ts with { mode, role, entry, fr, ac, auditRound, retryCount, lastBlock?, rawOutput?, testsProvided? } — auditRound (true for an implementer halt in the AUDIT retry round) makes it resume at audit, not the AC; entry (implement when /implement invoked this run, else tdd) and fr make its resume command one the operator can copy as it stands; testsProvided (the named files, on a --tests-provided run) adds the line tests provided, not written: <files>.tdd-result block, or raw output if no block was emitted).The halt path does pause for the operator. This is intentional — the bounded-retry cap means halt only fires after a real failure. Routine TDD cycles (no retries needed) run end-to-end without operator interaction. /implement Phase 2 invokes this orchestrator inline.
tdd-result is the only return channel.status: failed and the operator decides.--resume-at or --tests-provided run — only the AUDIT retry round's, for the ACs it reports missing./tdd on the FR" → no — that restarts at Stage RED; resume with --resume-at <AC-id>, or refactor / audit after GREEN.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
29 skills in this plugin
/best-practicesManage the project best-practices manifest at `specs/best-practices.yaml`. Add, edit, delete, or list entries cataloguing house best-practices docs with scope globs and topics that feed guidance retrieval into planning and implementation./brainstormSocratic design session for greenfield features with open solution spaces. Clarifies goals one question at a time, proposes 2-3 approaches with tradeoffs, gets design approval, then feeds into /spec-write./debugStructured debugging protocol for failed gate checks, failing tests, unexpected behavior, or a reported bug. Use when /gate-check or /tdd fails and the cause is unclear, or when a reported bug (a symptom, a ticket, a bug FR) needs its cause found and a test that proves the fix. Phases: Root Cause → Pattern Analysis → Hypothesis Testing → Implementation.npx claudepluginhub nesquikm/dev-process-toolkit --plugin dev-process-toolkitOther plugins' skills for the same job