Use when driving a multi-task feature phase whose WALL-CLOCK matters and the task plan is a dependency DAG — independent tasks run as parallel waves on a task-loop substrate (authoritative plan doc + per-task commits). Parallel multiplies quota pressure ×N (cap 3, user-adjustable); the serial sibling spec-tdd-task-loop is the 429-safe mode; a plain multi-unit bug batch is NOT this skill. Triggers on parallel tasks, dependency graph, task waves, wall-clock pressure, auto time-band switching, D...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Spec Tdd Task Dag?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/benjaminchenlab-spec-tdd-task-dag)
---
name: spec-tdd-task-dag
description: Use when driving a multi-task feature phase whose WALL-CLOCK matters and the task plan is a dependency DAG — independent tasks run as parallel waves on a task-loop substrate (authoritative plan doc + per-task commits). Parallel multiplies quota pressure ×N (cap 3, user-adjustable); the serial sibling spec-tdd-task-loop is the 429-safe mode; a plain multi-unit bug batch is NOT this skill. Triggers on parallel tasks, dependency graph, task waves, wall-clock pressure, auto time-band switching, DAG scheduling.
---
# spec-tdd-task-dag
**REQUIRED BASE:** `spec-tdd-task-loop` — read it first; every rule there applies unchanged (the three-layer division of labor, the lightweight gate, the Phase 0 breakdown bootstrap, number recheck, mock-first, resume, disclosure, commit discipline). This skill is its **parallel overlay**: the task table upgrades from a serial queue to a dependency DAG, and tasks that are independent and file-disjoint run as parallel waves. No verification strength added or reduced — only wall-clock compressed (the wave-end union test run pays back what parallelism dropped, see below).
**`eco` inheritance (task-loop's Eco mode — `../spec-tdd-task-loop/references/eco-mode.md` — applies in full)**: per-card machinery all MID + a per-card TOP final audit (after the gate, before the merge) — parallel waves are eco's biggest beneficiary: **the wave's top-context ×N quota pressure disappears** (the wave's machinery is all MID; the per-card final audit is a short read-only TOP, running staggered as cards converge, never concurrent as a wave). The final audit converges **inside that card's worktree** (diff, XML, `REPORT.md` all use that worktree's paths; `FINAL-AUDIT.md` lands in that card's worktree scratch — the existing rule that SCRATCH ROOT takes the worktree root), and only after convergence does the card enter the wave-end merge; the wave-end union run and the closing procedure (v1.33.0 total-coverage pass + closing batch review) are unchanged (additive, not substitutes).
## When to Use (vs task-loop)
- Time-sensitive + the DAG has a genuinely parallel structure (not a chain) → this skill. Parallel multiplies **quota pressure (×N, cap 3) and top-level context overhead** at once (status-row traffic, wave management, per-sibling handling) — for a context-tight phase, serial is cheaper.
- Chain-shaped dependencies / few tasks / conservative in 429-prone hours / wanting the simplest machinery → `spec-tdd-task-loop`. **Serial is not the old behavior — it is the ×1-quota-pressure safe mode**: parallel multiplies token throughput by the concurrency; in trigger-prone hours (e.g. daytime peak) go one at a time, and run the DAG full-speed in off-peak (e.g. overnight) — the mode is a function of the time band in the first place. An announced absence (leaving/sleeping) during in-flight work ⇒ task-loop's going-dark gate runs first (batched consent + substrate choice).
**When NOT to use:**
- Parallel waves of a multi-unit bug batch (no task-loop substrate: no authoritative plan doc, no per-task commits) → `spec-tdd`'s **multi-unit** parallel waves.
## Board upgrade: the task table = a DAG
- Each row gains two columns: **depends-on** (empty = root) and **expected files** (produced by the Phase 0 breakdown together with the rest).
- Phase 0's fresh-context review thereby gains one more attack dimension: **dependency-edge correctness + the expected-files column's disjointness** — with the two field failure classes named (v1.38.0): **false-parallel** (a task doc names — in its cross-task-calls field, or in prose — a cross-task call its depends-on column lacks; an interface edge disjointness cannot see) and **false-serial** (a shared-file edge the single-writer re-cut could dissolve, accepted without the weigh).
- **Wave computation = topological grouping + the expected-files disjointness check.** Two tasks whose columns overlap never share a wave, even if logically independent — shared files = a serial chain (the tier layer's multi-unit wave rule, lifted). What disjointness excludes is **textual merge conflicts**; **semantic interference (zero shared files yet each changes the other's behavior) cannot be excluded by disjointness** — it is backstopped by the wave-end union run (next section). **The call-edge cross-read (v1.38.0; field 2026-11-02: two file-disjoint cards shared a wave and one could not compile — its new code calls the sibling's not-yet-merged new method): at wave computation, re-read every task doc's cross-task-calls field (the required Pre-flight 6 field, v1.38.1 — prose naming alone is a doc defect, not a declaration) against its depends-on column — a call the column lacks is an INTERFACE (compile-time) edge: neither a textual conflict nor behavior interference, invisible to disjointness; fix the column and serialize before dispatch.** The reverse guard: a shared-file serial edge is accepted only after the single-writer weigh ran (task-loop Phase 0) — merging or extracting the shared part may dissolve the edge and parallelize the pair; the weigh's outcome is disclosed either way.
## Pre-flight: the mode ask (after task-loop's asks, one more question)
Present the wave structure (e.g. "3 waves: [T01,T03] → [T02,T04,T05] → [T06]") with the phase's estimated wall-clock — serial ≈ the per-card estimates summed; parallel ≈ the longest wave's span + wave-end merge/union-run overhead, plus each cold worktree's first build (an interval while calibration is thin; never the budget — a kill cap per task-loop watchdog rule 4) — four options:
- **All-parallel** — recommended for off-peak hours; **all-serial** — behavior identical to task-loop, the safe choice in 429-prone hours;
- **Per-wave choice** — ask at every wave boundary, parallel or serial;
- **Auto time band** — you report the peak/off-peak bands once (e.g. "10:00–22:00 peak, run serial; otherwise parallel" — **the bands are your quota experience; the skill presets nothing**), then every wave boundary switches automatically by local time, each switch disclosed on the board. Switching takes effect at wave boundaries; **an in-flight wave is never killed mid-flight**.
A chain-shaped DAG (nothing parallelizable) → this ask is silently skipped. **Concurrency cap 3 (user-adjustable)**: at most 3 tasks running per wave (each task internally still has 2–3 nested dispatches, at most ≈9 agent streams); an overflowing wave rotates in batches.
**Pre-ruled mode rulings (v1.31.0).** Entry may arrive with pre-ruled unattended rulings aboard — a manager going-dark gate's batched rulings carried on the `<phase>` hand-off; task-loop's amended pre-flight (inherited via the REQUIRED BASE above) honors the asks it covers. For THIS ask: a pre-ruled mode answer counts as answered, never re-asked, disclosed on the board's opening rows — **auto time band only, and the peak/off-peak bands themselves must ride the hand-off** (the bands are the user's quota experience; this skill presets nothing); **per-wave choice cannot be pre-ruled** (it asks at every wave boundary — unanswerable while away). Rulings cover THIS absence only, never carrying over.
**Authorization coupling (task-loop pre-flight 2)**: without top-commit authorization → **parallel mode is unavailable, automatically degrading to all-serial** — the DAG's task commits are top-executed `git merge`s; there is no "pause and hand to the user for a manual commit" counterpart shape; the degradation is disclosed.
## Parallel wave execution (worktree isolation)
- **The wave-start tree must be clean, and verified, not assumed**: before cutting worktrees the top personally runs `git status` — non-scratch residue (untracked scratch excepted) → STOP; clean it first.
- Each parallel task: `git worktree add .claude/worktrees/<id> -b task-dag/<id>` (from the wave-start HEAD). **The location is load-bearing** (field 2026-11-28/29, AIDTM-1911: two consecutive implementers stalled at zero output — 40 min, then 5 h 20 min — blocked on the worktree permission prompt with nobody attending; the watchdog killed both as zombies): EnterWorktree opens prompt-free ONLY for a **managed worktree** — a path under the repo's `.claude/worktrees/` that a real `git worktree add` has registered (or when called with no path, letting the harness cut its own — not this skill's shape, the top cuts named task worktrees). Any model-chosen path elsewhere is a hard safety-check ask that no allow-rule covers, and a path that does not exist prompts too — the old `.spec-tdd/worktrees/<id>` convention sat outside the managed root, so every agent entry waited on a Yes nobody was there to press. The tier layer's worktree ban ("a worktree branches from HEAD; uncommitted work doesn't transfer") **does not hold here** — on a clean tree, HEAD is everything; this is a difference of premises between the two layers, not a relaxation.
- **Spawn shape — a card's dispatches are PLAIN, never `isolation:"worktree"`** (field AIDTM-1911): every dispatched agent that works the card (level-1, its nested implementer, the per-card final audit) is spawned WITHOUT the worktree-isolation flag, its brief's SCRATCH ROOT pointing at the task worktree, and the agent's first action on entry is `EnterWorktree(<task worktree path>)` — prompt-free against a live registered managed worktree (the location rule above). Spawning an isolation agent INTO a task worktree is double isolation — it wraps the task worktree in a stray `agent-*` worktree under `.claude/worktrees/` that someone must clean up, and the entry prompt is paid anyway.
- **Before every dispatch into a worktree — first cut, continuation, or resume — the top verifies the worktree is LIVE: present on disk AND registered in `git worktree list`** (the location rule's prompt-free premise is registered existence; a missing or unregistered path hands the agent the permission prompt, and an unattended prompt is a zero-output stall until the watchdog kills the card). A brief may only point at a worktree verified live at re-dispatch time — never at one a previous wave reclaimed.
- **Document authority lives in the real tree**: task docs and the plan doc are authoritative in the real tree (the dispatch prompt points at real-tree absolute paths, read-only); the worktree carries only production/test code and build outputs (**pure-docs tasks' deliverable documents excepted** — they ride the worktree and merge back into the real tree at wave end; the path-level check runs on the real tree after the merge). When a user decision made mid-wave is written back to the real tree and affects in-flight siblings → deliver by SendMessage (same as mid-run redirection); undeliverable → that task **re-verifies against the decisions section before its merge**.
- Level-1 works entirely inside the worktree (code work): RED → level-2 → GREEN → verification, XML numbers all in its own tree. Sub-agents stay git-write-banned; **creating/merging/cleaning worktrees is the top's exclusive duty**.
- The dispatch template is task-loop's verbatim, plus two lines: WAVE (siblings in flight: <ids> — expected-files columns are disjoint; touching their files is banned) and the ENTRY line — the agent's first action is `EnterWorktree(<task worktree path>)` (spawn plain, the spawn-shape rule above); **SCRATCH ROOT takes that task's worktree root** (cut by the top, absolute path known — level-1 lives in the worktree the whole way and the watchdog reads that tree too; wrongly filling the repo root wedges every card at the rev-parse gate, and the double fault of "repo root filled + agent staying in the real tree" silently reproduces the W22 stale-heartbeat shape).
- **Wave-end serial merges**: each branch in task-table order, `git merge --no-ff task-dag/<id>` — each merge commit = that task's commit boundary. A conflict (which should not happen under the disjointness rule) → STOP, hand to a human. **Board updates cannot ride the merge commit (the merge hash only exists after the merge) → right after the wave's last merge, one board commit** (status-section hashes, decisions section, mode-switch disclosures). **The rollback unit = the merge commit + the board commit after it, both reverted together** — reverting only the merge leaves a board claiming done.
- **The wave-end gate (after the merges, in the real tree)**: the existing lightweight gate (the two compile items + diff scope) **plus a fourth item, "the wave-union test run"** — the union of the wave's every task's related test classes, run once in the real tree (once per wave, still far cheaper than serial's once per task; **a pure-docs task's numbers item is replaced by the path-level check, as in task-loop gate item 5; testless tasks don't enter the union**). The top personally running this run is a named gate exception (the same nature as compile: new information, no existing XML to recheck; the same shape as the "re-running the full suite is a diagnostic exception" rule), evidence = that run's XML numbers — compressed output (`-q --console=plain`, the XML is the evidence, never the full dump in context). The union run itself is the wave's final run; the XML-coverage trap does not apply to it.
- **Findings convergence per card — task-loop's findings loop, made explicit for waves (v1.35.0; field 2026-11-02: two cards ran a full SECOND level-1 chain for fixable findings — ~3.5–4× a clean card's cost — because this layer never restated the rule its REQUIRED BASE carries).** Findings from any round (encoding audit, fresh review, per-card final audit) hand back by **SendMessage into the SAME chain** — the level-1 fixes, its own auditor re-checks the delta; a fresh second level-1 chain for fixable findings is banned. The only re-dispatch exception is **spec-level findings** (they invalidate the task doc itself — wrong contract, broken disjointness, acceptance-test design wrong): those reopen the task doc (write-back first) and may re-dispatch — a task whose doc is invalidated TWICE stops the loop: the second invalidation escalates to the user (the doc itself is the defect; I9's breaker shape — per audit v1.37.0). **The audit ledger is per-task and inherited across chains**: a continuation or second chain resumes the same audit history — a fresh same-kind auditor dispatch counts as round two; the same kind caps at TWO rounds per task across its whole life (user-adjustable at dispatch); still red at the cap → close done-with-findings, the findings go to the board, disposal rides the closing procedure (total-coverage pass) or the user — never a third round.
- **Seam-dispatch default (v1.38.0; field 2026-11-02: a dependent card's dispatch was gated on its upstream's final-audit verdict though the upstream had already merged — the gate moved only when the user asked "can't T5 run parallel?", translated from the original).** A dependency edge gates on the upstream's MERGE — the seam being in the dependent's cut base means it compiles — never as an EXTRA audit-verdict dispatch gate. Under eco the close order (gate → final audit → merge) makes the merge moment carry the verdict anyway; an order slip that merges ahead of the audit (a disclosed deviation) does not reopen the question: the dependent dispatches on the merge, and the wrong-seam protection moves to the dependent's own MERGE time (a merge-time seam re-verification; the upstream's verdict gates the upstream's own row, not the dependent's dispatch). **In a slip, the dependent's MERGE additionally waits for the upstream's still-pending verdict (per audit v1.38.0, restoring the field resolution's second half): a dependent that converged against a seam the verdict then corrects must not merge first — the wave-end union run is the backstop, not the gate.**
- **At wave end, re-verify the anchors of ALL next-wave task docs at once** (re-anchored by method name) — a wave lands many tasks simultaneously; drift is larger than serial's.
- Worktree reclamation: branches all merged, residue only scratch/build → `git worktree remove --force` + delete the branch (level-1 always leaves scratch and build outputs, so a clean remove is always refused; on Windows there are also gradle daemon file locks). **After reclamation the registration is gone — every kept brief pointing at that path is a dead brief** (Common Mistakes). `.claude/worktrees/` is the harness's managed root, and it sweeps unregistered leftovers there (the `agent-*` residue of isolation spawns; observed, exact sweep timing not verified) — a registered live worktree held for resume is git-tracked state, not an orphan, and should not be swept; should one ever disappear, the branch (`task-dag/<id>`) survives and the same-path `git worktree add` rebuilds it.
- **The regression wall**: wave N's worktree is cut from the merged wave N−1 HEAD → the template's "one run covering all related test classes" per task verifies **all previous waves'** tests; cross-green **among same-wave siblings** is backstopped by the wave-end union run (semantic interference cannot be excluded by file disjointness). Union run all green → no residue.
- **The right-sized tail (v1.37.0, user ruling 2026-11-02): at a wave boundary, remaining ≤2 cards each single-dispatch-scale (task-loop Phase 0's definition) → the tail downgrades to in-session standard by DEFAULT** (one-line announcement + board disclosure; the user's veto at the announcement stands, I12): the top runs the remaining units itself per spec-tdd's multi-unit shape — per-unit RED test → encoding audit → implementer dispatch → verify, in the real tree (no new worktrees, no wave machinery; verification strength is the standard tier's own: TOP encoding audit per unit, stronger per-unit than eco's all-MID + TOP final audit). The closing procedure (total-coverage pass + closing batch review) still runs unchanged over the whole phase; a tail unit that skips any task-doc-mandated verification books re-test debt per the existing ledger; a pulled-out-stakes card never takes the downgrade — it runs the normal card machinery.
- **The closing procedure** (task-loop's, inherited in full — the v1.33.0 **total-coverage pass first, then the closing batch review**) runs in the real tree **after all waves are merged and the table is all-done** — wave boundaries don't trigger it (what it looks at is exactly the whole phase's accumulated effect, not one wave). The pass's full-suite run subsumes no wave machinery: the per-wave union runs stay (the per-wave semantic-interference backstop), the pass is the phase-wide coverage checkpoint over all deliverables — different objects, both mandatory. Its fix rows enter the DAG as usual: **depends-on and expected-files columns must be filled** (empty = root); the convergence re-round is scoped to the fix rows' diffs.
- **Watchdog signal paths and output axes live inside the worktree**: level-1 stays in the worktree the whole way — heartbeat / POLICY files, tree diff (vs the wave-start HEAD), build/test outputs all read **that worktree's** paths (the worktree was cut by the top; the absolute path is known) — reading the real tree's counterpart paths is forever stale, and every parallel card past its threshold would false-alarm. Checkpoints: **one recurring ring serves all in-flight** (one schedule per run, never per card — the top's context economics under ×N parallelism; re-verified create-if-missing at every wave dispatch, v1.32.1); a zombie inside a worktree → the revival attempt and the continuation re-dispatch take over in that same worktree, paths unchanged. **A cold worktree's first build is cold** (no daemon cache) — a parallel task's budget must count the cold build, or it overruns the moment it starts. **Build-cache check (per audit v1.37.0):** a machine-level shared Gradle build cache (`org.gradle.caching=true` in the user home's gradle.properties) lets a worktree's first build warm from it — check once per machine and count accordingly; **enabling it is the USER's machine-level call** (never silently edit their gradle.properties — ask once); a project that disables the cache for build reproducibility keeps cold builds — say so in the mode announcement.
- **The recurring ring and the freeze SOP (inheriting task-loop watchdog rules 1–2 and the 429/recovery machinery — task-loop's `../spec-tdd-task-loop/references/recovery-and-resume.md`; the v1.32.1 recurring substrate included; only the wave-shape delta recorded here)**: parallel already multiplies quota pressure (×N, cap 3) — the ring's post-recovery landings and the freeze procedure are the normal path in dag, not a corner. The ring is re-verified create-if-missing at every wave dispatch; **a freeze freezes wave boundaries too** — wave dispatches falling due during the freeze are deferred; the first successful turn (the ring's first post-recovery landing, or a manual message) collects first (sibling cards completed during the freeze, waves due but not dispatched, board reconciliation) before judging and scheduling waves; the freeze deduction applies **per card** — sibling cards on different pools running while the top is frozen is the norm in dag; collect-before-judge is worth more here than in serial. **The reset+15 insurance arms durable in unattended windows and the going-dark gate applies to any announced absence — overnight waves are this skill's own recommendation, so the gate is not optional here.**
## Resume (a wave interrupted)
- The board's in-flight may be **a whole wave**: each worktree resumes independently — a 429 killing one doesn't touch the siblings (SendMessage resumes that agent; the worktree's state is the inventory result); one dying before its merge → the branch is kept, waiting for recovery to continue; one dying after its merge → identical to task-loop's single-task resume.
- One agent in a wave dying of 429 with little remaining work → task-loop's rule: wait for reset and SendMessage-resume the same agent, or immediately re-dispatch a continuation agent taking over that worktree (the continuation brief re-points at the same worktree, re-verified live first — the dispatch-time live check above); **the top finishing the work by hand is equally hard-banned here** — the worktree's state is a ready-made inventory metric; even what changed is in the branch diff. The wave's other tasks are unaffected: no waiting, and no killing siblings.
- Mode switches (per-wave / auto time band) take effect at wave boundaries; an in-flight wave is never killed mid-flight; task-loop's mid-run redirection conventions apply, disclosed on the board.
## Common Mistakes (delta)
| Mistake | Fix |
|---|---|
| Putting two tasks with overlapping expected-files columns in one wave | Wave membership = topologically independent + file-column disjoint, both required; shared files → a serial chain. |
| Forcing all-parallel in 429-prone hours | Serial = ×1 quota pressure; parallel ×N (cap 3). The mode should follow the time band — the auto-band mode exists for exactly this. |
| Trusting the in-worktree green, skipping the wave-end gate (incl. the union run) | File disjointness excludes only textual conflicts; semantic interference is backstopped by the wave-end union run — it is a mandatory gate item, not optional. |
| A sub-agent touching git inside the worktree | The ban is unchanged; worktree create/merge/clean is the top's exclusive duty. |
| A sibling in the wave dying and the top absorbing its remaining work | Hard ban (task-loop's rule inherited) — re-dispatch a continuation agent to take that worktree; the wave's other tasks are unaffected: no waiting, no killing. |
| Reverting the merge commit but leaving the board commit after it | The rollback unit = merge commit + board commit, both together; a board claiming done while the code is rolled back = the status section lying. |
| Forcing parallel on without commit authorization | Parallel mode is unavailable; automatically degrades to all-serial, disclosed — the DAG's commits are the top's merges; there is no manual path. |
| Treating the worktree's copy of a task doc as the authoritative version | Document authority lives in the real tree (dispatch points at real-tree paths, read-only); mid-wave decisions delivered by SendMessage, undeliverable → re-verified before the merge. |
| Under eco, the final audit reading real-tree paths (the card hasn't merged; the real tree doesn't hold its output) | The final audit converges inside that card's worktree: diff, XML, `REPORT.md`, `FINAL-AUDIT.md` all use worktree paths; what only exists after the merge is not its review object. |
| A card's findings round dispatched as a fresh second level-1 chain | SendMessage resumes the SAME chain to fix (keep, don't rewrite); a fresh chain only for spec-level findings — and it inherits the card's audit ledger: the same audit kind caps at two rounds per task (field 2026-11-02: fixable findings burned a full second chain, ~4× a clean card). |
| Cutting a full worktree wave for one or two small remaining cards | The right-sized tail (v1.37.0): at a wave boundary, ≤2 single-dispatch-scale cards downgrade to in-session standard by default — announce + disclose, veto stands, pulled-out stakes excluded; wave machinery doesn't amortize on the tail. |
| Two file-disjoint cards share a wave; one cannot compile against the other's absence | The call-edge cross-read (v1.38.0): re-read every task doc's cross-task-calls field (the Pre-flight 6 input, v1.38.1) against its depends-on column at wave computation; a call the column lacks = an interface edge — fix the column, serialize (field 2026-11-02: the sweep card called the adoption card's not-yet-merged service). |
| A dependent card held un-dispatched behind its upstream's audit verdict | Seam-dispatch default (v1.38.0): the edge gates on the upstream's merge; an audit verdict never adds a dispatch gate — wrong-seam protection lives at the dependent's own merge (field 2026-11-02: the endpoint card waited on a verdict gate until the user asked "can't this run parallel?" — translated from the original). |
| Re-firing a card from a kept brief whose worktree the wave already reclaimed | Dead brief → dead path: the worktree permission prompt with nobody attending (the prompt-free premise is a live registered managed worktree), then ENOENT when someone finally answers — the AIDTM-1911 stall shape (two consecutive implementers, zero output 40 min then 5 h 20 min, watchdog-killed as zombies). Re-dispatch only onto a worktree verified live + registered at re-dispatch time; after reclamation, continuing the card is the top's fresh decision (re-cut or in-session per the rules), never a stale-brief replay. |
| Spawning a card's agent with `isolation:"worktree"` pointed at the task worktree | Double isolation: the agent's own isolation worktree wraps the task worktree, a stray `agent-*` worktree is left behind in `.claude/worktrees/`, and the entry prompt is paid anyway. Spawn plain; the agent enters via EnterWorktree (the spawn-shape rule above). |
## Red Flags — STOP (delta)
- The same file appearing in two same-wave tasks' diffs → the disjointness claim is bankrupt; STOP; move that task out of the wave and reschedule serially.
- Non-scratch residue in `git status` before cutting worktrees → STOP; clean it before cutting (a clean wave-start tree is a premise, not an assumption).
- Any red in the wave-end union run → STOP and diagnose (semantic interference actually happened); no board commit before all green.
- An auto-band switch not disclosed on the board → add the disclosure; switch records belong to the phase report.