opencode-thrum-pro 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/assets/commands/thrum-_deviations-protocol.md +87 -0
  2. package/assets/commands/thrum-_generator-idempotency-protocol.md +15 -0
  3. package/assets/commands/thrum-_project-rules-protocol.md +18 -0
  4. package/assets/commands/thrum-_snapshot-protocol.md +265 -0
  5. package/assets/commands/thrum-_stamp-protocol.md +112 -0
  6. package/assets/commands/thrum-_verify-before-write-protocol.md +27 -0
  7. package/assets/commands/thrum-inbox.md +22 -0
  8. package/assets/commands/thrum-load-context.md +17 -0
  9. package/assets/commands/thrum-overview.md +17 -0
  10. package/assets/commands/thrum-prime.md +30 -0
  11. package/assets/commands/thrum-quickstart.md +14 -0
  12. package/assets/commands/thrum-reply.md +28 -0
  13. package/assets/commands/thrum-restart-extended.md +195 -0
  14. package/assets/commands/thrum-restart.md +293 -0
  15. package/assets/commands/thrum-send.md +31 -0
  16. package/assets/commands/thrum-sleep-extended.md +186 -0
  17. package/assets/commands/thrum-sleep.md +212 -0
  18. package/assets/commands/thrum-team.md +12 -0
  19. package/assets/commands/thrum-update-project.md +259 -0
  20. package/assets/commands/thrum-wait.md +14 -0
  21. package/assets/skills/adversarial-critique/SKILL.md +242 -0
  22. package/assets/skills/brainstorm-queue-aware/SKILL.md +167 -0
  23. package/assets/skills/brainstorm-steward/SKILL.md +181 -0
  24. package/assets/skills/choosing-subagent-models/SKILL.md +244 -0
  25. package/assets/skills/closing-findings-while-warm/SKILL.md +104 -0
  26. package/assets/skills/configure-roles/SKILL.md +229 -0
  27. package/assets/skills/coordinator-assessing-agent-completion/SKILL.md +205 -0
  28. package/assets/skills/coordinator-assessing-agent-completion/scan.py +117 -0
  29. package/assets/skills/coordinator-branch-split-on-block/SKILL.md +168 -0
  30. package/assets/skills/coordinator-context-monitoring/SKILL.md +674 -0
  31. package/assets/skills/coordinator-dispatching-work/SKILL.md +288 -0
  32. package/assets/skills/coordinator-hotpath-merge-gate/SKILL.md +522 -0
  33. package/assets/skills/coordinator-interacting-with-the-owner/SKILL.md +171 -0
  34. package/assets/skills/coordinator-maintaining-memory/SKILL.md +89 -0
  35. package/assets/skills/coordinator-managing-state-and-lifecycle/SKILL.md +192 -0
  36. package/assets/skills/coordinator-merging-code/SKILL.md +331 -0
  37. package/assets/skills/coordinator-philosophy-merge-gate/SKILL.md +442 -0
  38. package/assets/skills/coordinator-plan-reconcile-gate/SKILL.md +198 -0
  39. package/assets/skills/coordinator-post-restart-sweep/SKILL.md +135 -0
  40. package/assets/skills/coordinator-running-autonomous-feature-development/SKILL.md +199 -0
  41. package/assets/skills/coordinator-running-brainstorm-cycles/SKILL.md +654 -0
  42. package/assets/skills/coordinator-running-review-cycles/SKILL.md +153 -0
  43. package/assets/skills/coordinator-single-responsibility-merge-gate/SKILL.md +14 -0
  44. package/assets/skills/diagnosing-fleet-and-daemon/SKILL.md +255 -0
  45. package/assets/skills/efficient-multi-agent-research/SKILL.md +177 -0
  46. package/assets/skills/fixing-documentation-errors/SKILL.md +258 -0
  47. package/assets/skills/implementer-maintaining-memory/SKILL.md +84 -0
  48. package/assets/skills/implementer-orchestrating-execution/SKILL.md +125 -0
  49. package/assets/skills/implementer-receiving-dispatch/SKILL.md +127 -0
  50. package/assets/skills/implementer-receiving-review-feedback/SKILL.md +125 -0
  51. package/assets/skills/implementer-status-and-handoff/SKILL.md +150 -0
  52. package/assets/skills/implementer-tdd-and-quality/SKILL.md +99 -0
  53. package/assets/skills/memory-audit-recover/SKILL.md +153 -0
  54. package/assets/skills/memory-curate/SKILL.md +139 -0
  55. package/assets/skills/memory-maintenance/SKILL.md +87 -0
  56. package/assets/skills/memory-read-discipline/SKILL.md +164 -0
  57. package/assets/skills/memory-search-advanced/SKILL.md +217 -0
  58. package/assets/skills/memory-write-discipline/SKILL.md +135 -0
  59. package/assets/skills/orchestrate/SKILL.md +795 -0
  60. package/assets/skills/persistent-watcher-archetype/SKILL.md +225 -0
  61. package/assets/skills/prime-agent/SKILL.md +92 -0
  62. package/assets/skills/project-hotpath-gate/SKILL.md +255 -0
  63. package/assets/skills/project-philosophy/SKILL.md +418 -0
  64. package/assets/skills/project-philosophy/resources/philosophy-template.md +155 -0
  65. package/assets/skills/project-philosophy/resources/reliability-class-library.md +653 -0
  66. package/assets/skills/project-setup/SKILL.md +1007 -0
  67. package/assets/skills/project-setup/resources/implementation-agent.md +826 -0
  68. package/assets/skills/researcher-answering-queries/SKILL.md +100 -0
  69. package/assets/skills/researcher-investigating/SKILL.md +152 -0
  70. package/assets/skills/researcher-maintaining-memory/SKILL.md +176 -0
  71. package/assets/skills/state-migration/SKILL.md +54 -0
  72. package/assets/skills/thrum/SKILL.md +161 -0
  73. package/assets/skills/thrum/resources/ANTI_PATTERNS.md +132 -0
  74. package/assets/skills/thrum/resources/BOUNDARIES.md +56 -0
  75. package/assets/skills/thrum/resources/CLI_REFERENCE.md +1066 -0
  76. package/assets/skills/thrum/resources/IDENTITY.md +49 -0
  77. package/assets/skills/thrum/resources/LISTENER_PATTERN.md +64 -0
  78. package/assets/skills/thrum/resources/MESSAGING.md +163 -0
  79. package/assets/skills/thrum/resources/TMUX_SESSIONS.md +118 -0
  80. package/assets/skills/thrum/resources/WORKTREES.md +117 -0
  81. package/assets/skills/thrum-memory/SKILL.md +138 -0
  82. package/assets/skills/trace-spec-to-plan/SKILL.md +104 -0
  83. package/assets/skills/trace-spec-to-plan/resources/sweep-agent-prompt.md +57 -0
  84. package/assets/skills/update-queue/SKILL.md +149 -0
  85. package/assets/skills/using-the-queue/SKILL.md +172 -0
  86. package/assets/skills/using-thrum-state/SKILL.md +104 -0
  87. package/assets/skills/verify-against-plan/SKILL.md +323 -0
  88. package/assets/skills/verify-against-source/SKILL.md +237 -0
  89. package/assets/skills/watcher-archetype/SKILL.md +84 -0
  90. package/assets/skills/writing-durable-markdown/SKILL.md +66 -0
  91. package/dist/hooks/block-sync-cd.d.ts +9 -0
  92. package/dist/hooks/block-sync-cd.js +71 -0
  93. package/dist/hooks/block-sync-cd.test.d.ts +1 -0
  94. package/dist/hooks/block-sync-cd.test.js +61 -0
  95. package/dist/hooks/shell-env.d.ts +8 -0
  96. package/dist/hooks/shell-env.js +22 -0
  97. package/dist/index.d.ts +6 -0
  98. package/dist/index.js +25 -0
  99. package/dist/installer.d.ts +2 -0
  100. package/dist/installer.js +86 -0
  101. package/package.json +49 -0
@@ -0,0 +1,1007 @@
1
+ ---
2
+ name: project-setup
3
+ description: "Use when converting a plan file (from writing-plans skill) into beads epics, tasks, implementation prompts, and worktrees — before any coding begins"
4
+ ---
5
+
6
+ # Project Setup
7
+
8
+ Convert a plan file into beads epics and tasks with TDD-quality descriptions,
9
+ filled implementation prompts, and ready-to-use worktrees.
10
+
11
+ **Core principle:** Task descriptions are the source of truth. Each task is a
12
+ self-contained implementation guide — detailed enough for an agent to work
13
+ autonomously.
14
+
15
+ **Announce at start:** "I'm using the project-setup skill to decompose this plan
16
+ into epics and tasks."
17
+
18
+ ## Phase 0 — Review gate (hard bail)
19
+
20
+ **This is the first gate and the ONLY structurally-enforceable gate in the
21
+ planning-skill review loop.** A `SKILL.md` is prose the agent follows; the
22
+ upstream wrapper's pre-flight greps are strong-but-soft behavioral guardrails.
23
+ This gate is different: project-setup is thrum-owned, so it is authored to
24
+ genuinely refuse to run.
25
+
26
+ Before doing anything else, verify the plan/spec doc carries a passing review
27
+ stamp, a Deviations-from-Source block, AND evidence that
28
+ `verify-against-source` specifically ran. Resolve the plan path first (it is
29
+ the skill's primary input — the same path the caller passes), then:
30
+
31
+ ```bash
32
+ # PLAN_FILE = the plan/spec doc this project-setup run is decomposing
33
+ # Anchored, NOT -F: a bare substring match accepts an invented verdict —
34
+ # `verdict=Ready:Yes-with-residual` satisfies `grep -F 'verdict=Ready:Yes'`
35
+ # and walks straight through this fail-closed gate. The trailing group
36
+ # requires the value to END here.
37
+ grep -E 'THRUM-REVIEW: stage=plan verdict=Ready:Yes([[:space:]]|-->|$)' "$PLAN_FILE" \
38
+ || grep -E 'THRUM-REVIEW: stage=plan verdict=OVERRIDE([[:space:]]|-->|$)' "$PLAN_FILE"
39
+
40
+ grep -F '## Deviations from Source' "$PLAN_FILE"
41
+
42
+ grep -E 'verify=Ready:Yes([[:space:]]|-->|$)' "$PLAN_FILE" \
43
+ || grep -E 'verify=OVERRIDE([[:space:]]|-->|$)' "$PLAN_FILE" \
44
+ || grep -E 'verify=PREDATES([[:space:]]|-->|$)' "$PLAN_FILE"
45
+ ```
46
+
47
+ All three checks must pass.
48
+
49
+ Notes on the check:
50
+
51
+ - **Case-sensitive, literal match.** Use `grep -F` on the exact canonical
52
+ (fixed-key-order) string. Never `grep -i`. The canonical verdict values are
53
+ exactly `Ready:Yes` and `OVERRIDE` — a mis-cased stamp (`ready:yes`,
54
+ `READY:YES`) does NOT pass.
55
+ - **`OVERRIDE` is a valid pass** for the THRUM-REVIEW stamp and for
56
+ `verify=` — each independently. Neither substitutes for the Deviations
57
+ marker. Surface any `THRUM-DEFER` lines still present in the doc as part
58
+ of the override audit.
59
+ - **The Deviations block has no override.** Its absence always fails the
60
+ gate — see `claude-plugin/commands/_deviations-protocol.md` ("empty must
61
+ be WRITTEN, not omitted").
62
+ - **`verify=` has no silent-omission path.** A stamp missing `verify=`
63
+ entirely FAILS this third check exactly like a missing stamp fails the
64
+ first — there is no carve-out for plans that predate the field. The field
65
+ must be PRESENT with one of exactly three values: `Ready:Yes` — the
66
+ `verify-against-source` conformance pass ran clean this cycle; `OVERRIDE`
67
+ — a coordinator deliberately waived `verify-against-source` for THIS
68
+ review cycle (an active, in-the-moment waiver, with a reason); `PREDATES`
69
+ — this plan/stamp predates the `verify=` convention entirely (the legacy
70
+ case). Each is a distinct, auditable claim, and none of them is the same
71
+ as leaving the field out. A plan reviewed before this convention existed
72
+ must be re-stamped with `verify=PREDATES` (not `OVERRIDE` — that value is
73
+ reserved for an active per-cycle waiver, not the legacy case) to pass,
74
+ same as any other legacy plan bails on the first check until it gets an
75
+ `OVERRIDE`. This is what makes `verify-against-source` mandatory in fact,
76
+ not just in name: a plan could otherwise carry `verdict=Ready:Yes` from
77
+ some OTHER reviewer while `verify-against-source` itself never ran.
78
+
79
+ If any check fails, **STOP — do not proceed.** Tell the user:
80
+
81
+ > project-setup requires the plan/spec to have passed the planning-loop review
82
+ > (or carry a coordinator override), to carry a `## Deviations from Source`
83
+ > block, AND to carry `verify=Ready:Yes`, `verify=OVERRIDE`, or
84
+ > `verify=PREDATES` evidence that `verify-against-source` specifically ran (or
85
+ > was deliberately waived, or the plan predates the convention). The plan at
86
+ > `<PLAN_FILE>` is missing one or more of: the review stamp, the Deviations
87
+ > block, the `verify=` field — check which with the three `grep -F` commands
88
+ > above. Run the plan review first (making sure `verify-against-source` runs
89
+ > and stamps `verify=`), obtain a coordinator override, or stamp
90
+ > `verify=PREDATES` if the plan predates this convention, then re-invoke
91
+ > project-setup.
92
+
93
+ **Fail closed, not open.** Plans that predate this feature, or that arrive from
94
+ a different flow, will not carry the stamp, the Deviations block, or the
95
+ `verify=` field — they still bail on all three checks. The caller must add an
96
+ `OVERRIDE` stamp for the review-stamp check and a `verify=PREDATES` (the
97
+ legacy case — not `verify=OVERRIDE`, which is reserved for an active per-cycle
98
+ waiver) for the verify check, and must author the Deviations block (there is
99
+ no override for its absence), to proceed. Do not silently fall through when
100
+ any of the three is absent.
101
+
102
+ ## When to Use
103
+
104
+ ```dot
105
+ digraph when_to_use {
106
+ "Have a design doc?" [shape=diamond];
107
+ "Have a plan file?" [shape=diamond];
108
+ "Need epics & tasks?" [shape=diamond];
109
+ "Use coordinator-running-brainstorm-cycles skill first" [shape=box];
110
+ "Use writing-plans skill first" [shape=box];
111
+ "Already have tasks in beads" [shape=box];
112
+ "Run project-setup" [shape=doublecircle];
113
+
114
+ "Have a design doc?" -> "Use coordinator-running-brainstorm-cycles skill first" [label="no"];
115
+ "Have a design doc?" -> "Have a plan file?" [label="yes"];
116
+ "Have a plan file?" -> "Use writing-plans skill first" [label="no"];
117
+ "Have a plan file?" -> "Need epics & tasks?" [label="yes"];
118
+ "Need epics & tasks?" -> "Already have tasks in beads" [label="no"];
119
+ "Need epics & tasks?" -> "Run project-setup" [label="yes"];
120
+ }
121
+ ```
122
+
123
+ **Don't use when:**
124
+
125
+ - No design doc exists yet — use the `coordinator-running-brainstorm-cycles`
126
+ skill first (spawns a researcher in an isolated worktree, runs the brainstorm
127
+ interactively with the user, iterates dual-review cycles, then hands off back
128
+ to project-setup)
129
+ - No plan file exists yet — use writing-plans skill first
130
+ - Tasks already exist in beads — go straight to creating the implementation
131
+ prompt closely following the template (implementation-agent.md)
132
+
133
+ ## Prerequisites
134
+
135
+ Two prereqs must be satisfied before project-setup proceeds. Bail on either
136
+ rather than trying to work around it.
137
+
138
+ ### Beads (bd) installed
139
+
140
+ Verify beads is installed:
141
+
142
+ ```bash
143
+ bd version
144
+ ```
145
+
146
+ If `bd` is not found, stop and tell the user:
147
+
148
+ > project-setup requires beads (`bd`) for task tracking with dependencies.
149
+ > Install it:
150
+ >
151
+ > ```bash
152
+ > brew install dolt # required dependency
153
+ > brew install steveyegge/beads/bd # beads CLI
154
+ > bd init # initialize in your repo
155
+ > ```
156
+ >
157
+ > See the [beads repo](https://github.com/steveyegge/beads) for alternative
158
+ > install methods. Requires dolt v1.81.8+ and bd v0.59.0+.
159
+
160
+ Do not proceed without beads. Do not fall back to markdown task lists or
161
+ TodoWrite.
162
+
163
+ ### Implementation Philosophy Doc
164
+
165
+ Verify the project has an implementation philosophy doc at the canonical path.
166
+ In worktrees, `.thrum/` is a redirect file pointing at the project root's real
167
+ `.thrum/` directory — the check must resolve through it:
168
+
169
+ ```bash
170
+ PHILOSOPHY_DIR=.thrum
171
+ [ -f .thrum/redirect ] && PHILOSOPHY_DIR="$(cat .thrum/redirect)"
172
+ test -f "$PHILOSOPHY_DIR/philosophy.md"
173
+ ```
174
+
175
+ If the file does not exist, stop and tell the user:
176
+
177
+ > project-setup requires a philosophy doc at `.thrum/philosophy.md`. Run the
178
+ > `project-philosophy` skill first to generate or locate one, then re-invoke
179
+ > project-setup.
180
+
181
+ Do not proceed without the philosophy doc. Do not inline-create.
182
+
183
+ If the doc exists, read it and extract the anti-patterns for injection in
184
+ Phase 4. Refer to the `project-philosophy` skill for the doc contents and the
185
+ anti-pattern format. Also check for `.thrum/hotpath-gate.json` (generated by
186
+ `project-hotpath-gate`); if absent, recommend running it alongside
187
+ `project-philosophy` at onboarding so the project has hot-path gate
188
+ configuration from day one.
189
+
190
+ ## Inputs
191
+
192
+ Primary input: **plan file path** (output of writing-plans, e.g.
193
+ `dev-docs/plans/2026-02-21-feature-plan.md`). The plan references the design doc
194
+ — both are read in Phase 1.
195
+
196
+ Also needed from CLAUDE.md or conversation context:
197
+
198
+ - **Project root** — absolute path to the project
199
+ - **Tech stack** — languages, frameworks, tools in use
200
+ - **Quality commands** — test/lint commands (e.g. `make test && make lint`)
201
+ - **Coverage target** — minimum coverage threshold (e.g. `>80%`)
202
+
203
+ If any are missing, ask the user (prefer multiple choice when possible).
204
+
205
+ ## Phase 1: Understand the Plan
206
+
207
+ Read the plan file and the design doc it references. Identify major phases,
208
+ components, data flow, and interfaces.
209
+
210
+ ### 🔴 Phase 1a — MANDATORY security-frame check (do this BEFORE decomposing)
211
+
212
+ **Read the project's threat model** (`docs/security_model/master.md` §1 and §1.2
213
+ on thrum; otherwise `docs/security*.md` / `SECURITY.md`) **whenever the plan
214
+ contains ANY of the following — and note that NONE of them need name an
215
+ attacker:**
216
+
217
+ - a **guard**, cap, deadline, concurrency limit, backoff, or rate limit
218
+ - a **retention, permanence, immutability, or "must never be deleted/rotated"** rule
219
+ - an **audit, forensic, tamper-evidence, or provenance** requirement
220
+ - an **authorization, entitlement, or recipient/ownership check**
221
+
222
+ **Thrum's actual shape, which the plan must be read against:** **NOT SaaS, NOT
223
+ internet-facing, NOT product-oriented.** It is **single-user, localhost, and
224
+ multi-machine on the same network**. Capabilities are **owner toggles, not an
225
+ authorization system**. Every process with repo write access is **inside the
226
+ perimeter**. What is defended against is **agents making MISTAKES, not agents
227
+ ATTACKING**.
228
+
229
+ **If a plan requirement only makes sense under a SaaS / multi-tenant /
230
+ internet-facing / compliance frame, it is a DEFECT IN THE PLAN — surface it
231
+ before creating beads.** Do not decompose it into tasks; a bead makes an
232
+ unratified premise look like ratified scope, and every downstream hop then
233
+ reasons correctly from it.
234
+
235
+ Requirements of this class do not arrive labelled "security" — they arrive as
236
+ durability, forensics, hygiene, or "defence in depth". A conformance gate
237
+ downstream cannot catch this: every hop reasons correctly from a false root, so
238
+ the check must happen where the premise enters.
239
+
240
+ **Ask of any such requirement: WHO RATIFIED IT?** Trace it to an owner ruling or
241
+ the threat model. "It appears in the source plan" is propagation, not
242
+ ratification.
243
+
244
+ ### The Two-Artifact System
245
+
246
+ This skill produces two complementary artifacts per task:
247
+
248
+ | Artifact | Contains | Authoritative For |
249
+ | --------------------- | ---------------------------------------------- | ----------------------------------- |
250
+ | **Beads task** | Acceptance criteria, deps, status | What must be true to close the task |
251
+ | **Plan file section** | Step-by-step code, file paths, verify commands | How to implement the task |
252
+
253
+ Both are required. Agents read `bd show {TASK_ID}` first (what must be true),
254
+ then search the plan file for the matching `## Task: {BEAD_ID}` section (how to
255
+ get there).
256
+
257
+ **If the plan file lacks code for a task, the task description must be detailed
258
+ enough to stand alone.** Flag any plan tasks with vague or missing
259
+ implementation code during this phase.
260
+
261
+ Explore the codebase and recent beads state in parallel. Partition the work so:
262
+
263
+ - One sub-agent maps packages, interfaces, and patterns relevant to
264
+ `{{FEATURE_DESCRIPTION}}` — output: `output/planning/codebase-scan.md`.
265
+ - One sub-agent runs `bd list --status=open`, `bd ready`, and `bd blocked` and
266
+ identifies work related to `{{FEATURE_DESCRIPTION}}` — output:
267
+ `output/planning/beads-context.md`. (Raw `bd ready` is deliberate here — this
268
+ is a beads-state inventory alongside `bd list`/`bd blocked`, not work-queue
269
+ pickup.)
270
+
271
+ Invoke `efficient-multi-agent-research` for the launch-and-wait mechanics. After
272
+ agents complete, read the two output files — do not fan-read individual beads
273
+ entries into the main context.
274
+
275
+ Ask the user focused questions (prefer multiple choice) about anything the plan
276
+ leaves ambiguous — constraints, scope boundaries, patterns to follow.
277
+
278
+ ## Phase 1b: Spec coverage gate (MANDATORY)
279
+
280
+ Invoke **`trace-spec-to-plan`** against the plan and its source spec. **Do not
281
+ create a single epic or task until every gap it reports is closed or explicitly
282
+ ruled by the owner.**
283
+
284
+ **Why HERE:** this is the last moment the spec is still in the room. Once a
285
+ requirement is missing from the plan *and* absent from the beads, **the beads
286
+ become the working set, nobody consults the spec again, and the gap stops being
287
+ discoverable at all.**
288
+
289
+ 🚫 **Never self-run this as the plan's author — dispatch it.** Self-review cannot
290
+ catch a requirement the author never perceived — same person, same anchoring,
291
+ same blind spot.
292
+
293
+ ⚠️ **This does NOT duplicate `verify-against-source`.** They read different
294
+ things and catch different failures:
295
+
296
+ | Gate | Reads | Asks | Catches |
297
+ |---|---|---|---|
298
+ | `verify-against-source` | the ARTIFACT | does this honor its source? | drift, contradiction, scope creep |
299
+ | **`trace-spec-to-plan`** | **the SPEC** | **where did each requirement land?** | **absence, name-only, missing substrate** |
300
+
301
+ **A reviewer reading an artifact cannot see what isn't in it.**
302
+
303
+ ## Phase 2: Decompose into Epics & Tasks
304
+
305
+ ### Map Plan Phases to Epics
306
+
307
+ Map each plan phase to a beads epic. Each epic should:
308
+
309
+ - Represent a cohesive, independently deliverable unit of work
310
+ - Be completable in 1-3 agent sessions
311
+ - Have clear boundaries (a single worktree/branch per epic)
312
+ - Map to a logical layer or component from the design spec
313
+
314
+ **Naming:** Imperative form — "Implement Sync Protocol", "Build Session
315
+ Manager", "Create Filter Component".
316
+
317
+ Present the epic breakdown to the user for approval before creating anything.
318
+
319
+ ### Create Epics in Beads
320
+
321
+ Once the user approves the epic breakdown:
322
+
323
+ ```bash
324
+ bd create --title="Epic Title" --type=epic --priority=1
325
+
326
+ # If epics have ordering dependencies:
327
+ bd dep add <later-epic-id> <earlier-epic-id>
328
+ ```
329
+
330
+ ### Create Tasks
331
+
332
+ When creating > 6 tasks, delegate to parallel sub-agents — one per epic. Each
333
+ sub-agent (sonnet-low is sufficient — the work is mechanical) gets the epic ID, the
334
+ list of `bd create --title=... --type=task --priority=N --description=...`
335
+ commands to run, the within-epic `bd dep add <later_id> <earlier_id>` ordering
336
+ commands, and instructions to return the created task IDs and titles. Invoke
337
+ `efficient-multi-agent-research` § Core Pattern for launch-and-wait mechanics.
338
+
339
+ > **Model tiers:** pass an explicit `model:` on every dispatch — `sonnet`
340
+ > (low effort) mechanical, `sonnet` (medium effort) judgment, Opus only on
341
+ > operator-ask or a skill step that names it. See the
342
+ > `choosing-subagent-models` skill for the full policy.
343
+
344
+ After sub-agents return IDs, set cross-epic dependencies directly (requires IDs
345
+ from multiple sub-agents):
346
+
347
+ ```bash
348
+ bd dep add <epic-2-id> <epic-1-id>
349
+
350
+ # Verify no circular dependencies
351
+ bd blocked
352
+ ```
353
+
354
+ ### Task Description Quality
355
+
356
+ Every beads task description is a **self-contained implementation guide**:
357
+
358
+ **Required sections:**
359
+
360
+ ````markdown
361
+ ## Files
362
+
363
+ - Create: `exact/path/to/new_file.go`
364
+ - Modify: `exact/path/to/existing.go` (add XyzService interface)
365
+ - Test: `exact/path/to/new_file_test.go`
366
+
367
+ ## Steps
368
+
369
+ ### Step 1: Write the failing test
370
+
371
+ ```go
372
+ func TestSpecificBehavior(t *testing.T) {
373
+ result := Function(input)
374
+ assert.Equal(t, expected, result)
375
+ }
376
+ ```
377
+
378
+ ### Step 2: Implement
379
+
380
+ ```go
381
+ func Function(input Type) ReturnType {
382
+ // implementation
383
+ }
384
+ ```
385
+
386
+ ### Step 3: Verify and commit
387
+
388
+ ```bash
389
+ go test ./path/to/package/... -run TestSpecificBehavior -v
390
+ git commit -m "feat(module): add specific feature"
391
+ ```
392
+
393
+ ## Acceptance Criteria
394
+
395
+ - [ ] All tests pass
396
+ - [ ] Function handles edge case X
397
+ - [ ] Error returns are typed, not generic
398
+ ````
399
+
400
+ **Scale code detail to task type:**
401
+
402
+ | Task Type | Code in Steps | Test Detail |
403
+ | -------------------- | ------------------------ | --------------------------------------------- |
404
+ | API/Interface design | Full signatures + types | Contract tests, error case tests |
405
+ | Business logic | Full implementation code | TDD: failing test → implement → pass |
406
+ | Integration/Wiring | Connection code + config | Integration test against mock/real dependency |
407
+ | UI/Styling | Full CSS/component code | Visual verification steps, screenshot check |
408
+ | Testing-only | N/A | Full test code with scenarios and edge cases |
409
+ | Documentation | N/A (outline only) | Verification: doc renders, links work |
410
+
411
+ **Granularity:** Each task should be completable in one focused session (30-90
412
+ minutes). If a task has more than 5 steps, split it.
413
+
414
+ ### Ensure Refactoring Epic Exists
415
+
416
+ Implementation agents log DRY/refactoring opportunities they discover during
417
+ feature work. These go into a persistent **refactoring epic** in beads. Check if
418
+ one exists; if not, create it:
419
+
420
+ ```bash
421
+ # Search for existing refactoring epic
422
+ bd list --type=epic | grep -i refactor
423
+ ```
424
+
425
+ If found, note the epic ID — it will be referenced in the implementation
426
+ template's "Logging Refactoring Opportunities" section.
427
+
428
+ If not found, create one:
429
+
430
+ `--description` is multi-line prose — never double-quoted inline. On
431
+ `scripts/bd-shared`, `--stdin`/`--body-file` are refused (remote-path
432
+ resolution + silent-empty-body hazards), so write it to a scratch file and
433
+ pass `-d "$(cat <file>)"`; see the role preamble's 🔴 PROSE INTO A COMMAND
434
+ rule.
435
+
436
+ ```bash
437
+ cat > /tmp/refactor-epic-desc.md <<'EOF'
438
+ Persistent backlog for refactoring, DRY improvements, and code
439
+ organization opportunities discovered during feature work. Tasks are added by
440
+ implementation agents as they encounter opportunities. Reviewed and prioritized
441
+ by the coordinator periodically.
442
+ EOF
443
+ bd create --title="Refactoring & DRY Opportunities" --type=epic --priority=3 -d "$(cat /tmp/refactor-epic-desc.md)"
444
+ ```
445
+
446
+ This epic is **project-wide and long-lived** — it persists across feature epics.
447
+ Do not close it when closing feature epics. Implementation agents find it via
448
+ `bd list --type=epic | grep -i refactor` and add tasks under it.
449
+
450
+ ### Verify Setup
451
+
452
+ Everything the plan specifies must end up in a created epic/task — including
453
+ artifacts declared in a plan **section** body (e.g. shared types, helpers), not
454
+ only inside a task's own Files/Steps. Dispatch a sub-agent to audit the created
455
+ tasks against the full plan and confirm nothing was left unscheduled before
456
+ proceeding to Phase 3.
457
+
458
+ Before proceeding to Phase 3:
459
+
460
+ - [ ] Every task has a clear title and detailed description
461
+ - [ ] Task ordering within each epic makes sense (foundations first)
462
+ - [ ] Epic dependencies reflect the actual build order
463
+ - [ ] No circular dependencies (`bd blocked` should be clean)
464
+ - [ ] Each epic can be assigned to one worktree/branch
465
+ - [ ] Total scope is realistic (flag if > 20 tasks per epic)
466
+ - [ ] Sub-agent audit confirms every plan-declared artifact, including
467
+ section-body declarations, is covered by some task
468
+
469
+ ### Verify Plan File Anchors
470
+
471
+ After creating all tasks, verify the plan file has a searchable anchor for each
472
+ task. Implementation agents find their code by searching for:
473
+
474
+ ```text
475
+ ## Task: {BEAD_ID} — {Title}
476
+ ```
477
+
478
+ For each created task, grep the plan file:
479
+
480
+ ```bash
481
+ grep "## Task:" {{PLAN_FILE}} | head -20
482
+ ```
483
+
484
+ Cross-reference against the created bead IDs. If any task lacks a matching
485
+ anchor, add it to the plan file at the corresponding section. This ensures
486
+ agents can search for their section instead of reading the entire (potentially
487
+ large) file.
488
+
489
+ ### Detect Cross-Epic Dependencies
490
+
491
+ After setting all dependencies, scan for tasks that depend on tasks in OTHER
492
+ epics:
493
+
494
+ ```bash
495
+ bd blocked
496
+ ```
497
+
498
+ For each cross-epic dependency (where the blocker is in a different epic than
499
+ the blocked task), record:
500
+
501
+ | Blocked Task | Blocked By | Blocker's Epic |
502
+ | ------------ | ---------- | -------------- |
503
+
504
+ Save this map — it feeds Phase 4, where each implementation prompt will include
505
+ its epic's cross-epic dependencies so agents know exactly which external tasks
506
+ to check before starting blocked work.
507
+
508
+ If no cross-epic dependencies exist, note that and move on.
509
+
510
+ ## Phase 3: Select Worktrees & Agents
511
+
512
+ **This phase is an interactive decision gate.** MUST ask the user which
513
+ worktree and agent to use for each epic before generating prompts. Do not infer
514
+ silently — present options and let the user choose.
515
+
516
+ ### Step 1: Gather Current State
517
+
518
+ Run these commands and present the results to the user:
519
+
520
+ ```bash
521
+ # List all active worktrees with branches
522
+ git worktree list
523
+
524
+ # Check which worktrees have in-progress beads tasks
525
+ bd list --status=in_progress
526
+
527
+ # Check the CLAUDE.md worktree table for status info
528
+ # (read the "Worktree Layout" section from the project root CLAUDE.md)
529
+ ```
530
+
531
+ ### Step 2: Present Worktree Options
532
+
533
+ For each epic, use `AskUserQuestion` to let the user choose a worktree. Build
534
+ the options from the gathered state:
535
+
536
+ **Option types to present:**
537
+
538
+ | Scenario | Option label |
539
+ | ------------------------------------------- | ----------------------------------- |
540
+ | Existing idle worktree with related branch | "Reuse `<path>` (`<branch>`)" |
541
+ | Existing idle worktree, unrelated branch | "Reuse `<path>`, create new branch" |
542
+ | No suitable worktree exists | "Create new worktree" |
543
+ | Work is small enough for the current branch | "Use current worktree (`<branch>`)" |
544
+
545
+ Include in each option's description:
546
+
547
+ - The worktree path and current branch
548
+ - Whether it's clean or has uncommitted changes
549
+ - Whether it has an existing agent registered
550
+ - Its status from CLAUDE.md (active/idle/merged)
551
+
552
+ **For "Create new worktree"**, suggest:
553
+
554
+ - Path: `~/.workspaces/{repo}/{feature}` (from CLAUDE.md convention)
555
+ - Branch: `feature/{feature-name}`, cut from the configured merge target
556
+ (`jq -r '.orchestration.merge_target' .thrum/config.json`) — never a
557
+ remembered branch name
558
+
559
+ **For agent names**, suggest a name derived from the feature in each option
560
+ description (e.g., `impl_{feature}`). The user can override.
561
+
562
+ ### Step 3: Set Up the Chosen Worktree
563
+
564
+ Based on the user's choice, execute the appropriate setup:
565
+
566
+ #### For reused worktrees
567
+
568
+ ```bash
569
+ cd <worktree-path>
570
+
571
+ # Check if clean
572
+ git status
573
+
574
+ # Fast-forward or merge forward to the MERGE TARGET if behind — never rebase
575
+ # (rebase onto a moved base is banned project-wide; see CLAUDE.md
576
+ # "Rebase onto current tip before sending MERGE-READY")
577
+ # Resolve the branch, never hardcode it — a name in a document goes stale and
578
+ # this one already did:
579
+ TARGET=$(jq -r '.orchestration.merge_target' .thrum/config.json)
580
+ git fetch origin "$TARGET"
581
+ git merge "origin/$TARGET"
582
+ # OR if branches diverged: ask user before merging
583
+
584
+ # Verify redirects are intact
585
+ cat .thrum/redirect # should point to <project-root>/.thrum
586
+ cat .beads/redirect # should point to <project-root>/.beads
587
+
588
+ # If redirects are missing or wrong, fix them:
589
+ # (from project root)
590
+ ./scripts/setup-worktree-thrum.sh <worktree-path>
591
+
592
+ # Verify beads sees shared database
593
+ bd where # Should show <project-root>/.beads
594
+ bd ready # Should show issues from the shared database
595
+
596
+ # Register the agent (if not already registered with the right name)
597
+ thrum quickstart --name <agent-name> --role implementer \
598
+ --module <branch-name> --intent "Implementing <epic-id>"
599
+ ```
600
+
601
+ #### For new worktrees
602
+
603
+ The preferred path is `thrum worktree create` (alias: `thrum worktree setup`).
604
+ Both commands are interchangeable. They create the
605
+ worktree, set up thrum and beads redirects, register the agent identity, and
606
+ enforce single-identity-per-worktree (registering a second identity in the same
607
+ worktree is an error).
608
+
609
+ ```bash
610
+ # Preferred: single command via thrum CLI
611
+ # Positional arg is the worktree NAME (not a path); branch is --branch; the
612
+ # agent identity is --name (which triggers quickstart-in-tmux). There is no
613
+ # --identity flag on the CLI.
614
+ thrum worktree create <worktree-name> --branch <branch-name> \
615
+ --name <agent-name> --role implementer
616
+
617
+ # Alias — identical behavior
618
+ thrum worktree setup <worktree-name> --branch <branch-name> \
619
+ --name <agent-name> --role implementer
620
+
621
+ # Alternative: shell script (does the same thing; the SCRIPT keeps its own
622
+ # <worktree-path> <branch> --identity interface — distinct from the CLI above)
623
+ ./scripts/setup-worktree-thrum.sh \
624
+ <worktree-path> <branch-name> \
625
+ --identity <agent-name> --role implementer
626
+ ```
627
+
628
+ All three handle: branch creation, worktree creation, thrum redirect, beads
629
+ redirect, and `thrum quickstart` registration.
630
+
631
+ #### For current worktree (small fixes)
632
+
633
+ ```bash
634
+ # Just register the agent
635
+ thrum quickstart --name <agent-name> --role implementer \
636
+ --module <current-branch> --intent "Implementing <epic-id>"
637
+
638
+ # Verify beads
639
+ bd where
640
+ bd ready
641
+ ```
642
+
643
+ ### Step 4: Verify Setup
644
+
645
+ Before proceeding to Phase 4, verify for each worktree:
646
+
647
+ ```bash
648
+ cd <worktree-path>
649
+
650
+ # Beads sees shared database
651
+ bd where
652
+ # Expected: <project-root>/.beads
653
+
654
+ # Issues are visible
655
+ bd ready
656
+
657
+ # Thrum daemon reachable
658
+ thrum daemon status
659
+
660
+ # Redirects correct
661
+ cat .thrum/redirect
662
+ cat .beads/redirect
663
+
664
+ # Agent registered
665
+ thrum agent list --context
666
+ ```
667
+
668
+ ### Step 5: Update CLAUDE.md
669
+
670
+ If a new worktree was created, update the worktree table in the project root
671
+ CLAUDE.md. Use the existing table format:
672
+
673
+ ```markdown
674
+ | `<path>` | `<branch>` | <purpose> | active |
675
+ ```
676
+
677
+ ### Troubleshooting
678
+
679
+ **"not in a bd workspace"** — The beads redirect file is missing or incorrect:
680
+
681
+ ```bash
682
+ ls -la .beads/
683
+ cat .beads/redirect
684
+ bd where
685
+ # Fix: run setup-worktree-thrum.sh <path> (redirect-only mode)
686
+ ```
687
+
688
+ **Wrong database** — `bd where` shows a local database instead of shared:
689
+
690
+ ```bash
691
+ bd where
692
+ # Should show <project-root>/.beads, not a local database
693
+ # Fix: rm .beads/*.db && re-run setup script
694
+ ```
695
+
696
+ **Sync warnings in worktrees** — Warnings about "snapshot validation failed" or
697
+ "git status failed" are **normal** in worktrees. If the final output shows
698
+ success, it's fine.
699
+
700
+ ### Record Worktree Assignments
701
+
702
+ At the end of this phase, confirm an assignment for each epic:
703
+
704
+ | Epic | Worktree Path | Branch | Agent Name |
705
+ | ----------- | ------------- | ---------- | -------------- |
706
+ | `<epic-id>` | `<path>` | `<branch>` | `<agent-name>` |
707
+
708
+ These values feed directly into the `{{PLACEHOLDER}}` resolution in Phase 4.
709
+
710
+ ## Phase 4: Generate Implementation Prompts
711
+
712
+ **CRITICAL: Generate prompts directly. Do NOT delegate prompt
713
+ generation to sub-agents.** Sub-agents take shortcuts — they skip sections,
714
+ leave template metadata in the output, fail to strip meta-sections, and produce
715
+ prompts that confuse the implementation agent. The prompt is the most important
716
+ artifact this skill produces. It defines how the implementation agent behaves
717
+ for the entire epic. Treat it with the same care as writing code.
718
+
719
+ For each epic/worktree assignment, generate a filled prompt file.
720
+
721
+ ### Step 1: Read the template
722
+
723
+ Read the `implementation-agent.md` file from this skill's `resources/`
724
+ directory.
725
+
726
+ This is the **source template**. Do not work from memory — read the actual file
727
+ every time.
728
+
729
+ ### Step 1.5: Generate Anti-Patterns for Each Epic
730
+
731
+ For each epic's prompt, derive the `{{ANTI_PATTERNS}}` content by combining two
732
+ sources:
733
+
734
+ 1. The design doc's **Key Decisions** section — implementation-constraining
735
+ decisions (e.g., "full page reload, not HTMX", "real service calls, not
736
+ hardcoded").
737
+ 2. The philosophy doc's **Anti-Patterns** and **Red Flags** sections (already
738
+ read during the Prerequisites check).
739
+
740
+ Present the derived anti-patterns to the user for approval via `AskUserQuestion`
741
+ before injecting into the prompt.
742
+
743
+ Refer to the `project-philosophy` skill for the anti-pattern format spec (rule
744
+ count, grep-ability, positive + negative pair structure).
745
+
746
+ **Why this matters:** The verifier sub-agent pattern in the implementation
747
+ template uses these red flags to check each task. Generic "tests pass"
748
+ verification misses architectural violations that pass tests but violate design
749
+ decisions.
750
+
751
+ ### Step 2: Resolve all placeholders
752
+
753
+ Perform literal find-and-replace on every `{{PLACEHOLDER}}` in the template. All
754
+ worktree-related values come from the Phase 3 assignments:
755
+
756
+ | Placeholder | Source |
757
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
758
+ | `{{EPIC_ID}}` | Beads epic ID from Phase 2 |
759
+ | `{{EPIC_TITLE}}` | Epic title (used in commit messages) |
760
+ | `{{WORKTREE_PATH}}` | **From Phase 3 worktree assignment** |
761
+ | `{{BRANCH_NAME}}` | **From Phase 3 worktree assignment** |
762
+ | `{{PROJECT_ROOT}}` | Absolute path to the project root |
763
+ | `{{DESIGN_DOC}}` | **Absolute path** to the design spec |
764
+ | `{{REFERENCE_CODE}}` | Relevant reference code paths (relative OK if committed) |
765
+ | `{{QUALITY_COMMANDS}}` | Test/lint commands — **scoped to packages this epic modifies**. Avoid full-suite commands (e.g., `go test ./...`) that hit pre-existing failures. Example: `go build ./... && go test ./internal/processing/localstore/ -v` |
766
+ | `{{COVERAGE_TARGET}}` | Coverage threshold (e.g., `>80%`) |
767
+ | `{{AGENT_NAME}}` | **From Phase 3 agent registration** |
768
+ | `{{PLAN_FILE}}` | **Absolute path** to the plan file (primary input) |
769
+ | `{{ANTI_PATTERNS}}` | Generated in Step 1.5; refer to the `project-philosophy` skill for the anti-pattern format spec. |
770
+ | `{{SUPERVISOR_NAME}}` | From `thrum team` — first agent with role=orchestrator; if none, first with role=coordinator; if none, ask user |
771
+ | `{{CROSS_EPIC_DEPS}}` | From Phase 2 cross-epic dependency map. If no cross-epic deps, replace with "No cross-epic dependencies." |
772
+
773
+ **IMPORTANT — Absolute paths for gitignored files:** `{{DESIGN_DOC}}`,
774
+ `{{PLAN_FILE}}`, and the saved prompt path (`dev-docs/prompts/`) are typically
775
+ gitignored. Agents in worktrees cannot resolve relative paths to these files
776
+ because worktrees only share committed content. Always resolve these to absolute
777
+ paths (e.g., `/Users/you/project/dev-docs/plans/file.md`, not
778
+ `dev-docs/plans/file.md`). This also applies to beads task descriptions — any
779
+ reference to a plan or design doc in a task description must be an absolute
780
+ path.
781
+
782
+ **Strip template meta-sections.** The following sections exist to document the
783
+ template itself and MUST NOT appear in the filled prompt:
784
+
785
+ - `## Purpose` — template description, not agent instructions
786
+ - `## CRITICAL: Prompt Generation Rules` — instructions for the coordinator
787
+ filling the template, not for the implementation agent
788
+ - `## Inputs Required` — placeholder documentation for the coordinator, not the
789
+ agent. Including this section confuses agents with `{{PLACEHOLDER}}`
790
+ descriptions alongside already-resolved values.
791
+ - Any `<!-- STRIP ... -->` HTML comment blocks — these are meta-instructions
792
+ that must be removed along with any text they annotate
793
+ - Any lines that address "the coordinator" or say "when filling this template"
794
+
795
+ **Keep all behavioral sections.** The output must contain every behavioral
796
+ section from the template — Sub-Agent Strategy, all 4 Phases (including the new
797
+ Phase 3: Self-Review Gate), Resume Quick Reference, etc. — with placeholders
798
+ replaced by resolved values. Do not omit, reorganize, or summarize behavioral
799
+ sections.
800
+
801
+ ### Step 3: Prepend feature-specific context
802
+
803
+ Add a header before the filled template with quick context, task inventory, and
804
+ architecture notes specific to this feature:
805
+
806
+ ```markdown
807
+ # Implementation Prompt: {{FEATURE_NAME}}
808
+
809
+ > Generated by project-setup on YYYY-MM-DD Plan: {{PLAN_FILE}} Design doc:
810
+ > {{DESIGN_DOC}} Epic: {{EPIC_ID}} (N tasks)
811
+
812
+ **Authored-against:** `<sha>` target: `<merge_target>`
813
+
814
+ > ⚠️ Verify base before acting: `git diff <sha>..origin/<merge_target> -- <files cited>` -- non-empty ⇒ cited code moved. (Resolve `<merge_target>` through its remote-tracking ref, never a bare local branch name — a local branch of the same name can be stale or absent.)
815
+
816
+ <!-- Derive stamp per `claude-plugin/commands/_stamp-protocol.md`. -->
817
+
818
+ ## Deviations from Source
819
+
820
+ <!-- Derive per `claude-plugin/commands/_deviations-protocol.md` — diff
821
+ against the plan/spec, never recall from memory. Required even when
822
+ empty. -->
823
+
824
+ No deviations from source.
825
+
826
+ ## Quick Context
827
+
828
+ <!-- 2-3 sentences about what this epic delivers and key decisions -->
829
+
830
+ <!-- Optional: task inventory table, architecture notes, suggested batches -->
831
+
832
+ ## Worktree Setup
833
+
834
+ <!-- If worktree was already created in Phase 3, note that here: -->
835
+
836
+ Worktree ready at `{{WORKTREE_PATH}}` on branch `{{BRANCH_NAME}}`. Agent
837
+ `{{AGENT_NAME}}` registered.
838
+
839
+ <!-- If worktree needs to be created by the implementation agent: -->
840
+
841
+ ./scripts/setup-worktree-thrum.sh {{WORKTREE_PATH}} {{BRANCH_NAME}} \
842
+ --identity {{AGENT_NAME}} --role implementer
843
+
844
+ ---
845
+
846
+ <!-- PASTE the filled template below this line.
847
+ STRIP the "## Purpose" and "## Inputs Required" sections — those are
848
+ template meta-documentation, not agent instructions.
849
+ START from "## Sub-Agent Strategy" through "## Resume Quick Reference".
850
+ All behavioral sections must be present with placeholders resolved. -->
851
+ ```
852
+
853
+ ### Step 3.5: Insert review gates between epics
854
+
855
+ For multi-epic prompts (where one implementation agent handles sequential
856
+ epics), insert a review gate block after each epic's task section. Use the
857
+ template from `implementation-agent.md` (between `REVIEW_GATE_TEMPLATE_START`
858
+ and `REVIEW_GATE_TEMPLATE_END` comments):
859
+
860
+ ```markdown
861
+ ## Review Gate: <EPIC_BEAD_ID>
862
+
863
+ Before proceeding to the next epic:
864
+
865
+ 1. Commit all work for this epic
866
+ 2. Run tests: verify all tests pass for changes in this epic
867
+ 3. Report completion via Thrum:
868
+ `thrum send --to @<SUPERVISOR_NAME> --body-file done.md` (body: "Epic
869
+ <EPIC_BEAD_ID> complete. Ready for review.")
870
+ 4. Set status: `thrum agent set-status idle`
871
+ 5. **STOP.** Wait for review approval before continuing.
872
+ ```
873
+
874
+ Resolve `{{EPIC_ID}}` with the current epic's bead ID and `{{SUPERVISOR_NAME}}`
875
+ with the supervisor agent name. Insert one gate after each epic's tasks, before
876
+ the next epic's heading. The orchestrator validates prompts by checking for
877
+ `## Review Gate:` headings — prompts without them will be rejected.
878
+
879
+ For single-epic prompts, omit the review gate (the Self-Review Gate in Phase 3
880
+ handles end-of-work review).
881
+
882
+ ### Step 4: Save and commit
883
+
884
+ Save to `dev-docs/prompts/{feature}.md`, then commit:
885
+
886
+ ```bash
887
+ git add dev-docs/prompts/
888
+ git commit -m "plan: add implementation prompts for {{FEATURE_NAME}}"
889
+ ```
890
+
891
+ ### Step 5: Stamp the prompt for the review loop
892
+
893
+ project-setup OWNS the impl-prompt stamps (the researcher stamps the brainstorm
894
+ and plan stages; project-setup stamps the prompt stage — per the
895
+ stamp-authorship convention). Two stamps, appended as a footer to the generated
896
+ prompt file:
897
+
898
+ 1. **Immediately after generating the prompt**, append the gate footer:
899
+
900
+ ```text
901
+ <!-- THRUM-GATE: stage=prompt next=dispatch -->
902
+ ```
903
+
904
+ 2. **After the post-setup prompt review terminates `Ready:Yes`**, append the
905
+ verdict stamp:
906
+
907
+ ```text
908
+ <!-- THRUM-REVIEW: stage=prompt verdict=Ready:Yes cycle=<N> date=<YYYY-MM-DD> -->
909
+ ```
910
+
911
+ This review happens **within the same project-setup session**: after Step 4
912
+ generates the prompt, dispatch the prompt dual-review (per the
913
+ `coordinator-running-brainstorm-cycles` Phase 7 flow), wait for it to
914
+ terminate, then append this stamp before closing out. Do NOT end the session
915
+ at Step 4 and re-invoke project-setup later for the stamp.
916
+
917
+ Use the exact canonical, case-sensitive form (`Ready:Yes` / `OVERRIDE`; keep
918
+ keys in the fixed order `stage=`, `verdict=`, `cycle=`, `date=` so a literal
919
+ `grep -F` matches). At dispatch, the coordinator greps the prompt for this
920
+ stamp: present → the pre-dispatch review is already satisfied (skip re-review);
921
+ absent → fall through to the normal pre-dispatch dual review (the stamp is a
922
+ shortcut, not a hard dispatch requirement).
923
+
924
+ ## Common Mistakes
925
+
926
+ **Too vague tasks:** "Add validation" is not a step —
927
+ `if err := validate(input); err != nil { return fmt.Errorf(...) }` is. Prefer
928
+ complete code over pseudocode.
929
+
930
+ **Too large tasks:** If a task has more than 5 steps, split it. Each task = one
931
+ focused session.
932
+
933
+ **Missing dependencies:** Forgetting cross-epic deps leads to agents starting
934
+ work they can't finish. Always run `bd blocked` to verify.
935
+
936
+ **Skipping worktree selection:** Always ask the user which worktree to use.
937
+ Check `git worktree list` and `bd list --status=in_progress` for idle worktrees
938
+ before proposing new ones. Never silently assign worktrees.
939
+
940
+ **Base branch resolution:** Do NOT pass `--base` — `worktree.Create` resolves
941
+ the base branch itself, in priority order: an explicit `--base` flag (always
942
+ wins) > `orchestration.merge_target` from `.thrum/config.json` > the main repo's
943
+ current HEAD branch > `main` as a last resort. Passing an explicit `--base <branch>`
944
+ here permanently overrides the config-driven resolution for every worktree this skill
945
+ creates — only pass it explicitly for a one-off worktree based on
946
+ something other than the configured merge target.
947
+
948
+ **Generating prompts before worktree setup:** Prompts embed the worktree path,
949
+ branch, and agent name. These must be confirmed in Phase 3 before generating
950
+ prompts in Phase 4.
951
+
952
+ **Skipping the plan file:** This skill reads the plan file (from writing-plans)
953
+ as primary input. If only a design doc exists, use writing-plans first to
954
+ produce the plan.
955
+
956
+ **Delegating prompt generation to sub-agents:** The filled implementation prompt
957
+ is the most critical artifact. Sub-agents take shortcuts: they leave template
958
+ meta-sections (`## Inputs Required`, `## Purpose`) in the output, skip
959
+ behavioral sections, fail to properly resolve placeholders, and produce prompts
960
+ that confuse the implementation agent. Always generate prompts yourself in the
961
+ main context.
962
+
963
+ **Leaving template meta-sections in filled prompts:** The `## Purpose` and
964
+ `## Inputs Required` sections are documentation ABOUT the template, not
965
+ instructions FOR the agent. Strip them. If they appear in the filled prompt,
966
+ agents see `{{PLACEHOLDER}}` descriptions alongside already-resolved values,
967
+ which is confusing and wasteful of context.
968
+
969
+ **Using relative paths for gitignored files:** Plan files, design docs, and
970
+ prompts live in gitignored directories (`dev-docs/`, `docs/plans/`). Agents in
971
+ worktrees can't see these via relative paths — the worktree only shares
972
+ committed files. Always use absolute paths (starting with `/`) when referencing
973
+ these files in: placeholder resolution, beads task descriptions, and the
974
+ generated implementation prompt. This is the most common source of "file not
975
+ found" errors for worktree agents.
976
+
977
+ ## Output Summary
978
+
979
+ When complete, the output is:
980
+
981
+ 1. **Beads epics and tasks** with dependency DAG and TDD-quality descriptions
982
+ 2. **Ready-to-use worktrees** with thrum/beads redirects and agents registered
983
+ 3. **Filled implementation prompts** at `dev-docs/prompts/{feature}.md`
984
+ 4. **All artifacts committed** to git
985
+
986
+ ## Handoff
987
+
988
+ After setup is complete, each epic is ready for an implementation agent. The
989
+ filled prompt at `dev-docs/prompts/{feature}.md` is the session start prompt —
990
+ give it directly to the implementing agent.
991
+
992
+ ### Implementer Status Reports
993
+
994
+ Implementation agents prefix every completion or escalation message with one of
995
+ four status tokens defined in `implementation-agent.md`'s Phase 4 Status
996
+ Vocabulary. Response depends on the token:
997
+
998
+ | Token | Coordinator Response |
999
+ | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1000
+ | `DONE` | Proceed to code review and merge for the epic's branch. |
1001
+ | `DONE_WITH_CONCERNS` | Read the concerns before review. Address correctness/scope issues before merging; note architectural observations for follow-up. Do not merge blind. |
1002
+ | `NEEDS_CONTEXT` | Answer the question, then re-dispatch the implementer with the missing context. |
1003
+ | `BLOCKED` | Assess the blocker: context problem → re-dispatch with more context; task too large → split it; stronger reasoning needed → re-dispatch on a more capable model; plan wrong → escalate to the user. Never force the same model to retry without changes. |
1004
+
1005
+ **Never ignore a status escalation or silently re-dispatch.** If the implementer
1006
+ reports `BLOCKED` or `NEEDS_CONTEXT`, something must change before retrying —
1007
+ provide missing context, split the task, switch models, or escalate.