openspec-beads-import
Import an approved OpenSpec change into Beads. Creates one epic, one Beads issue per tasks.md entry, infers task-level dependencies by reading each task description, then shows bd ready snapshot. Use after OpenSpec artifacts are approved and before coding starts.
- License 许可
- MIT
- 最近更新
- 2026-10-16
- Stars
- ★ 15
- Forks
- 1
01 前言 Front Matter
- name
- openspec-beads-import
- license
- MIT
- metadata
- { "author": "openspec", "version": "1.2", "generatedBy": "1.1.1" }
- description
- Import an approved OpenSpec change into Beads. Creates one epic, one Beads issue per tasks.md entry, infers task-level dependencies by reading each task description, then shows bd ready snapshot. Use after OpenSpec artifacts are approved and before coding starts.
- compatibility
- Requires openspec CLI and bd (beads) CLI.
03 SKILL.md 正文
Import an approved OpenSpec change into Beads as an executable task graph.
Source-of-truth rule: OpenSpec owns the spec. Beads owns the task graph. Never start coding directly from tasks.md — import first, then work from bd ready.
Input: A change name (kebab-case). If omitted, infer from conversation context or run openspec list and ask.
Setup
. "$(git rev-parse --show-toplevel)/scripts/openspec-beads/init.sh"
obws_init import || return 1
Steps
-
Confirm the change exists and is validated (strict — import bookend gate)
obws_gate_validate <change-id> strict # strict: catching missing scenarios here avoids a hard stop at archive obws_gate_status <change-id>Hard-stop on failure — do not import from a spec that fails strict validation.
-
Read the tasks file
cat openspec/changes/<change-id>/tasks.mdExtract all section headers and task items (
- [ ] N.M description). MANDATORY 1:1 rule: every- [ ] N.Mcheckbox becomes exactly one Beads node — never group multiple checkboxes into one issue. The per-taskmetadata.task_ref(e.g."1.3") must match the exact N.M from the checkbox — this is howopenspec-beads-workticks it on close.Task-ref format:
obws_tick_taskhandles any task_ref string via regex escaping. Two-level (1.3) and three-level (1.3.1) refs both work provided tasks.md uses them consistently. Ensure each- [ ] N.Mor- [ ] N.M.Pprefix is unique within the file. -
Build the dependency graph (cognitive step)
For each task, look for: explicit task references ("the repo from 2.1"), named artifact references (task B names a function task A creates), and logical chains within a section.
Report the inferred edges and reasoning to the user.
-
Write the graph JSON file
Write
openspec/changes/<change-id>/.bd-graph.jsonusing the schema inscripts/openspec-beads/graph.sh.Key rules:
- Root key is
"nodes"(NOT"issues"— the CLI rejects"issues"with "plan has no nodes") - Local alias field is
"key"(NOT"ref"— rejects"ref"with "empty key") - Every node must include
"labels": ["openspec:<change-id>"] - Every node must include
"metadata": {"openspec_change": "<change-id>", "task_ref": "N.M", "local_key": "<key>"} - Epic uses
"type": "epic"sobd epic close-eligibleandbd epic statuswork natively - Parent-child links:
"type": "parent-child"— task-to-task blocking:"type": "blocks"
Example structure:
{ "nodes": [ { "key": "epic", "title": "OpenSpec: <change-id>", "type": "epic", "priority": 2, "labels": ["openspec:<change-id>"], "description": "Execution tracker for openspec/changes/<change-id>.", "metadata": {"openspec_change": "<change-id>", "local_key": "epic"} }, { "key": "task-1-1", "title": "1.1: <task title>", "type": "task", "priority": 2, "labels": ["openspec:<change-id>"], "description": "openspec/changes/<change-id>/tasks.md §1.1. <verbatim task>", "metadata": {"openspec_change": "<change-id>", "task_ref": "1.1", "local_key": "task-1-1"}, "dependencies": [{"key": "epic", "type": "parent-child"}] } ] } - Root key is
-
Import atomically and tag
obws_import_graph <change-id>This helper: runs
bd create --graphon first import; on re-import diffs against existingmetadata.local_keyand creates only new nodes; wires parent-child and blocking edges post-create; appliesobws_tag_contextto all issues; checks for dependency cycles.Check
.bd-graph.jsoninto git. Re-running aftertasks.mdedits is safe. -
Verify the dependency graph landed
bd children <epic-id> --pretty bd show <issue-id> --json | jq '.[].labels'All issues (including the epic) must carry
branch:<name>,worktree:<name>,repo:<name>,openspec:<change-id>. The epic usestype=epic; theopenspec-beads-completequery addsAND (type=task OR type=bug)to exclude it from the required-work count.Run a structural lint on the imported issues:
obws_gate_lint --change <change-id>Fix any WARN/ERROR with
bd update <id> --acceptance "..."before proceeding. -
Show final state
bd children <epic-id> --pretty # NOTE: bd ready --explain --json returns an OBJECT {ready,blocked,summary,schema_version} # NOT an array — display only, do not pipe to jq '.[]' bd ready --explain --json bd graph --html <epic-id> > /tmp/<change-id>.html 2>/dev/null && \ echo "[import] Dep graph written to /tmp/<change-id>.html (open in browser to verify)" || trueReport: epic ID and child count, dependency graph summary, current
bd readyoutput. -
Register as swarm molecule (optional — verification step)
obws_import_graphalready callsbd swarm create <epic-id>internally. This step is a verification-only check:bd swarm list | head -5If the epic does not appear, run
bd swarm create <epic-id>manually. Passive label/structure primitive — enablesbd ready --mol <epic-id>for scope-filtered ready work. Notruflo swarm init. Does not spawn agents or coordinate work.
Non-obvious traps
obws_gate_validate <change-id> strictis required at import — strict failures caught here avoid a harder stop at archiveobws_import_graphhandles incremental re-import; calling it on an already-complete import is safe- The epic carries
openspec:<change-id>for filterability;openspec-beads-complete's query addsAND (type=task OR type=bug)to exclude it from the required-work count - Dep cycles detected by
obws_import_graphmust be fixed in.bd-graph.jsonbefore proceeding
Post-import parallelism (MANDATORY)
After import completes, immediately spawn concurrent agents for ALL ready tasks — never start one at a time.
READY=$(bd ready --mol <epic-id> --json --limit 20 | jq '[.[] | select(.issue_type != "epic") | {id, title}]')
echo "$READY"
Spawn rule:
- ≥ 2 ready tasks → the
ruflo-agent-route.shPreToolUse hook writes a model-tier advisory to stderr on each Agent spawn. Use those advisories (haiku/sonnet/opus) to set themodelparameter. Then send ONE message with multipleAgent({subagent_type: "claude", model: "<haiku|sonnet|opus>", prompt: "Run openspec-beads-work <id>..."})tool calls. All in one message = true concurrency. - Each agent is self-contained: it reads OpenSpec, claims, implements, validates, closes.
- Tasks that share a file (e.g., two tasks both modifying
tasks.mdtick) serialize naturally via Beads claim — the second agent will find the first task still in_progress and skip it.
Parallelism decision rule (from ruflo-swarm-dispatch):
- Independent tasks (different file paths) → built-in
Agenttool in parallel. This is the default. - Tasks sharing files or requiring ordered state →
ruflo swarmescalation only.
The dep graph already enforces ordering — anything bd ready shows is safe to run concurrently.
04 同仓库更多 Skills
ruflo-swarm-dispatch
Use when deciding between built-in Agent parallelism and ruflo-swarm for multi-agent tasks. Default is always the built-in Agent tool. Ruflo swarm is the escalation path for consensus-required or state-sharing tasks only.
openspec-verify-change
Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.
openspec-sync-specs
Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
openspec-onboard
Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
openspec-new-change
Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach.
openspec-ff-change
Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.