@zigrivers/scaffold 3.26.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 (126) hide show
  1. package/README.md +21 -7
  2. package/content/knowledge/core/ai-memory-management.md +17 -0
  3. package/content/knowledge/core/claude-md-patterns.md +2 -2
  4. package/content/knowledge/core/coding-conventions.md +2 -2
  5. package/content/knowledge/core/task-decomposition.md +4 -4
  6. package/content/knowledge/core/task-tracking.md +120 -29
  7. package/content/knowledge/core/user-stories.md +1 -1
  8. package/content/knowledge/execution/multi-agent-coordination.md +118 -0
  9. package/content/knowledge/execution/task-claiming-strategy.md +15 -3
  10. package/content/knowledge/execution/worktree-management.md +5 -3
  11. package/content/knowledge/web3/web3-access-control.md +189 -0
  12. package/content/knowledge/web3/web3-architecture.md +162 -0
  13. package/content/knowledge/web3/web3-audit-workflow.md +151 -0
  14. package/content/knowledge/web3/web3-common-vulnerabilities.md +171 -0
  15. package/content/knowledge/web3/web3-conventions.md +162 -0
  16. package/content/knowledge/web3/web3-deployment-and-verification.md +216 -0
  17. package/content/knowledge/web3/web3-dev-environment.md +150 -0
  18. package/content/knowledge/web3/web3-gas-optimization.md +165 -0
  19. package/content/knowledge/web3/web3-oracles-and-external-data.md +155 -0
  20. package/content/knowledge/web3/web3-project-structure.md +212 -0
  21. package/content/knowledge/web3/web3-requirements.md +152 -0
  22. package/content/knowledge/web3/web3-security.md +163 -0
  23. package/content/knowledge/web3/web3-testing.md +180 -0
  24. package/content/knowledge/web3/web3-upgradeability.md +189 -0
  25. package/content/methodology/web3-overlay.yml +40 -0
  26. package/content/pipeline/build/multi-agent-resume.md +27 -7
  27. package/content/pipeline/build/multi-agent-start.md +35 -7
  28. package/content/pipeline/build/new-enhancement.md +8 -1
  29. package/content/pipeline/build/quick-task.md +9 -0
  30. package/content/pipeline/build/single-agent-resume.md +11 -4
  31. package/content/pipeline/build/single-agent-start.md +13 -4
  32. package/content/pipeline/consolidation/workflow-audit.md +1 -1
  33. package/content/pipeline/environment/git-workflow.md +2 -2
  34. package/content/pipeline/foundation/beads.md +148 -22
  35. package/content/pipeline/foundation/coding-standards.md +1 -1
  36. package/content/tools/post-implementation-review.md +6 -6
  37. package/content/tools/prompt-pipeline.md +1 -1
  38. package/content/tools/release.md +5 -5
  39. package/content/tools/review-code.md +347 -3
  40. package/content/tools/review-pr.md +349 -7
  41. package/content/tools/version-bump.md +5 -5
  42. package/dist/cli/commands/observe.d.ts +2 -0
  43. package/dist/cli/commands/observe.d.ts.map +1 -1
  44. package/dist/cli/commands/observe.js +9 -1
  45. package/dist/cli/commands/observe.js.map +1 -1
  46. package/dist/cli/commands/observe.test.js +36 -0
  47. package/dist/cli/commands/observe.test.js.map +1 -1
  48. package/dist/config/schema.d.ts +672 -126
  49. package/dist/config/schema.d.ts.map +1 -1
  50. package/dist/config/schema.js +8 -1
  51. package/dist/config/schema.js.map +1 -1
  52. package/dist/config/schema.test.js +2 -2
  53. package/dist/config/schema.test.js.map +1 -1
  54. package/dist/config/validators/index.d.ts.map +1 -1
  55. package/dist/config/validators/index.js +2 -0
  56. package/dist/config/validators/index.js.map +1 -1
  57. package/dist/config/validators/web3.d.ts +4 -0
  58. package/dist/config/validators/web3.d.ts.map +1 -0
  59. package/dist/config/validators/web3.js +15 -0
  60. package/dist/config/validators/web3.js.map +1 -0
  61. package/dist/e2e/project-type-overlays.test.js +76 -0
  62. package/dist/e2e/project-type-overlays.test.js.map +1 -1
  63. package/dist/observability/adapters/beads.d.ts +4 -0
  64. package/dist/observability/adapters/beads.d.ts.map +1 -1
  65. package/dist/observability/adapters/beads.js +25 -2
  66. package/dist/observability/adapters/beads.js.map +1 -1
  67. package/dist/observability/adapters/beads.test.js +40 -2
  68. package/dist/observability/adapters/beads.test.js.map +1 -1
  69. package/dist/observability/engine/ledger-writer.d.ts +11 -1
  70. package/dist/observability/engine/ledger-writer.d.ts.map +1 -1
  71. package/dist/observability/engine/ledger-writer.js +6 -0
  72. package/dist/observability/engine/ledger-writer.js.map +1 -1
  73. package/dist/observability/engine/llm-dispatcher.d.ts.map +1 -1
  74. package/dist/observability/engine/llm-dispatcher.js +36 -5
  75. package/dist/observability/engine/llm-dispatcher.js.map +1 -1
  76. package/dist/observability/engine/llm-dispatcher.test.js +23 -0
  77. package/dist/observability/engine/llm-dispatcher.test.js.map +1 -1
  78. package/dist/project/adopt.d.ts.map +1 -1
  79. package/dist/project/adopt.js +3 -1
  80. package/dist/project/adopt.js.map +1 -1
  81. package/dist/project/detectors/coverage.test.js +3 -2
  82. package/dist/project/detectors/coverage.test.js.map +1 -1
  83. package/dist/project/detectors/disambiguate.js +1 -1
  84. package/dist/project/detectors/disambiguate.js.map +1 -1
  85. package/dist/project/detectors/index.d.ts.map +1 -1
  86. package/dist/project/detectors/index.js +2 -0
  87. package/dist/project/detectors/index.js.map +1 -1
  88. package/dist/project/detectors/resolve-detection.test.js +57 -0
  89. package/dist/project/detectors/resolve-detection.test.js.map +1 -1
  90. package/dist/project/detectors/types.d.ts +6 -2
  91. package/dist/project/detectors/types.d.ts.map +1 -1
  92. package/dist/project/detectors/types.js.map +1 -1
  93. package/dist/project/detectors/web3.d.ts +4 -0
  94. package/dist/project/detectors/web3.d.ts.map +1 -0
  95. package/dist/project/detectors/web3.js +37 -0
  96. package/dist/project/detectors/web3.js.map +1 -0
  97. package/dist/project/detectors/web3.test.d.ts +2 -0
  98. package/dist/project/detectors/web3.test.d.ts.map +1 -0
  99. package/dist/project/detectors/web3.test.js +75 -0
  100. package/dist/project/detectors/web3.test.js.map +1 -0
  101. package/dist/types/config.d.ts +8 -1
  102. package/dist/types/config.d.ts.map +1 -1
  103. package/dist/wizard/copy/core.d.ts.map +1 -1
  104. package/dist/wizard/copy/core.js +4 -0
  105. package/dist/wizard/copy/core.js.map +1 -1
  106. package/dist/wizard/copy/index.d.ts.map +1 -1
  107. package/dist/wizard/copy/index.js +2 -0
  108. package/dist/wizard/copy/index.js.map +1 -1
  109. package/dist/wizard/copy/types.d.ts +5 -1
  110. package/dist/wizard/copy/types.d.ts.map +1 -1
  111. package/dist/wizard/copy/types.test-d.js +7 -0
  112. package/dist/wizard/copy/types.test-d.js.map +1 -1
  113. package/dist/wizard/copy/web3.d.ts +3 -0
  114. package/dist/wizard/copy/web3.d.ts.map +1 -0
  115. package/dist/wizard/copy/web3.js +15 -0
  116. package/dist/wizard/copy/web3.js.map +1 -0
  117. package/dist/wizard/questions.d.ts +2 -1
  118. package/dist/wizard/questions.d.ts.map +1 -1
  119. package/dist/wizard/questions.js +8 -1
  120. package/dist/wizard/questions.js.map +1 -1
  121. package/dist/wizard/questions.test.js +14 -0
  122. package/dist/wizard/questions.test.js.map +1 -1
  123. package/dist/wizard/wizard.d.ts.map +1 -1
  124. package/dist/wizard/wizard.js +1 -0
  125. package/dist/wizard/wizard.js.map +1 -1
  126. package/package.json +1 -1
package/README.md CHANGED
@@ -29,7 +29,7 @@ Either way, Scaffold constructs the prompt and the target AI tool does the work.
29
29
 
30
30
  **Assembly engine** — At execution time, Scaffold builds a 7-section prompt from: system metadata, the meta-prompt, knowledge base entries, project context (artifacts from prior steps), methodology settings, layered instructions, and depth-specific execution guidance.
31
31
 
32
- **Knowledge base** — 235 domain expertise entries in `content/knowledge/` organized in eighteen categories (core, product, review, validation, finalization, execution, tools, game, web-app, backend, cli, library, mobile-app, data-pipeline, ml, browser-extension, research, data-science) covering testing strategy, domain modeling, API design, security best practices, eval craft, TDD execution, task claiming, worktree management, release management, rendering strategies, data stores, CLI patterns, game engines, library bundling, mobile deployment, batch and streaming pipelines, model training and serving, browser extension manifests and service workers, data-science reproducibility and notebook discipline, and more. These get injected into prompts based on each step's `knowledge-base` frontmatter field. Knowledge files with a `## Deep Guidance` section are optimized for CLI assembly — only the deep guidance content is loaded, avoiding redundancy with the prompt text. Teams can add project-local overrides in `.scaffold/knowledge/` that layer on top of the global entries.
32
+ **Knowledge base** — 267 domain expertise entries in `content/knowledge/` organized in nineteen categories (core, product, review, validation, finalization, execution, tools, game, web-app, backend, cli, library, mobile-app, data-pipeline, ml, browser-extension, research, data-science, web3) covering testing strategy, domain modeling, API design, security best practices, eval craft, TDD execution, task claiming, worktree management, release management, rendering strategies, data stores, CLI patterns, game engines, library bundling, mobile deployment, batch and streaming pipelines, model training and serving, browser extension manifests and service workers, data-science reproducibility and notebook discipline, smart-contract security and audit workflow, and more. These get injected into prompts based on each step's `knowledge-base` frontmatter field. Knowledge files with a `## Deep Guidance` section are optimized for CLI assembly — only the deep guidance content is loaded, avoiding redundancy with the prompt text. Teams can add project-local overrides in `.scaffold/knowledge/` that layer on top of the global entries.
33
33
 
34
34
  **Methodology presets** — Three built-in presets control which steps run and how deep the analysis goes:
35
35
  - **deep** (depth 5) — all steps enabled, exhaustive analysis
@@ -368,7 +368,7 @@ Every `scaffold init` wizard question can be answered via CLI flags, making scaf
368
368
  | `--depth` | 1-5 | Custom methodology depth (requires `--methodology custom`) |
369
369
  | `--adapters` | comma-sep | AI adapters: claude-code, codex, gemini |
370
370
  | `--traits` | comma-sep | Project traits: web, mobile |
371
- | `--project-type` | string | web-app, mobile-app, backend, cli, library, game, data-pipeline, ml, browser-extension, research, data-science |
371
+ | `--project-type` | string | web-app, mobile-app, backend, cli, library, game, data-pipeline, ml, browser-extension, research, data-science, web3 |
372
372
  | `--auto` | boolean | Non-interactive mode (uses Zod defaults for unset flags) |
373
373
 
374
374
  #### Web-App Config Flags (require `--project-type web-app` or auto-set it)
@@ -465,6 +465,14 @@ Data science has one forward-compatible config field in the schema, defaulted au
465
465
  |------|------|--------|
466
466
  | `dataScienceConfig.audience` | `solo` | Default (applied by the wizard and `--auto`). Covers the DS-1 audience (solo / small-team, local-first, prototyping). A future DS-2 release will extend the enum with `'platform'` (platform-engineered / larger-team DS) additively, without breaking existing configs. |
467
467
 
468
+ #### Web3 Config (`--project-type web3`)
469
+
470
+ Web3 has one forward-compatible config field in the schema, defaulted automatically — no CLI flags are needed in v1:
471
+
472
+ | Config field | Values | Notes |
473
+ |------|------|--------|
474
+ | `web3Config.scope` | `contracts` | Default (applied by the wizard and `--auto`). Covers the W3-1 audience (smart-contract / protocol projects on EVM chains — Foundry / Hardhat). A future W3-2 release will extend the enum with `'dapp'` (web3 application / dApp) additively, without breaking existing configs. |
475
+
468
476
  #### Game Config Flags (require `--project-type game` or auto-set it)
469
477
 
470
478
  | Flag | Type | Values |
@@ -514,7 +522,7 @@ during assembly.
514
522
 
515
523
  - **Flag > auto > interactive**: Flags always take highest precedence. `--auto --engine unreal` uses defaults for everything except engine.
516
524
  - **Partial flags + interactive**: Provide some flags and the wizard asks only the remaining questions. `scaffold init --project-type game --engine unreal` prompts interactively for multiplayer, platforms, etc.
517
- - **Type-specific flags auto-set project type**: `--engine unity` automatically sets `--project-type game`, `--web-rendering ssr` sets `--project-type web-app`, `--backend-api-style rest` sets `--project-type backend`, `--cli-interactivity hybrid` sets `--project-type cli`, `--lib-visibility public` sets `--project-type library`, `--mobile-platform ios` sets `--project-type mobile-app`, `--pipeline-processing batch` sets `--project-type data-pipeline`, `--ml-phase training` sets `--project-type ml`, `--ext-manifest 3` sets `--project-type browser-extension`, `--research-driver code-driven` sets `--project-type research`. Error if conflicting type. (Data science currently has no dedicated CLI flags — pass `--project-type data-science` directly.)
525
+ - **Type-specific flags auto-set project type**: `--engine unity` automatically sets `--project-type game`, `--web-rendering ssr` sets `--project-type web-app`, `--backend-api-style rest` sets `--project-type backend`, `--cli-interactivity hybrid` sets `--project-type cli`, `--lib-visibility public` sets `--project-type library`, `--mobile-platform ios` sets `--project-type mobile-app`, `--pipeline-processing batch` sets `--project-type data-pipeline`, `--ml-phase training` sets `--project-type ml`, `--ext-manifest 3` sets `--project-type browser-extension`, `--research-driver code-driven` sets `--project-type research`. Error if conflicting type. (Data science and web3 currently have no dedicated CLI flags — pass `--project-type data-science` or `--project-type web3` directly.)
518
526
  - **Cannot mix flag families**: `--web-rendering ssr --backend-api-style rest` is an error. Each flag family (`--web-*`, `--backend-*`, `--cli-*`, `--lib-*`, `--mobile-*`, `--pipeline-*`, `--ml-*`, `--research-*`, `--ext-*`, game) is exclusive.
519
527
  - **Validation**: `--depth` requires `--methodology custom`. `--online-services` requires `--multiplayer online` or `hybrid`. SSR/hybrid rendering is incompatible with static deploy target. Session auth requires server state (not static). ML inference projects must specify a serving pattern. Browser extensions must declare at least one capability (UI surface, content script, or background worker). Notebook-driven research cannot be fully autonomous.
520
528
 
@@ -610,6 +618,9 @@ scaffold init --auto --methodology deep --project-type research \
610
618
  # Solo / small-team data science project (reproducibility-first)
611
619
  scaffold init --auto --methodology deep --project-type data-science
612
620
 
621
+ # Web3 smart-contract / protocol project (Foundry / Hardhat on EVM)
622
+ scaffold init --auto --methodology deep --project-type web3
623
+
613
624
  # Multiplayer mobile game with Unity
614
625
  scaffold init --project-type game --methodology deep --auto \
615
626
  --engine unity --multiplayer online --target-platforms ios,android \
@@ -636,7 +647,7 @@ Scaffold supports **project-type overlays** — domain-specific knowledge and pi
636
647
 
637
648
  - **Injects domain knowledge** into existing pipeline steps (e.g., SSR caching strategies into `tech-stack`, API pagination patterns into `coding-standards`)
638
649
 
639
- The game overlay additionally adjusts step enablement, remaps artifact references, and adds dependency overrides (because game development has fundamentally different artifacts). The web-app, backend, CLI, library, mobile-app, data-pipeline, ML, browser-extension, research, and data-science overlays are **knowledge-only** — they inject domain expertise into existing steps without changing which steps run or how they depend on each other. The research type additionally supports **domain sub-overlays** (quant-finance, ml-research, simulation) that layer domain-specific knowledge on top of the core research overlay, and the backend type supports a `fintech` sub-overlay. Both research and backend accept `domain` as either a single string or an array (e.g. `domain: ['quant-finance', 'simulation']`) for stacking multiple sub-overlays; the wizard and CLI flags remain single-select in v1, so multi-domain stacking requires hand-editing `.scaffold/config.yml`.
650
+ The game overlay additionally adjusts step enablement, remaps artifact references, and adds dependency overrides (because game development has fundamentally different artifacts). The web-app, backend, CLI, library, mobile-app, data-pipeline, ML, browser-extension, research, data-science, and web3 overlays are **knowledge-only** — they inject domain expertise into existing steps without changing which steps run or how they depend on each other. The research type additionally supports **domain sub-overlays** (quant-finance, ml-research, simulation) that layer domain-specific knowledge on top of the core research overlay, and the backend type supports a `fintech` sub-overlay. Both research and backend accept `domain` as either a single string or an array (e.g. `domain: ['quant-finance', 'simulation']`) for stacking multiple sub-overlays; the wizard and CLI flags remain single-select in v1, so multi-domain stacking requires hand-editing `.scaffold/config.yml`.
640
651
 
641
652
  Overlays are composable with methodology presets. An MVP web-app gets fewer steps at lower depth; a deep backend project gets exhaustive analysis of every architectural decision.
642
653
 
@@ -652,6 +663,7 @@ Overlays are composable with methodology presets. An MVP web-app gets fewer step
652
663
  | `browser-extension` | `browser-extension-overlay.yml` | 12 entries (architecture, manifest configuration, service workers, content scripts, cross-browser, store submission, testing, security) | Manifest version, UI surfaces, content script, background worker |
653
664
  | `research` | `research-overlay.yml` + domain sub-overlays | 25 entries (experiment loop, tracking, overfitting prevention, backtesting, risk metrics, architecture search, simulation) | Experiment driver, interaction mode, domain, experiment tracking |
654
665
  | `data-science` | `data-science-overlay.yml` | 13 entries (reproducibility, experiment tracking, notebook discipline, model evaluation, data versioning, dev environment, observability, project structure, conventions, requirements, security, testing, architecture) | Audience (`solo` default; `platform` reserved for DS-2) |
666
+ | `web3` | `web3-overlay.yml` | 14 entries (Foundry tooling, smart-contract security, upgradeability, gas optimization, oracles, audit workflow, deployment, testing patterns, EVM fundamentals, ABI/interface design, event/log indexing, supply-chain) | Scope (`contracts` default; `dapp` reserved for W3-2) |
655
667
  | `game` | `game-overlay.yml` | 24 entries (engines, networking, audio, VR/AR, economy, save systems, certification) | Engine, multiplayer, platforms, economy, narrative, and 6 more |
656
668
 
657
669
  ### Game Development
@@ -737,7 +749,7 @@ These answers control which conditional steps activate. A single-player puzzle g
737
749
 
738
750
  #### Multi-type Detection
739
751
 
740
- `scaffold adopt` detects 11 project types from manifest files and directory layouts:
752
+ `scaffold adopt` detects 12 project types from manifest files and directory layouts:
741
753
 
742
754
  | Type | Key Signals |
743
755
  |------|-------------|
@@ -752,6 +764,7 @@ These answers control which conditional steps activate. A single-player puzzle g
752
764
  | `browser-extension` | `manifest.json` with `manifest_version` field |
753
765
  | `research` | `program.md` + `results.tsv`, backtest/strategy files with trading deps, optimization deps + experiment dirs, simulation framework deps |
754
766
  | `data-science` | Marimo signals required (`marimo` dep or `.marimo.toml`); DVC (`dvc.yaml`, `.dvc/config`, `dvc` py dep) is supplementary evidence only. Low-tier; defers to `ml` / `research` / `data-pipeline` when those match at medium/high tier |
767
+ | `web3` | `foundry.toml` or `hardhat.config.{ts,js,cjs,mjs}` (medium-tier); `remappings.txt`, `lib/forge-std` are supplementary low-tier signals. EVM-only scope. Library-collision boundary pinned by tiebreak (high-tier `library` wins over medium-tier `web3` for published-library Hardhat projects) |
755
768
 
756
769
  Each detector returns a confidence tier (high/medium/low) with evidence trails. Override detection with `--project-type <type>`.
757
770
 
@@ -1512,7 +1525,7 @@ scaffold dashboard
1512
1525
 
1513
1526
  ## Knowledge System
1514
1527
 
1515
- Scaffold ships with 235 domain expertise entries organized in eighteen categories:
1528
+ Scaffold ships with 267 domain expertise entries organized in nineteen categories:
1516
1529
 
1517
1530
  - **core/** (26 entries) — eval craft, testing strategy, domain modeling, API design, database design, system architecture, ADR craft, security best practices, operations, task decomposition, user stories, UX specification, design system tokens, user story innovation, AI memory management, coding conventions, tech stack selection, project structure patterns, task tracking, CLAUDE.md patterns, multi-model review dispatch, review step template, dev environment, git workflow patterns, automated review tooling, vision craft
1518
1531
  - **product/** (5 entries) — PRD craft, PRD innovation, gap analysis, vision craft, vision innovation
@@ -1532,6 +1545,7 @@ Scaffold ships with 235 domain expertise entries organized in eighteen categorie
1532
1545
  - **browser-extension/** (12 entries) — Manifest V3, content scripts, service workers, cross-browser compatibility, extension security, store submission
1533
1546
  - **research/** (25 entries) — experiment loop architecture, parameter optimization, overfitting prevention, experiment tracking, security/sandboxing; domain knowledge for quant-finance (backtesting, risk metrics, market data, strategy patterns), ML-research (architecture search, ablation studies, evaluation), and simulation (engine integration, parameter spaces, compute management)
1534
1547
  - **data-science/** (13 entries) — reproducibility, experiment tracking, notebook discipline, model evaluation, data versioning, dev environment (Marimo/Jupyter/Hex), observability, project structure, conventions, requirements, security, testing, architecture
1548
+ - **web3/** (14 entries) — Foundry tooling and dev environment, smart-contract security and common vulnerabilities, upgradeability patterns, gas optimization, oracles and external data, audit workflow, deployment and verification, testing patterns, access control, EVM/contract architecture, conventions, project structure, requirements
1535
1549
 
1536
1550
  Each pipeline step declares which knowledge entries it needs in its frontmatter. The assembly engine injects them automatically. Knowledge files with a `## Deep Guidance` section are optimized for the CLI — only the deep guidance content is loaded into the assembled prompt, skipping the summary to avoid redundancy with the prompt text.
1537
1551
 
@@ -1740,7 +1754,7 @@ All build inputs live under `content/`:
1740
1754
  content/
1741
1755
  ├── pipeline/ # 60 meta-prompts organized by 16 phases (phases 0-15, including build)
1742
1756
  ├── tools/ # 10 tool meta-prompts (stateless, category: tool)
1743
- ├── knowledge/ # 235 domain expertise entries (core, product, review, validation, finalization, execution, tools, game, web-app, backend, cli, library, mobile-app, data-pipeline, ml, browser-extension, research, data-science)
1757
+ ├── knowledge/ # 267 domain expertise entries (core, product, review, validation, finalization, execution, tools, game, web-app, backend, cli, library, mobile-app, data-pipeline, ml, browser-extension, research, data-science, web3)
1744
1758
  ├── methodology/ # 3 YAML presets (deep, mvp, custom)
1745
1759
  └── skills/ # Skill templates with {{markers}} for multi-platform resolution (includes mmr)
1746
1760
  ```
@@ -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 `[BD-xxx]` task ID"
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 `[BD-xxx]` 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-42] feat(api): implement endpoint`.
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 [BD-123]: Reason`. Bare TODOs are not allowed.
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 [BD-123]: Reason for the TODO`. Also `FIXME [BD-456]` and `HACK [BD-789]`. Bare TODOs without task IDs accumulate without accountability and are not allowed.
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 BD-xxx).
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 BD-42: implement PATCH /api/v1/users/:id
150
- -> Task BD-43: add profile edit form component
151
- -> Task BD-44: add profile edit page with state management
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 `[BD-xxx]` for traceability
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
- Track task status through a simple state machine:
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
- - **ready** — All dependencies met, can start immediately
45
- - **in-progress** — Agent is actively working on it
46
- - **review** — Implementation complete, awaiting PR merge
47
- - **done** — PR merged, tests passing on main
48
- - **blocked** — Cannot proceed, dependency or question unresolved
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 `[BD-0]` bootstrap convention
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 status BD-xxx` | Check task state | Before picking up work |
82
- | `bd start BD-xxx` | Mark task in-progress | Beginning work on a task |
83
- | `bd done BD-xxx` | Mark task complete | After PR merged |
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 block BD-xxx "reason"` | Mark task blocked | When dependency is unmet |
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
- [BD-42] feat(api): implement user registration endpoint
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 `[BD-xxx]` prefix enables:
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 start BD-xxx` to claim the task
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 `[BD-xxx]` prefix
117
- 2. If task is complete: create PR, run `bd done BD-xxx`
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 `[BD-xxx]` message
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] BD-10: Database schema migration (done)
188
- - [x] BD-11: Auth middleware (done)
189
- - [ ] BD-12: User registration endpoint (in-progress)
190
- - [ ] BD-13: Login endpoint (ready)
191
- - [ ] BD-14: Profile management (blocked — needs BD-12)
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
- - BD-14: Waiting on BD-12 (user model finalization)
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
- ## BD-12: User registration endpoint
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 `[BD-xxx]` 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.
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 BD-42)
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-42/add-user-endpoint`) is the claim signal
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 claim <id>` to claim a task (if available)
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-42`, `bd-43`, etc.)
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
- ### BD_ACTOR Environment Variable
182
+ ### BEADS_ACTOR Environment Variable
183
183
 
184
- When using Beads for task tracking, set `BD_ACTOR` per agent for attribution:
184
+ When using Beads for task tracking, set `BEADS_ACTOR` per agent for attribution:
185
185
 
186
186
  ```bash
187
- export BD_ACTOR="agent-1"
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: