@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.
- package/content/knowledge/core/ai-memory-management.md +17 -0
- package/content/knowledge/core/claude-md-patterns.md +2 -2
- package/content/knowledge/core/coding-conventions.md +2 -2
- package/content/knowledge/core/task-decomposition.md +4 -4
- package/content/knowledge/core/task-tracking.md +120 -29
- package/content/knowledge/core/user-stories.md +1 -1
- package/content/knowledge/execution/multi-agent-coordination.md +118 -0
- package/content/knowledge/execution/task-claiming-strategy.md +15 -3
- package/content/knowledge/execution/worktree-management.md +5 -3
- package/content/pipeline/build/multi-agent-resume.md +27 -7
- package/content/pipeline/build/multi-agent-start.md +35 -7
- package/content/pipeline/build/new-enhancement.md +8 -1
- package/content/pipeline/build/quick-task.md +9 -0
- package/content/pipeline/build/single-agent-resume.md +11 -4
- package/content/pipeline/build/single-agent-start.md +13 -4
- package/content/pipeline/consolidation/workflow-audit.md +1 -1
- package/content/pipeline/environment/git-workflow.md +2 -2
- package/content/pipeline/foundation/beads.md +148 -22
- package/content/pipeline/foundation/coding-standards.md +1 -1
- package/content/tools/post-implementation-review.md +6 -6
- package/content/tools/prompt-pipeline.md +1 -1
- package/content/tools/release.md +5 -5
- package/content/tools/review-code.md +347 -3
- package/content/tools/review-pr.md +349 -7
- package/content/tools/version-bump.md +5 -5
- package/dist/cli/commands/observe.d.ts +2 -0
- package/dist/cli/commands/observe.d.ts.map +1 -1
- package/dist/cli/commands/observe.js +9 -1
- package/dist/cli/commands/observe.js.map +1 -1
- package/dist/cli/commands/observe.test.js +36 -0
- package/dist/cli/commands/observe.test.js.map +1 -1
- package/dist/observability/adapters/beads.d.ts +4 -0
- package/dist/observability/adapters/beads.d.ts.map +1 -1
- package/dist/observability/adapters/beads.js +25 -2
- package/dist/observability/adapters/beads.js.map +1 -1
- package/dist/observability/adapters/beads.test.js +40 -2
- package/dist/observability/adapters/beads.test.js.map +1 -1
- package/dist/observability/engine/ledger-writer.d.ts +11 -1
- package/dist/observability/engine/ledger-writer.d.ts.map +1 -1
- package/dist/observability/engine/ledger-writer.js +6 -0
- package/dist/observability/engine/ledger-writer.js.map +1 -1
- package/dist/observability/engine/llm-dispatcher.d.ts.map +1 -1
- package/dist/observability/engine/llm-dispatcher.js +36 -5
- package/dist/observability/engine/llm-dispatcher.js.map +1 -1
- package/dist/observability/engine/llm-dispatcher.test.js +23 -0
- package/dist/observability/engine/llm-dispatcher.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,23 @@ AI memory operates in layers, each with different persistence and token cost:
|
|
|
22
22
|
| **MCP memory server** | Cross-session (structured) | Low (queried on demand) | Decisions, lessons, error patterns |
|
|
23
23
|
| **External docs** | Always current | Zero until queried | Library APIs, framework docs |
|
|
24
24
|
|
|
25
|
+
### When to use which: user-level vs project-level memory
|
|
26
|
+
|
|
27
|
+
Two persistent memory mechanisms can coexist on one machine. They serve different scopes — pick the right one for each fact:
|
|
28
|
+
|
|
29
|
+
| Scope | Mechanism | Lives in | Survives across | Shared with team? |
|
|
30
|
+
|-------|-----------|----------|-----------------|-------------------|
|
|
31
|
+
| **User-level** (per-user, cross-project) | Filesystem auto-memory (Claude Code client) | `~/.claude/projects/<encoded-cwd>/memory/*.md` | Sessions, projects | No — local to your machine |
|
|
32
|
+
| **Project-level** (per-project, team-shareable) | `bd remember` (Beads) | `.beads/embeddeddolt/` | Sessions, repo clones | Yes — committed and synced via Dolt |
|
|
33
|
+
|
|
34
|
+
Rule of thumb:
|
|
35
|
+
- Facts about the **person** (role, expertise level, communication style, preferences) → filesystem auto-memory.
|
|
36
|
+
- Facts about the **project** (in-flight context, team conventions, project-specific blockers, decisions) → `bd remember`.
|
|
37
|
+
|
|
38
|
+
When `.beads/` exists in a project, prefer `bd remember` for project facts so teammates inherit the context. When working in a project without Beads, the filesystem layer is your only persistent memory.
|
|
39
|
+
|
|
40
|
+
> Upstream Beads's AGENTS.md says "do not create MEMORY.md files" — that prescription is about project memory specifically. Filesystem auto-memory continues to be the right layer for *user* memory (facts about you, not the project).
|
|
41
|
+
|
|
25
42
|
### Core Principle: Signal Over Volume
|
|
26
43
|
|
|
27
44
|
ETH Zurich research (2026) found that dumping context into AI sessions hurts more than it helps — 3% performance decrease with 20% cost increase for LLM-generated context files. The key insight: **only store what cannot be derived from the code itself.** Custom build commands, project-specific conventions, decision rationale, and team agreements are high-signal. Code patterns, file structure, and API shapes are low-signal (the agent can read the code).
|
|
@@ -41,7 +41,7 @@ Rules must be specific, actionable, and testable:
|
|
|
41
41
|
**Good rules:**
|
|
42
42
|
- "Run `make check` before every commit"
|
|
43
43
|
- "Never push directly to main — always use branch + PR"
|
|
44
|
-
- "Every commit message starts with `[
|
|
44
|
+
- "Every commit message starts with `[bd-<id>]` task ID"
|
|
45
45
|
|
|
46
46
|
**Bad rules:**
|
|
47
47
|
- "Write clean code" — what does clean mean?
|
|
@@ -243,7 +243,7 @@ When updating a section, prefer additive changes over destructive ones:
|
|
|
243
243
|
|
|
244
244
|
**Stale commands.** Key Commands table references `npm test` but the project switched to `bun test` two months ago. The agent runs the wrong command and wastes a cycle. Fix: keep Key Commands in sync with actual build tool configuration. The `claude-md-optimization` step verifies this.
|
|
245
245
|
|
|
246
|
-
**Conflicting rules.** CLAUDE.md says "always use conventional commits" in one section and "use `[
|
|
246
|
+
**Conflicting rules.** CLAUDE.md says "always use conventional commits" in one section and "use `[bd-<id>]` prefix" in another, with no guidance on which takes precedence. Fix: consolidate commit message rules in one place. If both apply, show the combined format: `[bd-a3f8] feat(api): implement endpoint`.
|
|
247
247
|
|
|
248
248
|
**Redundant instructions.** The same rule appears in Core Principles, Workflow, and Rules sections with slightly different wording. The agent may follow one version and violate another. Fix: state each rule once in its canonical section. Other sections reference it.
|
|
249
249
|
|
|
@@ -39,7 +39,7 @@ If a convention cannot be checked by a tool, it will not be followed consistentl
|
|
|
39
39
|
|
|
40
40
|
### Comment Philosophy at a Glance
|
|
41
41
|
|
|
42
|
-
Comments explain **why**, not **what**. If you need a comment to explain what code does, the code is too complex — refactor first. Extract well-named functions, use descriptive variables, replace magic numbers with constants. TODOs must include a task ID: `// TODO [
|
|
42
|
+
Comments explain **why**, not **what**. If you need a comment to explain what code does, the code is too complex — refactor first. Extract well-named functions, use descriptive variables, replace magic numbers with constants. TODOs must include a task ID: `// TODO [bd-<id>]: Reason`. Bare TODOs are not allowed.
|
|
43
43
|
|
|
44
44
|
## Deep Guidance
|
|
45
45
|
|
|
@@ -106,7 +106,7 @@ Comments explain **why**, not **what**. If you need a comment to explain what co
|
|
|
106
106
|
|
|
107
107
|
**Documentation comments**: Public APIs always need documentation comments. TypeScript uses JSDoc `/** */`. Python uses docstrings. Go uses comments above exported identifiers starting with the identifier name.
|
|
108
108
|
|
|
109
|
-
**TODO format**: `// TODO [
|
|
109
|
+
**TODO format**: `// TODO [bd-<id>]: Reason for the TODO`. Also `FIXME [bd-<id2>]` and `HACK [bd-<id3>]`. Bare TODOs without task IDs accumulate without accountability and are not allowed.
|
|
110
110
|
|
|
111
111
|
### Error Handling Patterns by Language
|
|
112
112
|
|
|
@@ -12,7 +12,7 @@ Expert knowledge for breaking user stories into implementable tasks with depende
|
|
|
12
12
|
|
|
13
13
|
### Story-to-Task Mapping
|
|
14
14
|
|
|
15
|
-
User stories bridge PRD features and implementation tasks. Each story decomposes into tasks following the technical layers needed. Every task must trace back to a user story, and every story to a PRD feature (PRD Feature → US-xxx → Task
|
|
15
|
+
User stories bridge PRD features and implementation tasks. Each story decomposes into tasks following the technical layers needed. Every task must trace back to a user story, and every story to a PRD feature (PRD Feature → US-xxx → Task bd-<id>).
|
|
16
16
|
|
|
17
17
|
### Task Sizing
|
|
18
18
|
|
|
@@ -146,9 +146,9 @@ Every task must trace back to a user story, and every user story must trace to a
|
|
|
146
146
|
```
|
|
147
147
|
PRD Feature: User Profile Management
|
|
148
148
|
-> US-002: Edit display name and bio
|
|
149
|
-
-> Task
|
|
150
|
-
-> Task
|
|
151
|
-
-> Task
|
|
149
|
+
-> Task bd-a3f8: implement PATCH /api/v1/users/:id
|
|
150
|
+
-> Task bd-a3f9: add profile edit form component
|
|
151
|
+
-> Task bd-a3fa: add profile edit page with state management
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
This traceability ensures:
|
|
@@ -18,7 +18,9 @@ Core properties:
|
|
|
18
18
|
- **Repository-local** — Task data lives in `.beads/`, committed alongside code
|
|
19
19
|
- **Git-hook synced** — Task state updates automatically on commit via data-sync hooks
|
|
20
20
|
- **CLI-driven** — All operations via `bd` commands (create, list, status, ready)
|
|
21
|
-
- **ID-prefixed commits** — Every commit message includes `[
|
|
21
|
+
- **ID-prefixed commits** — Every commit message includes `[bd-<id>]` for traceability
|
|
22
|
+
|
|
23
|
+
> IDs are hash-based and lowercase (e.g., `bd-a3f8`). The `bd-` prefix is configurable at `bd init` time. Hierarchical IDs for epic children: `bd-a3f8.1`, `bd-a3f8.1.1`. Older example IDs in this doc using `BD-42`-style uppercase digits reflect a pre-v1.0.0 convention; current upstream emits hash-based lowercase IDs.
|
|
22
24
|
|
|
23
25
|
### Task Hierarchy
|
|
24
26
|
|
|
@@ -34,18 +36,24 @@ Epics group related tasks. Tasks are the unit of work assignment — one task pe
|
|
|
34
36
|
|
|
35
37
|
### Progress Tracking
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
Beads tracks task status through this state machine (upstream v1.0.4 enum):
|
|
38
40
|
|
|
41
|
+
```text
|
|
42
|
+
open → in_progress → closed (happy path)
|
|
43
|
+
↓
|
|
44
|
+
blocked | deferred (off-path)
|
|
39
45
|
```
|
|
40
|
-
ready → in-progress → review → done
|
|
41
|
-
↘ blocked
|
|
42
|
-
```
|
|
43
46
|
|
|
44
|
-
- **
|
|
45
|
-
- **
|
|
46
|
-
- **
|
|
47
|
-
- **
|
|
48
|
-
- **
|
|
47
|
+
- **open** — Not started.
|
|
48
|
+
- **in_progress** — Atomically claimed via `bd update <id> --claim` or `bd ready --claim`.
|
|
49
|
+
- **blocked** — Dependency unresolved (set automatically when a `blocks:` dep exists on an open issue).
|
|
50
|
+
- **deferred** — Hidden from `bd ready` until `--defer` date passes.
|
|
51
|
+
- **closed** — Completed (via `bd close <id>`). Reopen with `bd reopen <id>`.
|
|
52
|
+
- **pinned** / **hooked** — Special states; rarely set manually.
|
|
53
|
+
|
|
54
|
+
Beads also exposes a *status category* dimension (`active | wip | done | frozen`) for higher-level grouping. Use `bd state <id>` to query, `bd statuses` to list valid statuses.
|
|
55
|
+
|
|
56
|
+
> Scaffold previously documented `ready → in-progress → review → done` — none of those (except via `ready` as a *query*) are upstream statuses. The `review` state, if needed, can be added per-project via `bd config set types.custom_statuses '[{"name":"review","category":"wip"}]'`.
|
|
49
57
|
|
|
50
58
|
### Lessons-Learned Workflow
|
|
51
59
|
|
|
@@ -70,7 +78,7 @@ bd init # Creates .beads/ directory with data store and git hooks
|
|
|
70
78
|
Initialization creates:
|
|
71
79
|
- `.beads/` — Data directory (committed to git)
|
|
72
80
|
- Git hooks for automatic data sync (these are Beads data hooks, not code-quality hooks like pre-commit linters)
|
|
73
|
-
- Initial `[
|
|
81
|
+
- Initial `[bd-<id>]` bootstrap convention (lowercase hash-style)
|
|
74
82
|
|
|
75
83
|
#### Core Commands
|
|
76
84
|
|
|
@@ -78,25 +86,26 @@ Initialization creates:
|
|
|
78
86
|
|---------|---------|-------------|
|
|
79
87
|
| `bd create "title"` | Create a new task | Starting new work |
|
|
80
88
|
| `bd list` | Show all tasks | Session start, planning |
|
|
81
|
-
| `bd
|
|
82
|
-
| `bd
|
|
83
|
-
| `bd
|
|
89
|
+
| `bd show <id>` | Inspect full task (alias `bd view`) | Before picking up work |
|
|
90
|
+
| `bd update <id> --claim` | Atomically claim (assigns to you + sets `in_progress`) | Beginning work on a task |
|
|
91
|
+
| `bd ready --claim --json` | Find and claim first ready task in one call | Picking next task with no preference |
|
|
92
|
+
| `bd close <id>` (alias `bd done`) | Mark task complete | After PR merged |
|
|
84
93
|
| `bd ready` | List tasks ready to start | Picking next task |
|
|
85
|
-
| `bd
|
|
94
|
+
| `bd update <id> --status blocked` | Mark task blocked | When dependency is unmet |
|
|
86
95
|
|
|
87
96
|
#### Commit Message Convention
|
|
88
97
|
|
|
89
98
|
Every commit references its Beads task:
|
|
90
99
|
|
|
91
100
|
```
|
|
92
|
-
[
|
|
101
|
+
[bd-a3f8] feat(api): implement user registration endpoint
|
|
93
102
|
|
|
94
103
|
- Add POST /api/v1/auth/register
|
|
95
104
|
- Add input validation with zod schema
|
|
96
105
|
- Add integration tests for happy path and validation errors
|
|
97
106
|
```
|
|
98
107
|
|
|
99
|
-
The `[
|
|
108
|
+
The `[bd-<id>]` prefix enables:
|
|
100
109
|
- Automatic task-to-commit traceability
|
|
101
110
|
- Progress tracking based on commit activity
|
|
102
111
|
- Session reconstruction (which commits belong to which task)
|
|
@@ -108,13 +117,13 @@ The `[BD-xxx]` prefix enables:
|
|
|
108
117
|
1. Review `tasks/lessons.md` for recent patterns and corrections
|
|
109
118
|
2. Run `bd ready` to see available tasks
|
|
110
119
|
3. Pick the highest-priority ready task (or continue an in-progress task)
|
|
111
|
-
4. Run `bd
|
|
120
|
+
4. Run `bd update <id> --claim` to atomically claim the task (or skip step 2-3 and just `bd ready --claim --json`)
|
|
112
121
|
5. Read the task description and acceptance criteria before writing code
|
|
113
122
|
|
|
114
123
|
#### Session End Protocol
|
|
115
124
|
|
|
116
|
-
1. Commit all work with `[
|
|
117
|
-
2. If task is complete: create PR, run `bd
|
|
125
|
+
1. Commit all work with `[bd-<id>]` prefix (lowercase hash-style)
|
|
126
|
+
2. If task is complete: create PR, run `bd close <id>` (alias: `bd done`)
|
|
118
127
|
3. If task is incomplete: leave clear notes about current state and next steps
|
|
119
128
|
4. If lessons were learned: update `tasks/lessons.md`
|
|
120
129
|
|
|
@@ -124,7 +133,7 @@ A task is done when:
|
|
|
124
133
|
- All acceptance criteria from the task description are met
|
|
125
134
|
- Tests pass (`make check` or equivalent)
|
|
126
135
|
- Code follows project coding standards
|
|
127
|
-
- Changes are committed with proper `[
|
|
136
|
+
- Changes are committed with proper `[bd-<id>]` message
|
|
128
137
|
- PR is created (or merged, depending on workflow)
|
|
129
138
|
|
|
130
139
|
Do not mark a task done based on "it seems to work." Prove it works — tests pass, logs clean, behavior verified.
|
|
@@ -184,14 +193,14 @@ For complex projects, maintain a progress summary:
|
|
|
184
193
|
# Progress
|
|
185
194
|
|
|
186
195
|
## Current Sprint
|
|
187
|
-
- [x]
|
|
188
|
-
- [x]
|
|
189
|
-
- [ ]
|
|
190
|
-
- [ ]
|
|
191
|
-
- [ ]
|
|
196
|
+
- [x] bd-a1b2: Database schema migration (done)
|
|
197
|
+
- [x] bd-a1b3: Auth middleware (done)
|
|
198
|
+
- [ ] bd-a3f8: User registration endpoint (in_progress)
|
|
199
|
+
- [ ] bd-a3f9: Login endpoint (open, ready to pick up)
|
|
200
|
+
- [ ] bd-a3fa: Profile management (blocked — needs bd-a3f8)
|
|
192
201
|
|
|
193
202
|
## Blocked
|
|
194
|
-
-
|
|
203
|
+
- bd-a3fa: Waiting on bd-a3f8 (user model finalization)
|
|
195
204
|
```
|
|
196
205
|
|
|
197
206
|
#### Completion Criteria Checklists
|
|
@@ -199,7 +208,7 @@ For complex projects, maintain a progress summary:
|
|
|
199
208
|
Each task should define explicit completion criteria, not vague goals:
|
|
200
209
|
|
|
201
210
|
```markdown
|
|
202
|
-
##
|
|
211
|
+
## bd-a3f8: User registration endpoint
|
|
203
212
|
|
|
204
213
|
### Done when:
|
|
205
214
|
- [ ] POST /api/v1/auth/register endpoint exists
|
|
@@ -218,8 +227,90 @@ Each task should define explicit completion criteria, not vague goals:
|
|
|
218
227
|
|
|
219
228
|
**Missing lessons.** The user corrects the same mistake three sessions in a row because nobody captured it in `tasks/lessons.md`. Fix: treat lesson capture as mandatory, not optional. After every correction, update the file before continuing with other work.
|
|
220
229
|
|
|
221
|
-
**Task ID drift.** Commits stop including `[
|
|
230
|
+
**Task ID drift.** Commits stop including `[bd-<id>]` prefixes partway through the project. Traceability breaks down. Fix: make task ID inclusion a habit enforced by review. If using a pre-commit hook, validate the prefix.
|
|
222
231
|
|
|
223
232
|
**Overloaded tasks.** A single task covers "implement the API, write the UI, add tests, update docs." This overflows a single session and makes progress tracking meaningless. Fix: split into tasks that each fit in one agent session (30-90 minutes).
|
|
224
233
|
|
|
225
234
|
**Lessons without rules.** A lesson says "we had trouble with X" but doesn't state a preventive rule. Future sessions read the lesson but don't know what to do differently. Fix: every lesson must include a concrete rule — "Always do Y" or "Never do Z" — not just a description of what went wrong.
|
|
235
|
+
|
|
236
|
+
### Agent context: `bd prime` is the SSOT
|
|
237
|
+
|
|
238
|
+
Beads ships `bd prime` as the single source of truth for workflow context injected into agent sessions. The default output is ~1-2k tokens and includes:
|
|
239
|
+
- Current ready/in-progress task counts
|
|
240
|
+
- The next 1-2 ready tasks with full descriptions
|
|
241
|
+
- Recent activity (last few closed/updated)
|
|
242
|
+
- Persistent memories set via `bd remember`
|
|
243
|
+
|
|
244
|
+
Variants:
|
|
245
|
+
- `bd prime` — full default
|
|
246
|
+
- `bd prime --memories-only` — just persistent memories (very small)
|
|
247
|
+
- `bd prime --full` — extended context (use sparingly; ~5k tokens)
|
|
248
|
+
- `bd prime --hook-json` — Claude Code SessionStart hook envelope
|
|
249
|
+
|
|
250
|
+
Override the default output by writing `.beads/PRIME.md` (Markdown, free-form). The `bd setup claude` / `bd setup gemini` recipes wire `bd prime --hook-json` into SessionStart hooks for you — you don't typically invoke it by hand.
|
|
251
|
+
|
|
252
|
+
`bd onboard` emits a one-line snippet you can paste into any agent context file to remind it about `bd prime`.
|
|
253
|
+
|
|
254
|
+
### Two memory scopes — when to use which
|
|
255
|
+
|
|
256
|
+
Scaffold-generated projects have two persistent memory layers when `.beads/` exists:
|
|
257
|
+
|
|
258
|
+
- **Filesystem auto-memory** (per-user, cross-project) — facts about you the developer. Stored under `~/.claude/projects/.../memory/` by the Claude Code client.
|
|
259
|
+
- **`bd remember`** (per-project, team-shareable) — facts about this project. Stored in `.beads/embeddeddolt/`, committed with the repo.
|
|
260
|
+
|
|
261
|
+
For project-level facts that should travel with the repo (in-flight context, team conventions, project-specific blockers, decisions), use `bd remember` instead of filesystem memory. See `content/knowledge/core/ai-memory-management.md` for the full scope split table.
|
|
262
|
+
|
|
263
|
+
### Editor integration via `bd setup` recipes
|
|
264
|
+
|
|
265
|
+
Beads ships built-in setup recipes that write the integration block into CLAUDE.md, AGENTS.md, GEMINI.md, or `.cursor/rules/` for you, using marker-managed format that survives re-runs:
|
|
266
|
+
|
|
267
|
+
- `bd setup claude` — Claude Code (writes CLAUDE.md block + SessionStart/PreCompact hooks)
|
|
268
|
+
- `bd setup codex` — Codex CLI (writes `.agents/skills/beads/SKILL.md` + AGENTS.md section)
|
|
269
|
+
- `bd setup gemini` — Gemini CLI (writes GEMINI.md section + hooks)
|
|
270
|
+
- `bd setup cursor` / `bd setup windsurf` / `bd setup aider` / `bd setup factory` / `bd setup mux` — other editors
|
|
271
|
+
|
|
272
|
+
Each recipe is idempotent (re-running it does not duplicate content), reversible (`--remove`), and verifiable (`--check`). Recipe choice determines profile (claude/gemini default to `minimal` ~60% smaller; codex/factory/mux default to `full`). There is no runtime `--profile` flag in v1.0.4 — recipe choice is the knob.
|
|
273
|
+
|
|
274
|
+
Custom recipes can be added via `bd setup --add <name> <path>`, persisted in `.beads/recipes.toml`.
|
|
275
|
+
|
|
276
|
+
### Optional: enable custom issue types
|
|
277
|
+
|
|
278
|
+
`bd create -t` supports `bug`, `feature`, `task`, `epic`, `chore`, `decision` out of the box. To use `story`, `milestone`, or `spike`, enable them via project config:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
bd config set types.custom '["story", "milestone", "spike"]'
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
After that, `bd create -t story "US-XXX: …"` works as expected.
|
|
285
|
+
|
|
286
|
+
### Production option: off-site backup
|
|
287
|
+
|
|
288
|
+
Beads can push a versioned mirror to filesystem, S3, GCS, Azure Blob, or DoltHub:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
bd backup init s3://my-bucket/beads-backup/
|
|
292
|
+
bd backup sync # push current DB
|
|
293
|
+
bd backup restore # bring it back if needed
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Worth setting up for any project where task state matters beyond the developer's laptop.
|
|
297
|
+
|
|
298
|
+
### When to use the MCP server (rarely)
|
|
299
|
+
|
|
300
|
+
Beads ships a Python MCP server (`beads-mcp`) for clients that don't have shell access — e.g., Claude Desktop, some IDE plugins. Install:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
uv tool install beads-mcp # or: pip install beads-mcp
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
For Claude Code, Cursor, Windsurf, and any agent with shell access, **CLI + hooks is preferred** — it's ~1-2k tokens of context (via `bd prime`) vs 10-50k for the MCP tool schemas. Only reach for `beads-mcp` when shell access isn't available.
|
|
307
|
+
|
|
308
|
+
### Safe re-initialization
|
|
309
|
+
|
|
310
|
+
If you need to re-init a Beads database (e.g., migrating to a fresh prefix, recovering from corruption), use the explicit flags rather than `--force`:
|
|
311
|
+
|
|
312
|
+
- `bd init --reinit-local` — bypass the local-exists guard
|
|
313
|
+
- `bd init --discard-remote` — explicitly authorize discarding remote Dolt history
|
|
314
|
+
- `bd init --destroy-token DESTROY-<prefix>` — required in non-interactive mode for destructive re-init
|
|
315
|
+
|
|
316
|
+
Stable exit codes: `10` (remote divergence), `11` (local exists), `12` (destroy-token missing). The legacy `--force` flag still works but is deprecated.
|
|
@@ -293,7 +293,7 @@ Every PRD feature must map to at least one user story. This is a non-negotiable
|
|
|
293
293
|
- Loading states, empty states, and offline behavior are often implied but not stated
|
|
294
294
|
|
|
295
295
|
**Traceability notation:**
|
|
296
|
-
- Use IDs to create a traceable chain: PRD-REQ-001 → US-001 → (downstream: Task
|
|
296
|
+
- Use IDs to create a traceable chain: PRD-REQ-001 → US-001 → (downstream: Task bd-a3f8)
|
|
297
297
|
- Story IDs (US-001, US-002, ...) are stable — they persist through updates and are referenced by downstream phases
|
|
298
298
|
|
|
299
299
|
### Story Dependencies
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: multi-agent-coordination
|
|
3
|
+
description: Upstream Beads primitives for coordinating parallel agents — bd merge-slot for serialized merge resolution and bd gate for async coordination
|
|
4
|
+
topics: [beads, multi-agent, worktrees, merge-conflicts, coordination, parallel-execution]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Multi-Agent Coordination (Beads Primitives)
|
|
8
|
+
|
|
9
|
+
When multiple agents work in parallel worktrees and converge on `main`, two upstream Beads primitives prevent the most common coordination failures. Both are optional — scaffold's multi-agent flows work without them — but they meaningfully reduce coordination cost in active parallel workloads.
|
|
10
|
+
|
|
11
|
+
## `bd merge-slot` — serialized merge resolution
|
|
12
|
+
|
|
13
|
+
**Problem:** Two agents finish in-flight tasks at roughly the same time. Both rebase on `origin/main` and push. The second agent's push races with the first agent's merge — either gets `non-fast-forward` (retry) or merges a stale base (silent conflict).
|
|
14
|
+
|
|
15
|
+
**Solution:** Acquire the project's merge slot before rebasing/pushing. Release it after the PR merges. There is **one** merge slot per project (stored as a bead with ID `<prefix>-merge-slot`); the slot uses `status=in_progress` + `metadata.holder` to track the current holder, and a priority-ordered `metadata.waiters` queue.
|
|
16
|
+
|
|
17
|
+
### Commands
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# First-time setup (once per project — usually done at bd init time):
|
|
21
|
+
bd merge-slot create
|
|
22
|
+
|
|
23
|
+
# Before rebasing your feature branch on main:
|
|
24
|
+
bd merge-slot acquire --wait
|
|
25
|
+
# Without --wait, acquire FAILS immediately if the slot is held. With --wait it
|
|
26
|
+
# adds you to the waiters queue and blocks until the slot frees. Holder defaults
|
|
27
|
+
# to $BEADS_ACTOR; pass --holder <name> to override.
|
|
28
|
+
|
|
29
|
+
# Now safe to rebase and push:
|
|
30
|
+
git fetch origin && git rebase origin/main
|
|
31
|
+
git push -u origin HEAD
|
|
32
|
+
|
|
33
|
+
# After your PR merges (or if you abandon the work):
|
|
34
|
+
bd merge-slot release
|
|
35
|
+
# --holder is optional (defaults to $BEADS_ACTOR) and is used for verification
|
|
36
|
+
# that you're releasing your own hold, not someone else's.
|
|
37
|
+
|
|
38
|
+
# To inspect current holder:
|
|
39
|
+
bd merge-slot check
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### When to use
|
|
43
|
+
|
|
44
|
+
Use `bd merge-slot` in multi-agent flows (3+ agents, OR projects where a merge conflict requires careful manual resolution). Skip it for single-agent or two-agent workflows where collisions are rare and `git push` retries are acceptable.
|
|
45
|
+
|
|
46
|
+
### Failure modes
|
|
47
|
+
|
|
48
|
+
- **Stale slot** (agent crashes between acquire and release): `bd merge-slot check` reports the current holder. Manual recovery is `bd update <prefix>-merge-slot --status open` to clear the holder field (do this with care — verify the original holder is truly gone first).
|
|
49
|
+
- **Slot held by yourself in a different worktree**: the `--holder` field is checked on release, so multiple worktrees with the same `$BEADS_ACTOR` cannot interfere. Different actors queue behind each other.
|
|
50
|
+
|
|
51
|
+
## `bd gate` — async coordination gates
|
|
52
|
+
|
|
53
|
+
**Problem:** Agent A's task can't start until something happens (a PR merges, a workflow completes, a human reviews). Without a gate, Agent A either polls (wasteful) or proceeds anyway and discovers the missing dependency the hard way.
|
|
54
|
+
|
|
55
|
+
**Solution:** Create a gate issue that blocks the dependent task. The gate is itself a Beads issue with an auto-generated ID. Resolving the gate unblocks the task.
|
|
56
|
+
|
|
57
|
+
Gate types:
|
|
58
|
+
- `human` (default) — Requires a manual `bd gate resolve <gate-id>`.
|
|
59
|
+
- `timer` — Auto-resolves after `--timeout` (e.g., `--timeout=2h`).
|
|
60
|
+
- `gh:run` — Waits for a GitHub Actions run; `--await-id=<run-id>`.
|
|
61
|
+
- `gh:pr` — Waits for a PR merge; `--await-id=<pr-number>`.
|
|
62
|
+
|
|
63
|
+
### Commands
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# When you discover that bd-xyz is blocked until something happens, create a gate.
|
|
67
|
+
# The gate has an auto-generated ID; capture it via --json:
|
|
68
|
+
GATE_ID=$(bd gate create \
|
|
69
|
+
--blocks bd-xyz \
|
|
70
|
+
--reason "Waiting for auth-middleware-v2 PR to merge" \
|
|
71
|
+
--type human \
|
|
72
|
+
--json | jq -r '.id')
|
|
73
|
+
|
|
74
|
+
# Common variants:
|
|
75
|
+
# - gh:pr gate (auto-resolves on PR merge)
|
|
76
|
+
bd gate create --type=gh:pr --blocks bd-xyz --await-id=123 --reason "Blocked on PR #123"
|
|
77
|
+
|
|
78
|
+
# - timer gate
|
|
79
|
+
bd gate create --type=timer --blocks bd-xyz --timeout=2h --reason "Recheck in 2h"
|
|
80
|
+
|
|
81
|
+
# When the underlying condition is met, resolve manually (human gates) or rely on
|
|
82
|
+
# the type-specific watcher (gh:pr, gh:run, timer):
|
|
83
|
+
bd gate resolve "$GATE_ID" --reason "PR #123 merged, middleware live"
|
|
84
|
+
|
|
85
|
+
# Check what's gated:
|
|
86
|
+
bd gate list # open gates only
|
|
87
|
+
bd gate list --all # include closed
|
|
88
|
+
bd gate check # evaluate all open gates (resolves any whose condition is met)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### When to use
|
|
92
|
+
|
|
93
|
+
Use gates for one-off async dependencies — "this task can't proceed until X happens, and X is identifiable as a run ID, a PR number, a timer, or a human decision." Skip them for plain "this task depends on that task" cases, which are covered by `bd dep add --blocks` (a dependency, not a gate).
|
|
94
|
+
|
|
95
|
+
### Pattern: multiple downstream tasks share one underlying blocker
|
|
96
|
+
|
|
97
|
+
If five downstream tasks all wait on the same PR merging, create five gh:pr gates (one per blocked issue) all pointing at the same `--await-id=<pr-number>`:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
for ID in bd-aaa bd-bbb bd-ccc bd-ddd bd-eee; do
|
|
101
|
+
bd gate create --type=gh:pr --blocks "$ID" --await-id=123 --reason "Blocked on PR #123"
|
|
102
|
+
done
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`bd gate check` (or the automatic watcher) resolves all five at once when the PR merges.
|
|
106
|
+
|
|
107
|
+
> The `bd gate add-waiter` subcommand is a different mechanism — it registers an agent's *wake address* (e.g., "my-project/workers/agent-1") to receive notifications. It's not for chaining issues to gates; use `--blocks` on `bd gate create` for that.
|
|
108
|
+
|
|
109
|
+
## Composition
|
|
110
|
+
|
|
111
|
+
Both primitives compose with the rest of the multi-agent flow:
|
|
112
|
+
|
|
113
|
+
- `bd ready --claim` picks a non-gated, non-blocked task.
|
|
114
|
+
- `bd preflight` validates task readiness before PR (already in scaffold's start prompts).
|
|
115
|
+
- `bd merge-slot acquire` serializes the merge.
|
|
116
|
+
- `bd gate resolve` unblocks downstream waiters when your work lands.
|
|
117
|
+
|
|
118
|
+
For the canonical sequence in scaffold's multi-agent prompts, see `content/pipeline/build/multi-agent-start.md`.
|
|
@@ -66,7 +66,7 @@ Before starting a task, verify all its blockers are resolved. After completing e
|
|
|
66
66
|
### Multi-Agent Conflict Avoidance — Extended
|
|
67
67
|
|
|
68
68
|
**Claiming a task:**
|
|
69
|
-
- Creating a feature branch (e.g., `bd-
|
|
69
|
+
- Creating a feature branch (e.g., `bd-a3f8/add-user-endpoint`) is the claim signal
|
|
70
70
|
- Other agents should check for existing branches before claiming the same task
|
|
71
71
|
- If two agents accidentally claim the same task, the one with fewer commits yields
|
|
72
72
|
|
|
@@ -100,9 +100,9 @@ Beads is an optional task-tracking tool. Detect its presence and adapt.
|
|
|
100
100
|
|
|
101
101
|
**When `.beads/` directory exists:**
|
|
102
102
|
- Use `bd ready` to list tasks that are ready for work
|
|
103
|
-
- Use `bd
|
|
103
|
+
- Use `bd update <id> --claim` to atomically claim a task (or `bd ready --claim --json` to find and claim the first available in one call)
|
|
104
104
|
- Use `bd close <id>` after PR is merged to mark task complete
|
|
105
|
-
- Task IDs come from Beads (`bd-
|
|
105
|
+
- Task IDs come from Beads (`bd-a3f8`, `bd-a3f9`, etc. — hash-based, lowercase)
|
|
106
106
|
- Branch naming follows Beads convention: `bd-<id>/<short-desc>`
|
|
107
107
|
|
|
108
108
|
**Without Beads:**
|
|
@@ -123,6 +123,18 @@ A task is complete when all of the following are true:
|
|
|
123
123
|
|
|
124
124
|
Only after all five criteria are met should the task be marked as done.
|
|
125
125
|
|
|
126
|
+
## Discovered Work
|
|
127
|
+
|
|
128
|
+
While implementing a claimed task, you may discover bugs or follow-up tasks. Don't silently expand the current task's scope — file the new work as a separate Beads issue with `discovered-from`:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
bd create "fix(parser): handle empty input edge case" \
|
|
132
|
+
--type bug -p 2 \
|
|
133
|
+
--deps discovered-from:$CURRENT_TASK_ID
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`discovered-from` is metadata for traceability — the new issue appears in `bd ready` normally and does NOT block the current task. This preserves the audit trail of why the new task exists.
|
|
137
|
+
|
|
126
138
|
## See Also
|
|
127
139
|
|
|
128
140
|
- [tdd-execution-loop](./tdd-execution-loop.md) — Red-green-refactor cycle and commit timing
|
|
@@ -179,16 +179,18 @@ git branch | grep "workspace" | xargs -r git branch -D
|
|
|
179
179
|
|
|
180
180
|
Use `-D` here because workspace branches are not merged — they're disposable.
|
|
181
181
|
|
|
182
|
-
###
|
|
182
|
+
### BEADS_ACTOR Environment Variable
|
|
183
183
|
|
|
184
|
-
When using Beads for task tracking, set `
|
|
184
|
+
When using Beads for task tracking, set `BEADS_ACTOR` per agent for attribution:
|
|
185
185
|
|
|
186
186
|
```bash
|
|
187
|
-
export
|
|
187
|
+
export BEADS_ACTOR="agent-1"
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
This ensures that task claims, completions, and other Beads operations are attributed to the correct agent. Set it in the agent's shell environment before starting work.
|
|
191
191
|
|
|
192
|
+
> Older Beads versions (<v1.0.0) used `BD_ACTOR`. It's still accepted as a deprecated alias — if you see it in legacy scripts, rename when you next edit.
|
|
193
|
+
|
|
192
194
|
### Listing Active Worktrees
|
|
193
195
|
|
|
194
196
|
To see all active worktrees and their branches:
|
|
@@ -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
|
---
|
|
@@ -85,7 +85,7 @@ Before doing anything else, confirm the environment:
|
|
|
85
85
|
- If NOT in a worktree, stop and instruct the user to set one up or navigate to the correct directory
|
|
86
86
|
|
|
87
87
|
2. **Beads identity** (if `.beads/` exists)
|
|
88
|
-
- `echo $
|
|
88
|
+
- `echo $BEADS_ACTOR` — should show `$ARGUMENTS`
|
|
89
89
|
- If not set, the worktree setup may be incomplete
|
|
90
90
|
|
|
91
91
|
### State Recovery
|
|
@@ -114,14 +114,14 @@ Recover your context by checking the current state of work:
|
|
|
114
114
|
### Beads Recovery
|
|
115
115
|
|
|
116
116
|
**If Beads is configured** (`.beads/` exists):
|
|
117
|
-
- `bd list --
|
|
118
|
-
- If a PR shows as merged, close the corresponding task: `bd close <id
|
|
117
|
+
- `bd list --assignee $ARGUMENTS` — check for tasks with `in_progress` status owned by this agent
|
|
118
|
+
- If a PR shows as merged, close the corresponding task: `bd close <id>`
|
|
119
119
|
- If there is in-progress work, finish it (see "Resume In-Progress Work" below)
|
|
120
120
|
- Otherwise, clean up and start fresh:
|
|
121
121
|
- `git fetch origin --prune && git clean -fd`
|
|
122
122
|
- Run the install command from CLAUDE.md Key Commands
|
|
123
|
-
- `bd ready`
|
|
124
|
-
- Continue working until `bd ready`
|
|
123
|
+
- Atomically claim the next ready task: `TASK=$(bd ready --claim --json | jq -r '.id')` (sets `assignee=$BEADS_ACTOR` + `status=in_progress`; no race window between agents).
|
|
124
|
+
- Continue working until `bd ready --claim --json` returns no task.
|
|
125
125
|
|
|
126
126
|
**Without Beads:**
|
|
127
127
|
- Read `docs/implementation-playbook.md` as the primary task reference.
|
|
@@ -171,8 +171,28 @@ Once in-progress work is complete (or if there was none):
|
|
|
171
171
|
- Fix any findings at or above `fix_threshold` before proceeding
|
|
172
172
|
|
|
173
173
|
3. **Create PR** (if not already created for in-progress work)
|
|
174
|
+
- If Beads is configured, run the PR-readiness checklist first:
|
|
175
|
+
```bash
|
|
176
|
+
if [ -d .beads ]; then
|
|
177
|
+
bd preflight
|
|
178
|
+
fi
|
|
179
|
+
```
|
|
180
|
+
Fix any issues `bd preflight` flags before proceeding.
|
|
181
|
+
- **For 3+ parallel agents**, acquire the project's merge slot to serialize merge-time conflicts:
|
|
182
|
+
```bash
|
|
183
|
+
if [ -d .beads ]; then
|
|
184
|
+
bd merge-slot acquire --wait # blocks if held; queues you in priority order
|
|
185
|
+
fi
|
|
186
|
+
```
|
|
187
|
+
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`.
|
|
174
188
|
- Push the branch: `git push -u origin HEAD`
|
|
175
189
|
- Create a pull request: `gh pr create`
|
|
190
|
+
- After the PR merges (or if you abandon the work), release the slot:
|
|
191
|
+
```bash
|
|
192
|
+
if [ -d .beads ]; then
|
|
193
|
+
bd merge-slot release # holder verified via $BEADS_ACTOR
|
|
194
|
+
fi
|
|
195
|
+
```
|
|
176
196
|
- Include agent name in PR description for traceability
|
|
177
197
|
|
|
178
198
|
4. **Run code reviews (MANDATORY)**
|
|
@@ -219,7 +239,7 @@ Once in-progress work is complete (or if there was none):
|
|
|
219
239
|
- Push updates and re-request review
|
|
220
240
|
|
|
221
241
|
**Task was completed by another agent:**
|
|
222
|
-
- If Beads: `bd
|
|
242
|
+
- 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.
|
|
223
243
|
- Without Beads: check the plan/playbook for recently completed tasks and open PRs
|
|
224
244
|
- Skip to the next available task
|
|
225
245
|
|