1
---
2
name: subagent-driven-development
3
description: Use when executing implementation plans with independent tasks in the current session
4
---
5
6
# Subagent-Driven Development
7
8
Execute plan by dispatching a fresh implementer subagent per task, a task review (spec compliance + code quality) after each, and a broad whole-branch review at the end.
9
10
**Why subagents:** You delegate tasks to specialized agents with isolated context. By precisely crafting their instructions and context, you ensure they stay focused and succeed at their task. They should never inherit your session's context or history — you construct exactly what they need. This also preserves your own context for coordination work.
11
12
**Core principle:** Fresh subagent per task + task review (spec + quality) + broad final review = high quality, fast iteration
13
14
**Narration:** between tool calls, narrate at most one short line — the
15
ledger and the tool results carry the record.
16
17
**Continuous execution:** Do not pause to check in with your human partner between tasks. Execute all tasks from the plan without stopping. The only reasons to stop are the four named below, or all tasks complete. "Should I continue?" prompts and progress summaries waste their time — they asked you to execute the plan, so execute it.
18
19
**Rulings, not stalls.** A running plan does not wait on a human. Conflicts,
20
ambiguities, plan defects, a cap you would have asked to exceed — decide
21
them. The spec is the binding authority, the plan is its argument, and your
22
judgment settles what neither answers. Record every decision in the ledger as
23
`Ruling: <what you decided> — <why> — <what it costs if wrong>`, and keep
24
going. A wrong ruling costs rework your human partner can see and undo; a
25
session parked on a question costs their whole day and buys nothing.
26
27
Four things stop you, and only these: an irreversible or destructive
28
operation; a security-sensitive action; a side effect outside this worktree
29
that norms say you ask about first (a merge, a push to a shared branch, a
30
publish); and a plan so broken that every path forward is a guess. For those,
31
stop and ask.
32
33
## When to Use
34
35
```dot
36
digraph when_to_use {
37
"Have implementation plan?" [shape=diamond];
38
"Tasks mostly independent?" [shape=diamond];
39
"Partner chose inline, or no subagent tool?" [shape=diamond];
40
"subagent-driven-development" [shape=box];
41
"executing-plans" [shape=box];
42
"Manual execution or brainstorm first" [shape=box];
43
44
"Have implementation plan?" -> "Tasks mostly independent?" [label="yes"];
45
"Have implementation plan?" -> "Manual execution or brainstorm first" [label="no"];
46
"Tasks mostly independent?" -> "Partner chose inline, or no subagent tool?" [label="yes"];
47
"Tasks mostly independent?" -> "Manual execution or brainstorm first" [label="no - tightly coupled"];
48
"Partner chose inline, or no subagent tool?" -> "executing-plans" [label="yes"];
49
"Partner chose inline, or no subagent tool?" -> "subagent-driven-development" [label="no"];
50
}
51
```
52
53
**vs. Executing Plans (inline):**
54
- Fresh subagent per task (no context pollution) instead of one context doing every task
55
- Review after each task (spec compliance + code quality) instead of only at the end
56
- Costs a fresh context per task and per review; inline costs one context plus one final reviewer
57
- Both run in this session, share the same plan workspace and ledger, and never pause between tasks
58
59
## The Process
60
61
```dot
62
digraph process {
63
rankdir=TB;
64
65
subgraph cluster_per_task {
66
label="Per Task";
67
"Dispatch implementer subagent (./implementer-prompt.md)" [shape=box];
68
"Implementer asks questions?" [shape=diamond];
69
"Answer questions, provide context" [shape=box];
70
"Implementer implements, tests, commits, self-reviews" [shape=box];
71
"Generate review package, dispatch task reviewer (./task-reviewer-prompt.md)" [shape=box];
72
"Spec ✅ and quality approved?" [shape=diamond];
73
"Fix loop: read references/fix-loop.md before every round" [shape=box];
74
"Append completion to ledger, mark todo complete" [shape=box];
75
}
76
77
"Setup: worktree, ledger check, read plan, pre-flight review" [shape=box];
78
"More tasks remain?" [shape=diamond];
79
"Final review and finish: read references/final-review.md" [shape=box];
80
"Final review clean: delete this plan's workspace" [shape=box];
81
"Use superpowers:finishing-a-development-branch" [shape=box style=filled fillcolor=lightgreen];
82
83
"Setup: worktree, ledger check, read plan, pre-flight review" -> "Dispatch implementer subagent (./implementer-prompt.md)";
84
"Dispatch implementer subagent (./implementer-prompt.md)" -> "Implementer asks questions?";
85
"Implementer asks questions?" -> "Answer questions, provide context" [label="yes"];
86
"Answer questions, provide context" -> "Implementer implements, tests, commits, self-reviews";
87
"Implementer asks questions?" -> "Implementer implements, tests, commits, self-reviews" [label="no"];
88
"Implementer implements, tests, commits, self-reviews" -> "Generate review package, dispatch task reviewer (./task-reviewer-prompt.md)";
89
"Generate review package, dispatch task reviewer (./task-reviewer-prompt.md)" -> "Spec ✅ and quality approved?";
90
"Spec ✅ and quality approved?" -> "Append completion to ledger, mark todo complete" [label="yes"];
91
"Spec ✅ and quality approved?" -> "Fix loop: read references/fix-loop.md before every round" [label="no"];
92
"Fix loop: read references/fix-loop.md before every round" -> "Append completion to ledger, mark todo complete" [label="addressed, or parked at the cap"];
93
"Append completion to ledger, mark todo complete" -> "More tasks remain?";
94
"More tasks remain?" -> "Dispatch implementer subagent (./implementer-prompt.md)" [label="yes"];
95
"More tasks remain?" -> "Final review and finish: read references/final-review.md" [label="no"];
96
"Final review and finish: read references/final-review.md" -> "Final review clean: delete this plan's workspace";
97
"Final review clean: delete this plan's workspace" -> "Use superpowers:finishing-a-development-branch";
98
}
99
```
100
101
## Setup
102
103
Ensure the work happens in an isolated workspace: use
104
superpowers:using-git-worktrees to create one or verify the existing one.
105
Never start implementation on a main/master branch without your human
106
partner's explicit consent.
107
108
Conversation memory does not survive compaction. In real sessions,
109
controllers that lost their place have re-dispatched entire completed task
110
sequences — the single most expensive failure observed. Track progress in
111
a ledger file, not only in todos.
112
113
- Each plan owns a workspace: at skill start, run this skill's
114
`bash scripts/sdd-workspace PLAN_FILE` by its absolute path, from the
115
working tree you're executing in — it prints the plan's git-ignored
116
directory (under `<repo-root>/.superpowers/sdd/`), home to
117
every artifact for THIS plan: ledger, briefs, reports, review packages.
118
Another plan's directory is never yours to read or write.
119
- Check for this plan's ledger at `<workspace>/progress.md`. If one exists,
120
read [references/resuming.md](references/resuming.md) before anything
121
else: it says whose ledger it is and where to resume.
122
- Create the ledger with its identity as the first line:
123
`# SDD ledger — plan: <plan file path>`.
124
- The ledger is your recovery map: the commits it names exist in git even
125
when your context no longer remembers creating them. After compaction,
126
trust the ledger and `git log` over your own recollection.
127
- `git clean -fdx` will destroy the workspace (it's git-ignored scratch); if
128
that happens, recover from `git log`.
129
130
Read the plan once, note its context and Global Constraints, and create a
131
todo per task. If the plan names a Spec, read that too: the spec is the
132
authority the plan argues from, and conflicts inside the plan resolve
133
against it. A plan with no reachable spec gets a ledger note saying so —
134
rulings made without one are provisional.
135
136
Before dispatching Task 1, read [references/preflight.md](references/preflight.md)
137
and run the conflict scan it describes. Its table and rulings go in the
138
ledger.
139
140
## Model Selection
141
142
Use the least powerful model that can handle each role to conserve cost and increase speed.
143
144
**Mechanical implementation tasks** (isolated functions, clear specs, 1-2 files): use a fast, cheap model. Most implementation tasks are mechanical when the plan is well-specified.
145
146
**Integration and judgment tasks** (multi-file coordination, pattern matching, debugging): use a standard model.
147
148
**Architecture and design tasks**: use the most capable available model.
149
The final whole-branch review is one of these — dispatch it on the most
150
capable available model, not the session default.
151
152
**Review tasks**: choose the model with the same judgment, scaled to the
153
diff's size, complexity, and risk. A small mechanical diff does not need the
154
most capable model; a subtle concurrency change does. Scoped re-reviews of
155
small fix diffs take a cheap-to-mid tier.
156
157
**Fix-loop escalation (rounds 4-5)**: use a model at least one tier above
158
the implementer that got stuck.
159
160
**Always specify the model explicitly when dispatching a subagent.** An
161
omitted model inherits your session's model — often the most capable and
162
most expensive — which silently defeats this section.
163
164
**Turn count beats token price.** Wall-clock and context cost scale with how
165
many turns a subagent takes, and the cheapest models routinely take 2-3× the
166
turns on multi-step work — costing more overall. Use a mid-tier model as the
167
floor for reviewers and for implementers working from prose descriptions.
168
When the task's plan text contains the complete code to write, the
169
implementation is transcription plus testing: use the cheapest tier for
170
that implementer. Single-file mechanical fixes also take the cheapest tier.
171
172
**Task complexity signals (implementation tasks):**
173
- Touches 1-2 files with a complete spec → cheap model
174
- Touches multiple files with integration concerns → standard model
175
- Requires design judgment or broad codebase understanding → most capable model
176
177
## The Task Loop
178
179
**Small same-shape work:** when the plan lists several small edits of the
180
same kind across files, read [references/batching.md](references/batching.md)
181
before dispatching them.
182
183
Everything you paste into a dispatch prompt — and everything a subagent
184
prints back — stays resident in your context for the rest of the session
185
and is re-read on every later turn. Hand artifacts over as files.
186
187
**Waiting on dispatched subagents:** never poll a wait interface with
188
short timeouts, and never sit in one silent, open-ended wait either.
189
While you have local work — ledger updates, packaging the next review,
190
reading reports — keep working; child results arrive on their own.
191
When you are genuinely idle, wait in bounded stretches (five to ten
192
minutes, where your platform allows), and between stretches post one
193
line of status and reconcile your live children: list them, and chase
194
any that finished without reporting. A bounded stretch keeps nearly
195
all of a long wait's efficiency while guaranteeing a stuck or lost
196
child is noticed within minutes, not at the end of the session.
197
198
### 1. Dispatch the implementer
199
200
Record BASE (`git rev-parse HEAD`) before dispatching — the review package
201
and fix-round diffs need it.
202
203
- **Task brief:** before dispatching an implementer, run this skill's
204
`bash scripts/task-brief PLAN_FILE N` by its absolute path, from the
205
working tree you're executing in — it extracts the task's full text to a
206
uniquely named file and prints the path. Compose the dispatch so the
207
brief stays the single source of
208
requirements. Your dispatch should contain: (1) one line on where this
209
task fits in the project; (2) the brief path, introduced as "read this
210
first — it is your requirements, with the exact values to use verbatim";
211
(3) interfaces and decisions from earlier tasks that the brief cannot
212
know; (4) your resolution of any ambiguity you noticed in the brief;
213
(5) the report-file path and report contract. Exact values (numbers,
214
magic strings, signatures, test cases) appear only in the brief. Never
215
make a subagent read the whole plan file.
216
- **Report file:** name the implementer's report file after the brief
217
(brief `…/task-N-brief.md` → report `…/task-N-report.md`) and put it in
218
the dispatch prompt. The implementer writes the full report there and
219
returns only status, commits, a one-line test summary, and concerns.
220
- A dispatch prompt describes one task, not the session's history. Do not
221
paste accumulated prior-task summaries ("state after Tasks 1-3") into
222
later dispatches — a real session's dispatch hit 42k chars of which 99%
223
was pasted history. A fresh subagent needs its task, the interfaces it
224
touches, and the global constraints. Nothing else.
225
- The dispatch carries the no-subagents contract (it is in the
226
implementer template): the implementer never dispatches subagents —
227
not helpers, and never a reviewer. Review arrives from you, after the
228
report. In real sessions, every reviewer a worker spawned duplicated
229
the task review the controller dispatched anyway — a full extra
230
review seat per task.
231
- If an earlier task parked a finding in the area this task touches, carry
232
a pointer to that ledger entry in the dispatch.
233
- Record the implementer's agent identity from the dispatch result —
234
fix-loop rounds 1-3 resume this agent.
235
- Never dispatch multiple implementation subagents in parallel (conflicts).
236
237
Template: [implementer-prompt.md](implementer-prompt.md)
238
239
### 2. Handle the report
240
241
Implementer subagents report one of four statuses. Handle each appropriately:
242
243
**DONE:** Generate the review package (`bash scripts/review-package PLAN_FILE BASE HEAD` by its absolute path, from the working tree you're executing in — it prints the unique file path it wrote; BASE is the commit you recorded before dispatching the implementer — never `HEAD~1`, which silently drops all but the last commit of a multi-commit task), then dispatch the task reviewer with the printed path.
244
245
**Any other status** (DONE_WITH_CONCERNS, NEEDS_CONTEXT, BLOCKED): read
246
[references/handling-reports.md](references/handling-reports.md) and follow
247
it, every time you get one.
248
249
If the implementer asks questions — before starting or mid-task — answer
250
clearly and completely, provide additional context if needed, and don't
251
rush it into implementation.
252
253
### 3. Review the task
254
255
Per-task reviews are task-scoped gates. The broad review happens once, at the
256
final whole-branch review. Never skip the task review, and never accept a
257
report missing either verdict — spec compliance AND task quality are both
258
required. Implementer self-review never replaces the task review; both are
259
needed.
260
261
- Hand the reviewer its diff as a file: run this skill's
262
`bash scripts/review-package PLAN_FILE BASE HEAD` by its absolute path, from
263
the working tree you're executing in, and pass the reviewer the file path
264
it prints (or, without bash: `git log --oneline`, `git diff --stat`,
265
and `git diff -U10` for the range, redirected to one uniquely named
266
file). The output never enters your own context, and the reviewer sees
267
the commit list, stat summary, and full diff with context in one Read
268
call. Use the BASE you recorded before dispatching the implementer —
269
never `HEAD~1`, which silently truncates multi-commit tasks. Never
270
dispatch a task reviewer without a diff file.
271
- **Reviewer inputs:** the task reviewer gets three paths — the same brief
272
file, the report file, and the review package — plus the global
273
constraints that bind the task.
274
- The global-constraints block you hand the reviewer is its attention
275
lens. Copy the binding requirements verbatim from the plan's Global
276
Constraints section or the spec: exact values, exact formats, and the
277
stated relationships between components ("same layout as X", "matches
278
Y"). The reviewer's template already carries the process rules (YAGNI,
279
test hygiene, review method) — the constraints block is for what THIS
280
project's spec demands.
281
- Do not add open-ended directives like "check all uses" or "run race tests
282
if useful" without a concrete, task-specific reason
283
- Do not ask a reviewer to re-run tests the implementer already ran on the
284
same code — the implementer's report carries the test evidence
285
- Do not pre-judge findings for the reviewer — never instruct a reviewer to
286
ignore or not flag a specific issue. If you believe a finding would be a
287
false positive, let the reviewer raise it and adjudicate it in the review
288
loop. If the prompt you are writing contains "do not flag," "don't treat X
289
as a defect," "at most Minor," or "the plan chose" — stop: you are
290
pre-judging, usually to spare yourself a review loop.
291
If the reviewer reports "⚠️ Cannot verify from diff" items, read
292
[references/cannot-verify.md](references/cannot-verify.md) before you mark
293
the task complete.
294
295
Template: [task-reviewer-prompt.md](task-reviewer-prompt.md)
296
297
### 4. The fix loop
298
299
The loop triggers when the review reports spec ❌, any Critical or Important
300
finding, or a ⚠️ item you confirmed as a real gap.
301
302
When it triggers, read [references/fix-loop.md](references/fix-loop.md) and
303
follow it. Read it again before every round, even if you read it earlier in
304
this session: it holds the round cap, the breaker, and the ledger line each
305
round writes, and your memory of it does not survive compaction.
306
307
### 5. Complete the task
308
309
When the review comes back clean — or every open finding is parked with a
310
ruling at the cap — append the completion line to the ledger in the same
311
message as your other bookkeeping:
312
313
- `Task <N>: complete (commits <base7>..<head7>, review clean)`
314
- `Task <N>: complete (commits <base7>..<head7>, <K> parked)` after a
315
tripped breaker
316
317
Then mark the todo complete and move on. Never move to the next task while
318
the review has open Critical/Important issues that are neither fixed nor
319
parked-with-ruling at the cap.
320
321
## Final Review
322
323
When every task is complete, read
324
[references/final-review.md](references/final-review.md) and follow it. It
325
covers the whole-branch review, its single fix wave, and how you finish.
326
327
## Common Rationalizations
328
329
| Excuse | Reality |
330
|--------|---------|
331
| "Close enough on spec compliance" | Reviewer found spec gaps = not done. Fix or hit the cap and adjudicate — those are the only exits. |
332
| "I'll fix it myself, dispatching is overhead" | Controller fixes pollute your context and skip review. Resume the implementer. |
333
| "One more round will converge" | Past the cap, rounds don't converge — the failure is structural. Adjudicate and route. |
334
| "The reviewer will just find something new anyway" | Scoped re-reviews verify fixes; they cannot wander. New findings on untouched code go to the ledger, not the loop. |
335
| "This finding is obviously wrong, I'll drop it" | You adjudicate only at the cap, and every ruling is a ledger entry. Silent discards are forbidden. |
336
| "The fix was small, skip the re-review" | Unreviewed fixes are how regressions land. Every round ends with a scoped re-review. |
337
| "Reviews slow the loop down" | The loop without reviews is just unverified churn. Reviews are the loop's brakes and steering. |
338
| "Ledger bookkeeping is overhead" | The ledger is what survives compaction. Controllers without one have re-dispatched entire completed task sequences. |
339
| "The implementer spawned its own reviewer — free extra assurance" | It's a duplicate seat reviewing the same diff; the task review is the gate. A worker-spawned reviewer is a defect to flag, not rigor. |
340