@zigrivers/scaffold 3.27.0 → 3.28.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 (47) hide show
  1. package/content/knowledge/core/ai-memory-management.md +17 -0
  2. package/content/knowledge/core/claude-md-patterns.md +2 -2
  3. package/content/knowledge/core/coding-conventions.md +2 -2
  4. package/content/knowledge/core/task-decomposition.md +4 -4
  5. package/content/knowledge/core/task-tracking.md +120 -29
  6. package/content/knowledge/core/user-stories.md +1 -1
  7. package/content/knowledge/execution/multi-agent-coordination.md +118 -0
  8. package/content/knowledge/execution/task-claiming-strategy.md +15 -3
  9. package/content/knowledge/execution/worktree-management.md +5 -3
  10. package/content/pipeline/build/multi-agent-resume.md +27 -7
  11. package/content/pipeline/build/multi-agent-start.md +35 -7
  12. package/content/pipeline/build/new-enhancement.md +8 -1
  13. package/content/pipeline/build/quick-task.md +9 -0
  14. package/content/pipeline/build/single-agent-resume.md +11 -4
  15. package/content/pipeline/build/single-agent-start.md +13 -4
  16. package/content/pipeline/consolidation/workflow-audit.md +1 -1
  17. package/content/pipeline/environment/git-workflow.md +2 -2
  18. package/content/pipeline/foundation/beads.md +148 -22
  19. package/content/pipeline/foundation/coding-standards.md +1 -1
  20. package/content/tools/post-implementation-review.md +6 -6
  21. package/content/tools/prompt-pipeline.md +1 -1
  22. package/content/tools/release.md +5 -5
  23. package/content/tools/review-code.md +347 -3
  24. package/content/tools/review-pr.md +349 -7
  25. package/content/tools/version-bump.md +5 -5
  26. package/dist/cli/commands/observe.d.ts +2 -0
  27. package/dist/cli/commands/observe.d.ts.map +1 -1
  28. package/dist/cli/commands/observe.js +9 -1
  29. package/dist/cli/commands/observe.js.map +1 -1
  30. package/dist/cli/commands/observe.test.js +36 -0
  31. package/dist/cli/commands/observe.test.js.map +1 -1
  32. package/dist/observability/adapters/beads.d.ts +4 -0
  33. package/dist/observability/adapters/beads.d.ts.map +1 -1
  34. package/dist/observability/adapters/beads.js +25 -2
  35. package/dist/observability/adapters/beads.js.map +1 -1
  36. package/dist/observability/adapters/beads.test.js +40 -2
  37. package/dist/observability/adapters/beads.test.js.map +1 -1
  38. package/dist/observability/engine/ledger-writer.d.ts +11 -1
  39. package/dist/observability/engine/ledger-writer.d.ts.map +1 -1
  40. package/dist/observability/engine/ledger-writer.js +6 -0
  41. package/dist/observability/engine/ledger-writer.js.map +1 -1
  42. package/dist/observability/engine/llm-dispatcher.d.ts.map +1 -1
  43. package/dist/observability/engine/llm-dispatcher.js +36 -5
  44. package/dist/observability/engine/llm-dispatcher.js.map +1 -1
  45. package/dist/observability/engine/llm-dispatcher.test.js +23 -0
  46. package/dist/observability/engine/llm-dispatcher.test.js.map +1 -1
  47. package/package.json +1 -1
@@ -9,7 +9,7 @@ outputs: []
9
9
  conditional: null
10
10
  stateless: true
11
11
  category: pipeline
12
- knowledge-base: [tdd-execution-loop, task-claiming-strategy, worktree-management]
12
+ knowledge-base: [tdd-execution-loop, task-claiming-strategy, worktree-management, multi-agent-coordination]
13
13
  reads: [coding-standards, tdd, git-workflow]
14
14
  argument-hint: "<agent-name>"
15
15
  ---
@@ -90,7 +90,7 @@ Before writing any code, verify the worktree environment:
90
90
  - If on a feature branch with changes, redirect to `/scaffold:multi-agent-resume $ARGUMENTS`
91
91
 
92
92
  3. **Beads identity** (if `.beads/` exists)
93
- - `echo $BD_ACTOR` — should show `$ARGUMENTS`
93
+ - `echo $BEADS_ACTOR` — should show `$ARGUMENTS`
94
94
  - If not set, the worktree setup may be incomplete
95
95
 
96
96
  4. **Dependency check**
@@ -119,11 +119,13 @@ These rules are critical for multi-agent operation:
119
119
 
120
120
  **If Beads is configured** (`.beads/` exists):
121
121
  - Branch naming: `bd-<id>/<desc>`
122
- - Run `bd ready` to see available tasks
123
- - Pick the lowest-ID unblocked task
122
+ - Verify `$BEADS_ACTOR` is set per agent (echo it; bail if empty).
123
+ - Atomically claim the next ready task: `TASK=$(bd ready --claim --json | jq -r '.id')`
124
+ - This sets `assignee=$BEADS_ACTOR` and `status=in_progress` in a single round-trip — eliminates the race window where two agents both see the same "ready" task.
125
+ - If `bd ready --claim` returns no task, you're done — exit the loop.
124
126
  - Implement following the TDD workflow below
125
- - After PR is merged: `bd close <id> && bd sync`
126
- - Repeat with `bd ready` until no tasks remain
127
+ - After PR is merged: `bd close <id>`
128
+ - Repeat (`bd ready --claim --json`) until no tasks remain
127
129
 
128
130
  **Without Beads:**
129
131
  - Branch naming: `<type>/<desc>` (e.g., `feat/add-auth`)
@@ -174,8 +176,28 @@ For each task:
174
176
  - Fix any findings at or above `fix_threshold` before proceeding
175
177
 
176
178
  7. **Create PR**
179
+ - If Beads is configured, run the PR-readiness checklist first:
180
+ ```bash
181
+ if [ -d .beads ]; then
182
+ bd preflight
183
+ fi
184
+ ```
185
+ Fix any issues `bd preflight` flags before proceeding.
186
+ - **For 3+ parallel agents**, acquire the project's merge slot to serialize merge-time conflicts:
187
+ ```bash
188
+ if [ -d .beads ]; then
189
+ bd merge-slot acquire --wait # blocks if held; queues you in priority order
190
+ fi
191
+ ```
192
+ There is one merge slot per project; `--wait` blocks until you have it. Skip for single-agent or two-agent runs. See `content/knowledge/execution/multi-agent-coordination.md`.
177
193
  - Push the branch: `git push -u origin HEAD`
178
194
  - Create a pull request: `gh pr create`
195
+ - After the PR merges (or if you abandon the work), release the slot:
196
+ ```bash
197
+ if [ -d .beads ]; then
198
+ bd merge-slot release # holder verified via $BEADS_ACTOR
199
+ fi
200
+ ```
179
201
  - Include in the PR description: what was implemented, key decisions, files changed, agent name
180
202
  - Follow the PR workflow from `docs/git-workflow.md` or CLAUDE.md
181
203
 
@@ -210,10 +232,16 @@ For each task:
210
232
  - Resolve conflicts, re-run tests, force-push the branch
211
233
 
212
234
  **Another agent claimed the same task:**
213
- - If Beads: `bd sync` will reveal the conflict pick a different task
235
+ - If Beads: A `git pull` (and `bd dolt pull` if a Dolt remote is configured) brings the local DB current; run `bd doctor --fix` if anything looks stale.
214
236
  - Without Beads: check open PRs (`gh pr list`) for overlapping work
215
237
  - Move to the next available unblocked task
216
238
 
239
+ **A downstream task is blocked on a specific async condition (PR merge, workflow run, timer, human decision):**
240
+ - If Beads: create a gate that blocks the downstream task. The gate has an auto-generated ID. For a PR-merge blocker: `bd gate create --type=gh:pr --blocks <task-id> --await-id=<pr-number> --reason "..."`. For a human-resolved blocker: `bd gate create --blocks <task-id> --reason "..."` (defaults to `--type=human`). Capture the gate ID via `--json | jq -r '.id'` if you need to resolve manually later.
241
+ - The gated task disappears from `bd ready` until the gate resolves. `gh:pr` / `gh:run` / `timer` gates auto-resolve via watchers; `human` gates resolve via `bd gate resolve <gate-id>`.
242
+ - If multiple downstream tasks share one underlying blocker, create one gate per blocked task pointing at the same `--await-id`. For dependency-style blocking ("this task can't start until that task finishes"), use `bd dep add --blocks` instead.
243
+ - See `content/knowledge/execution/multi-agent-coordination.md` for the full pattern.
244
+
217
245
  **Dependency install fails after cleanup:**
218
246
  - `git clean -fd` may have removed generated files — re-run the full install sequence
219
247
  - If persistent, check if another agent's merge changed the dependency file
@@ -263,9 +263,16 @@ For each user story (or logical grouping of small stories):
263
263
  **If Beads:**
264
264
  ```bash
265
265
  bd create "US-XXX: <imperative title>" -p <priority>
266
- # Priority: 0=blocking release, 1=must-have, 2=should-have, 3=nice-to-have
266
+ # Priority: 0=blocking release, 1=must-have, 2=should-have, 3=nice-to-have, 4=backlog
267
267
  ```
268
268
 
269
+ For architectural decisions (ADRs), use the built-in `decision` type:
270
+ ```bash
271
+ bd create "Use Postgres over MySQL for X" -t decision -p 1
272
+ ```
273
+
274
+ If your project enables custom types via `bd config set types.custom '["story","milestone","spike"]'`, you can also use `-t story` for user-story-sized work and `-t milestone` for releases.
275
+
269
276
  **Without Beads:** Document tasks as a structured list in `docs/implementation-plan.md` with title, priority, dependencies, and description.
270
277
 
271
278
  #### Task Titles and Descriptions
@@ -157,6 +157,7 @@ Assign priority using Beads conventions:
157
157
  - **P1** — Must-have for current milestone
158
158
  - **P2** — Should-have (default for most quick tasks)
159
159
  - **P3** — Nice-to-have, backlog
160
+ - **P4** — Backlog / future-consideration (lowest priority; effectively deferred)
160
161
 
161
162
  #### Acceptance Criteria
162
163
  Write 2-5 testable acceptance criteria in Given/When/Then format:
@@ -202,6 +203,14 @@ bd create "type(scope): description" -p <priority>
202
203
  # Example: bd create "fix(auth): prevent duplicate session creation on rapid re-login" -p 2
203
204
  ```
204
205
 
206
+ If this task was discovered while doing other work, link the lineage with `discovered-from`:
207
+ ```bash
208
+ bd create "fix(parser): handle empty input edge case" \
209
+ --type bug -p 2 \
210
+ --deps discovered-from:$CURRENT_TASK_ID
211
+ ```
212
+ The new task appears in `bd ready` normally; `discovered-from` is metadata for traceability and does NOT block readiness.
213
+
205
214
  **Without Beads:** Document the task inline and proceed directly to implementation.
206
215
 
207
216
  Then set the task description with the full context from Phase 2. Include all of:
@@ -98,10 +98,10 @@ Recover your context by checking the current state of work:
98
98
 
99
99
  **If Beads is configured** (`.beads/` exists):
100
100
  - `bd list` — check for tasks with `in_progress` status
101
- - If a PR shows as merged, close the corresponding task: `bd close <id> && bd sync`
101
+ - If a PR shows as merged, close the corresponding task: `bd close <id>`
102
102
  - If there is in-progress work, finish it (see "Resume In-Progress Work" below)
103
- - Otherwise, start fresh with `bd ready` to find the next available task
104
- - Continue working until `bd ready` shows no available tasks
103
+ - Otherwise, atomically claim the next ready task: `TASK=$(bd ready --claim --json | jq -r '.id')` (sets `assignee=$BEADS_ACTOR` + `status=in_progress`; no race window).
104
+ - Continue working until `bd ready --claim --json` returns no task.
105
105
 
106
106
  **Without Beads:**
107
107
  - Read `docs/implementation-playbook.md` as the primary task reference.
@@ -148,6 +148,13 @@ Once in-progress work is complete (or if there was none):
148
148
  - Fix any findings at or above `fix_threshold` before proceeding
149
149
 
150
150
  3. **Create PR** (if not already created for in-progress work)
151
+ - If Beads is configured, run the PR-readiness checklist first:
152
+ ```bash
153
+ if [ -d .beads ]; then
154
+ bd preflight
155
+ fi
156
+ ```
157
+ Fix any issues `bd preflight` flags before proceeding.
151
158
  - Push the branch: `git push -u origin HEAD`
152
159
  - Create a pull request: `gh pr create`
153
160
  - Follow the PR workflow from `docs/git-workflow.md` or CLAUDE.md
@@ -187,7 +194,7 @@ Once in-progress work is complete (or if there was none):
187
194
  - Push updates and re-request review
188
195
 
189
196
  **Task was completed by another agent (multi-agent overlap):**
190
- - If Beads: `bd sync` will show updated task states
197
+ - If Beads: A `git pull` (and `bd dolt pull` if a Dolt remote is configured) brings the local DB current; run `bd doctor --fix` if anything looks stale.
191
198
  - Without Beads: check the plan/playbook for recently completed tasks
192
199
  - Skip to the next available task
193
200
 
@@ -101,11 +101,13 @@ Before writing any code, verify the environment is ready:
101
101
  Check if `.beads/` directory exists.
102
102
 
103
103
  **If Beads is configured:**
104
- - Run `bd ready` to see available tasks
105
- - Pick the lowest-ID unblocked task
104
+ - Atomically claim the next ready task: `TASK=$(bd ready --claim --json | jq -r '.id')`
105
+ - This sets `assignee=$BEADS_ACTOR` (or your git user.name) and `status=in_progress` in a single round-trip no race window vs other agents.
106
+ - If you need a specific task by ID instead, use `bd update <id> --claim`.
107
+ - If `bd ready --claim` returns no task, you're done — exit the loop.
106
108
  - Implement following the TDD workflow below
107
- - After PR is merged, run `bd close <id> && bd sync`
108
- - Repeat with `bd ready` until no tasks remain
109
+ - After PR is merged, run `bd close <id>`
110
+ - Repeat (`bd ready --claim --json`) until no tasks remain
109
111
 
110
112
  **Without Beads:**
111
113
  1. Read `docs/implementation-playbook.md` as the primary task execution reference.
@@ -153,6 +155,13 @@ For each task:
153
155
  - Fix any findings at or above `fix_threshold` before proceeding
154
156
 
155
157
  7. **Create PR**
158
+ - If Beads is configured, run the PR-readiness checklist first:
159
+ ```bash
160
+ if [ -d .beads ]; then
161
+ bd preflight
162
+ fi
163
+ ```
164
+ Fix any issues `bd preflight` flags before proceeding. (Note: do NOT use `[ -d .beads ] && bd preflight` — that returns exit-1 when `.beads/` is absent and breaks any caller running under `set -e`.)
156
165
  - Push the branch: `git push -u origin HEAD`
157
166
  - Create a pull request: `gh pr create`
158
167
  - Include in the PR description: what was implemented, key decisions, files changed
@@ -37,7 +37,7 @@ inconsistent command formats. Fix all issues found.
37
37
 
38
38
  ## Quality Criteria
39
39
  - (mvp) CLAUDE.md contains complete workflow (9 steps + AI review step 4.5)
40
- - (mvp) Commit format is consistent everywhere (If Beads: [BD-<id>] type(scope): description. Without Beads: type(scope): description)
40
+ - (mvp) Commit format is consistent everywhere (If Beads: [bd-<id>] type(scope): description. Without Beads: type(scope): description)
41
41
  - (mvp) Branch naming is consistent everywhere (If Beads: bd-<task-id>/<short-desc>. Without Beads: <type>/<short-desc>)
42
42
  - (mvp) PR workflow includes all 8 sub-steps with --delete-branch flag
43
43
  - (mvp) If Beads: task closure uses bd close (not bd update --status completed)
@@ -34,11 +34,11 @@ parallel agents, CI pipeline, branch protection, and conflict prevention rules.
34
34
 
35
35
  ## Quality Criteria
36
36
  - (mvp) Branch naming format is consistent (Beads: bd-<task-id>/<desc>. Non-Beads: <type>/<desc>)
37
- - (mvp) Commit format is consistent (Beads: [BD-<id>] type(scope): desc. Non-Beads: type(scope): desc)
37
+ - (mvp) Commit format is consistent (Beads: [bd-<id>] type(scope): desc. Non-Beads: type(scope): desc)
38
38
  - (deep) PR workflow includes all 8 sub-steps (commit, AI review, rebase, push, create,
39
39
  auto-merge with --delete-branch, watch CI, confirm merge)
40
40
  - (deep) Worktree script creates permanent worktrees with workspace branches
41
- - (deep) If Beads: BD_ACTOR environment variable documented for agent identity
41
+ - (deep) If Beads: BEADS_ACTOR environment variable documented for agent identity
42
42
  - (deep) CI workflow job name matches branch protection context
43
43
  - (mvp) Branch cleanup documented for both single-agent and worktree-agent variants
44
44
  - (deep) Agent crash recovery procedure documented
@@ -21,34 +21,157 @@ and autonomous behavior guidelines.
21
21
  - Existing CLAUDE.md (optional) — if present, operates in update mode
22
22
 
23
23
  ## Expected Outputs
24
- - .beads/ directory — initialized Beads data store with git hooks
24
+ - .beads/ directory — initialized Beads data store with git hooks (installed/repaired via `bd doctor --fix`)
25
25
  - tasks/lessons.md — patterns and anti-patterns file for cross-session learning
26
- - CLAUDE.md — initial skeleton with Core Principles, Task Management (Beads),
27
- Self-Improvement, and Autonomous Behavior sections
26
+ - CLAUDE.md — marker-managed Beads integration block installed via `bd setup claude`
27
+ (the recipe owns the section between `<!-- BEGIN BEADS INTEGRATION ... -->` and
28
+ `<!-- END BEADS INTEGRATION -->`; survives re-runs). The recipe wires `bd prime
29
+ --hook-json` into SessionStart/PreCompact hooks so agent context is loaded
30
+ automatically. Scaffold adds its own Core Principles + commit convention sections
31
+ AROUND that block but does NOT hand-roll the Beads command reference — `bd prime`
32
+ is the single source of truth for agent context.
28
33
 
29
34
  ## Quality Criteria
30
35
  - (mvp) `bd ready` executes without error (Beads is initialized)
31
36
  - (mvp) .beads/ directory exists and contains Beads data files
32
- - (mvp) Beads git hooks are installed (data-sync hooks, not code-quality hooks)
37
+ - (mvp) Beads git hooks are installed; `bd doctor --fix` was run after `bd init` to
38
+ ensure hooks/config are current (idempotent — also the canonical recovery path if
39
+ `bd` is upgraded later)
33
40
  - (mvp) tasks/lessons.md exists with Patterns, Anti-Patterns, and Common Gotchas sections
34
- - (mvp) CLAUDE.md contains Core Principles with all four tenets (Simplicity, No Laziness, TDD, Prove It)
35
- - (mvp) CLAUDE.md contains Beads command reference table
36
- - (mvp) CLAUDE.md contains commit-message convention requiring Beads task IDs
37
- - (mvp) Bootstrap commit uses `[BD-0]` convention
41
+ - (mvp) `bd setup claude` was run after `bd init` to install the upstream-managed
42
+ Beads integration block in CLAUDE.md (marker-wrapped, hook-driven). For projects
43
+ also targeting Codex CLI or Gemini CLI: `bd setup codex` and/or `bd setup gemini`
44
+ were run. Verify with `bd setup claude --check`.
45
+ - (mvp) CLAUDE.md contains Core Principles with all four tenets (Simplicity, No Laziness, TDD, Prove It) — scaffold-owned content, ADJACENT to the Beads-managed block
46
+ - (mvp) CLAUDE.md contains commit-message convention requiring Beads task IDs — scaffold-owned content
47
+ - (mvp) CLAUDE.md contains an upgrade-remediation callout: "If `bd` was upgraded since
48
+ last `bd init`, run `bd doctor --fix` to re-sync git hooks and project config. This
49
+ fixes errors like `unknown command \"hook\" for \"bd\"` from stale post-checkout /
50
+ post-merge hook shims."
51
+ - (mvp) Bootstrap commit uses `[bd-<id>]` convention (lowercase hash-style IDs per Beads v1.0.0+)
52
+ - (mvp) Auto-export to `.beads/issues.jsonl` is explicitly enabled after `bd init`:
53
+ `bd config set export.auto true && bd config set export.git-add true`. As of
54
+ Beads v1.0.4-Unreleased this is opt-in (previously default); explicit enable means
55
+ release/version-bump tooling can rely on `.beads/issues.jsonl` being current.
56
+ - (mvp) Agents pick up Beads workflow context via `bd prime` (loaded automatically by
57
+ the hooks `bd setup claude` installs). Scaffold does NOT hand-roll a Beads command
58
+ reference table — that lives upstream in `bd prime` output. If a project wants
59
+ custom prime content, write `.beads/PRIME.md`.
60
+ - (deep) `bd config set types.custom '["story","milestone","spike"]'` was run so
61
+ downstream prompts can use `-t story` and `-t milestone`. Verify with `bd config get types.custom`.
38
62
  - (deep) Cross-doc consistency verified against git-workflow.md and coding-standards.md
39
63
 
40
64
  ## Methodology Scaling
41
- - **deep**: Full Beads setup with all CLAUDE.md sections, detailed command reference
42
- table, priority level documentation, and cross-doc consistency checks against
65
+ - **deep**: Full Beads setup `bd init`, then `bd doctor --fix`, then `bd setup
66
+ claude` (and/or `bd setup codex`, `bd setup gemini` for multi-platform projects).
67
+ Enable custom issue types via `bd config set types.custom '["story","milestone","spike"]'`
68
+ so downstream prompts can use `-t story` for user stories and `-t milestone` for
69
+ releases. Scaffold-owned CLAUDE.md content (Core Principles + commit convention +
70
+ upgrade-remediation callout) is composed ADJACENT to the recipe-managed integration
71
+ block. Detailed priority level documentation. Cross-doc consistency checks against
43
72
  existing git-workflow.md and coding-standards.md.
44
- - **mvp**: Initialize Beads, create tasks/lessons.md, add minimal CLAUDE.md
45
- sections (Core Principles + Beads commands). Skip cross-doc checks.
73
+ - **mvp**: `bd init`, `bd doctor --fix`, `bd setup claude`, create tasks/lessons.md,
74
+ add minimal scaffold-owned CLAUDE.md sections (Core Principles + commit convention +
75
+ upgrade-remediation callout). Skip cross-doc checks. Custom types stay off — only
76
+ built-in `bug|feature|task|epic|chore|decision` available.
46
77
  - **custom:depth(1-5)**:
47
- - Depth 1: Initialize Beads + create tasks/lessons.md. Minimal CLAUDE.md with Core Principles only.
48
- - Depth 2: Depth 1 + add Beads command reference table to CLAUDE.md.
49
- - Depth 3: Add full command table, priority level documentation, and autonomous behavior rules.
50
- - Depth 4: Full setup with cross-doc consistency checks against git-workflow.md and coding-standards.md.
51
- - Depth 5: Full setup + detailed autonomous behavior rules + commit-message convention enforcement.
78
+ - Depth 1: `bd init` + `bd doctor --fix` + `bd setup claude` + create tasks/lessons.md. Minimal scaffold CLAUDE.md content (Core Principles only).
79
+ - Depth 2: Depth 1 + add commit convention + upgrade-remediation callout.
80
+ - Depth 3: Add priority level documentation and autonomous behavior rules.
81
+ - Depth 4: Full setup with cross-doc consistency checks against git-workflow.md and coding-standards.md. Enable `bd config set types.custom '["story","milestone","spike"]'`.
82
+ - Depth 5: Full setup + detailed autonomous behavior rules + commit-message convention enforcement. Run `bd setup codex` and `bd setup gemini` if the project targets those CLIs.
83
+
84
+ ## Instructions
85
+
86
+ Execute these steps in order. Each is idempotent — re-running this prompt on an
87
+ existing setup updates rather than re-initializes.
88
+
89
+ 1. **Initialize Beads** (skip if `.beads/` already contains a Dolt DB):
90
+ ```bash
91
+ bd init
92
+ ```
93
+
94
+ 2. **Sync hooks and project config against the installed bd version** (idempotent; also
95
+ the canonical recovery path if `bd` is upgraded later):
96
+ ```bash
97
+ bd doctor --fix
98
+ ```
99
+
100
+ 3. **Install the upstream-managed editor integration** for whichever AI agent CLI
101
+ the project targets. The recipe writes a marker-managed block in CLAUDE.md /
102
+ AGENTS.md / GEMINI.md and installs the SessionStart hooks that load
103
+ `bd prime --hook-json`:
104
+ ```bash
105
+ bd setup claude # Claude Code (always)
106
+ bd setup codex # Codex CLI (multi-platform projects only)
107
+ bd setup gemini # Gemini CLI (multi-platform projects only)
108
+ ```
109
+ Verify with `bd setup claude --check`.
110
+
111
+ 4. **Create the project merge-slot** (one-time; idempotent — re-running on an
112
+ existing slot is a no-op). This is required by the multi-agent flow's
113
+ `bd merge-slot acquire --wait` later, and creating it now means downstream
114
+ PR steps can rely on it being present:
115
+ ```bash
116
+ bd merge-slot create 2>/dev/null || true # exit 0 even if slot already exists
117
+ ```
118
+
119
+ 5. **Enable JSONL auto-export** so release/version-bump tooling can rely on
120
+ `.beads/issues.jsonl` being current (Beads v1.0.4-Unreleased flipped these
121
+ to opt-in):
122
+ ```bash
123
+ bd config set export.auto true
124
+ bd config set export.git-add true
125
+ ```
126
+
127
+ 6. **(deep methodology only) Enable custom issue types** so downstream prompts can
128
+ use `-t story` for user stories and `-t milestone` for releases:
129
+ ```bash
130
+ bd config set types.custom '["story","milestone","spike"]'
131
+ ```
132
+ Verify with `bd config get types.custom`.
133
+
134
+ 7. **Create the lessons-learned file** for cross-session memory (skip if it already exists — never overwrite accumulated lessons):
135
+ ```bash
136
+ mkdir -p tasks
137
+ if [ ! -f tasks/lessons.md ]; then
138
+ cat > tasks/lessons.md <<'EOF'
139
+ # Lessons Learned
140
+
141
+ ## Patterns
142
+
143
+ (Add discovered patterns here.)
144
+
145
+ ## Anti-Patterns
146
+
147
+ (Add anti-patterns here.)
148
+
149
+ ## Common Gotchas
150
+
151
+ (Add gotchas here.)
152
+ EOF
153
+ else
154
+ # Append any missing section headings; existing content stays.
155
+ grep -q "^## Patterns" tasks/lessons.md || printf '\n## Patterns\n\n(Add discovered patterns here.)\n' >> tasks/lessons.md
156
+ grep -q "^## Anti-Patterns" tasks/lessons.md || printf '\n## Anti-Patterns\n\n(Add anti-patterns here.)\n' >> tasks/lessons.md
157
+ grep -q "^## Common Gotchas" tasks/lessons.md || printf '\n## Common Gotchas\n\n(Add gotchas here.)\n' >> tasks/lessons.md
158
+ fi
159
+ ```
160
+
161
+ 8. **Compose scaffold-owned CLAUDE.md sections** ADJACENT to (not replacing) the
162
+ recipe-managed block from step 3. The scaffold-owned content includes Core
163
+ Principles (Simplicity, No Laziness, TDD, Prove It), the commit-message
164
+ convention (`[bd-<id>]` prefix, lowercase hash IDs), the upgrade-remediation
165
+ callout ("If `bd` was upgraded since last `bd init`, run `bd doctor --fix`..."),
166
+ and (deep) autonomous behavior rules.
167
+
168
+ 9. **Bootstrap commit** with the lowercase hash-style ID convention:
169
+ ```bash
170
+ git add .beads tasks/lessons.md CLAUDE.md
171
+ git commit -m "[bd-<id>] chore: initialize Beads task tracking"
172
+ ```
173
+ The bd-<id> here references whatever bootstrap task you created via
174
+ `bd create "Initialize Beads"` (or the auto-generated bootstrap bead).
52
175
 
53
176
  ## Conditional Evaluation
54
177
  Enable when: project uses Beads task tracking methodology (user selects Beads during
@@ -56,11 +179,14 @@ setup), or user explicitly enables structured task management. Skip when: user p
56
179
  GitHub Issues, Linear, or another task tracker, or explicitly declines Beads setup.
57
180
 
58
181
  ## Mode Detection
59
- Update mode if .beads/ contains a config.json or tasks directory (not just an
60
- empty directory). In update mode: never re-initialize
61
- .beads/ (existing task data is irreplaceable), never overwrite tasks/lessons.md
62
- (only add missing sections), update CLAUDE.md Beads sections in-place preserving
63
- project-specific customizations.
182
+ Update mode if `.beads/` contains a populated database (look for `.beads/embeddeddolt/`
183
+ in the default embedded-Dolt layout, `.beads/dolt/` in server mode, or any `.beads/*.db`
184
+ file). Legacy v0.x Beads used `.beads/config.json` and a `tasks` directory — recognize
185
+ those too for older projects. When unsure, run `bd info` from the project root: a
186
+ populated DB returns project metadata; an uninitialized one errors. In update mode:
187
+ never re-initialize `.beads/` (existing task data is irreplaceable), never overwrite
188
+ `tasks/lessons.md` (only add missing sections), update CLAUDE.md Beads sections
189
+ in-place preserving project-specific customizations.
64
190
 
65
191
  ## Update Mode Specifics
66
192
  - **Detect prior artifact**: .beads/ directory exists with data files
@@ -33,7 +33,7 @@ self-review checklist.
33
33
  ## Quality Criteria
34
34
  - (mvp) Every standard references the specific tech stack, not generic principles
35
35
  - (deep) Includes >= 2 runnable code examples per section showing the RIGHT way for the stack
36
- - (mvp) Commit message format documented: if project uses Beads task tracking: [BD-<id>] type(scope): description; otherwise: type(scope): description following conventional commits
36
+ - (mvp) Commit message format documented: if project uses Beads task tracking: [bd-<id>] type(scope): description; otherwise: type(scope): description following conventional commits
37
37
  - (mvp) AI-specific coding rules section addresses common AI mistakes (dead code,
38
38
  duplication, magic numbers, premature abstraction, unnecessary features)
39
39
  - (mvp) Linter/formatter configs created and referenced from the document
@@ -433,9 +433,9 @@ The per-story review prompt for Codex and Gemini:
433
433
  \"findings\": [
434
434
  {
435
435
  \"severity\": \"P0|P1|P2|P3\",
436
+ \"category\": \"correctness|edge-case|security|acceptance-criteria|test-coverage\",
436
437
  \"acceptance_criterion\": \"Which criterion (or null if general)\",
437
- \"file\": \"relative/path/to/file.ts\",
438
- \"line\": 42,
438
+ \"location\": \"relative/path/to/file.ts:42\",
439
439
  \"description\": \"Specific description\",
440
440
  \"suggestion\": \"How to fix it\"
441
441
  }
@@ -448,7 +448,7 @@ The per-story review prompt for Codex and Gemini:
448
448
  Return ONLY valid JSON."
449
449
 
450
450
  Normalize the Superpowers code-reviewer findings to the same JSON shape as
451
- Codex/Gemini (severity, acceptance_criterion, file, line, description, suggestion)
451
+ Codex/Gemini (severity, category, acceptance_criterion, location, description, suggestion)
452
452
  before returning. Then return all three channels' findings plus channel status:
453
453
  {
454
454
  "story": "[STORY_TITLE]",
@@ -479,8 +479,8 @@ mmr reconcile "$JOB_ID" --channel superpowers --input /tmp/agent-findings.json
479
479
  ```
480
480
 
481
481
  All findings injected via `mmr reconcile` must use MMR-compatible schema: each
482
- finding needs `severity` (P0-P3), `location` (file:line), and `description`
483
- (`suggestion` is optional). The strict validator will reject findings with
482
+ finding needs `severity` (P0-P3), `category` (stable finding category),
483
+ `location` (file:line), and `description` (`suggestion` is optional). The strict validator will reject findings with
484
484
  missing or invalid required fields.
485
485
 
486
486
  This step is optional — post-implementation review is a full-codebase review (not
@@ -721,7 +721,7 @@ the user they require manual attention before the project is ready to release.
721
721
  3. **Auth failures are not silent** — always surface to the user with the exact recovery command (`! codex login` or `! gemini -p "hello"`). Wait for user response before queuing a compensating pass.
722
722
  4. **Independence** — never share one channel's output with another. Each reviews independently.
723
723
  5. **Verify every fix** — run tests (or re-read the file) immediately after each fix before moving on.
724
- 6. **3-round limit (per finding)** — never attempt to fix the *same* blocking finding more than 3 times. Each round that surfaces a *new, different, fixable* finding is healthy iteration — keep going. Stop only when the same finding recurs across 3 attempts, channels contradict each other, or the user asks to stop. Surface unresolved findings to the user.
724
+ 6. **3-round limit (per finding identity)** — never attempt to fix the *same* blocking finding more than 3 times. Mirror the wrapper hash identity used by `review-pr.md` and `review-code.md`: `location` + `category` + `description` + `suggestion`. This tool's JSON prompt templates already require `category`; it does not have wrapper-side Step 7a attempts-file bookkeeping, so track attempts in the review report/session notes. Each round that surfaces genuinely different findings with new identities is healthy iteration — keep going. Stop when an identity hits 3 attempts, when the same underlying defect recurs across 3 rounds even if reviewer wording changes, when channels contradict each other, or when the user asks to stop. Surface unresolved findings to the user.
725
725
  7. **Document everything** — the report must show which channels ran, which were compensating, which were skipped, and the root cause for any degraded channel.
726
726
  8. **No auto-merge** — this tool modifies local files only. It never pushes, merges, or creates PRs.
727
727
  9. **Dispatch pattern cross-reference** — Phase 2 parallel dispatch uses `superpowers:dispatching-parallel-agents`. Each story subagent dispatches its own `superpowers:code-reviewer` as Channel 3. This two-level nesting is intentional and supported.
@@ -27,7 +27,7 @@ Print the following reference directly. Do not read any files or run any command
27
27
  ### Phase 0 — Prerequisites (one-time)
28
28
  | Action | Command |
29
29
  |--------|---------|
30
- | Install Beads | `npm install -g @beads/bd` or `brew install beads` **(optional)** |
30
+ | Install Beads | `curl -fsSL https://raw.githubusercontent.com/gastownhall/beads/main/scripts/install.sh \| bash` (upstream-recommended), `brew install beads`, or `npm install -g @beads/bd` **(optional)** |
31
31
  | Install Playwright MCP | `claude mcp add playwright npx @playwright/mcp@latest` **(optional — web apps only)** |
32
32
 
33
33
  ### Phase 0 — Product Vision (`vision`)
@@ -227,14 +227,14 @@ Omit empty sections. Use the commit's first line (without the type prefix) as th
227
227
 
228
228
  If `.beads/` exists:
229
229
 
230
- 1. Run `bd list --status closed` (or parse `.beads/issues.jsonl` for closed issues).
231
- 2. Cross-reference closed tasks with the commit range (match task IDs like `BD-xxx` or `scaffold-xxx` in commit messages).
230
+ 1. Run `bd list --status closed --json` (canonical). If `bd` is unavailable in this environment, skip the autogenerated closed-tasks section — manual changelog entry expected.
231
+ 2. Cross-reference closed tasks with the commit range (match task IDs like `bd-xxxx` or `scaffold-xxx` in commit messages).
232
232
  3. If matches found, append a section:
233
233
 
234
234
  ```markdown
235
235
  ### Completed Tasks
236
- - [BD-xxx] Task title
237
- - [BD-yyy] Task title
236
+ - [bd-<id>] Task title
237
+ - [bd-<id2>] Task title
238
238
  ```
239
239
 
240
240
  If `.beads/` does not exist or no tasks match, silently skip this section.
@@ -286,7 +286,7 @@ git add <changed-files>
286
286
  git commit -m "chore(release): vX.Y.Z"
287
287
  ```
288
288
 
289
- If Beads is configured (`.beads/` exists) and a task is active, include the task ID: `[BD-xxx] chore(release): vX.Y.Z`.
289
+ If Beads is configured (`.beads/` exists) and a task is active, include the task ID: `[bd-<id>] chore(release): vX.Y.Z`.
290
290
 
291
291
  ---
292
292