Skip to main content
Molecules are work graphs: epics whose children flow through bd ready as dependency-ordered steps. They are usually instantiated from formulas, but a formula is optional — any epic with children is a molecule.

What is a Molecule?

A molecule is a persistent instance of a proto (a cooked formula):
  • Contains steps with dependencies
  • Persistent beads in the issue database, synced like any other bead
  • Steps map to issues with parent-child relationships
Under the hood, a molecule is just an epic — a parent bead with children — plus workflow semantics: Protos and formulas are optional layers for reusable patterns and complex composition — most work needs only epics and dependencies.

Creating Molecules

From a Formula

This creates:
  • Parent issue: bd-xyz (the molecule root)
  • Child issues: bd-xyz.1, bd-xyz.2, etc. (the steps)

Without a Formula

Create the epic and wire the dependencies directly:
If the epic carries a size/effort label, see Labels for keeping it off the steps. If an ad-hoc epic turns out to be worth repeating, extract a reusable formula from it with bd mol distill <epic-id> <formula-name>.

Finding Molecules

Viewing a Molecule

A molecule’s steps are the issues linked to its root by a parent-child dependency (what --parent and bd mol pour create). An ID that only looks hierarchical, such as bd-xyz.4 with no such dependency, does not make an issue a step.

Working with Molecules

The Execution Model

An agent picks up a molecule and executes ready children in parallel until everything closes:
Children are parallel by default. Only explicit dependencies create sequence. The multi-session loop:
  1. Get ready work: bd ready --mol <molecule-id>
  2. Claim it: bd update <id> --claim
  3. Do the work
  4. Close it: bd close <id>
  5. Repeat until the molecule is done

Dependency Types

Only some dependency types block execution: Non-blocking types (related, discovered-from, replies-to) link issues without affecting execution.

Step Dependencies

In a formula, steps declare needs:
On live issues, add the edge directly — the dependent comes first:
The bd ready command respects these:

Progressing Through Steps

--continue claims the next ready step for you (it becomes in_progress and yours), skipping any step someone else already holds; add --no-auto to see the next step without claiming it. Against a bd serve that cannot advance a molecule, bd close --continue refuses before closing anything, so a step is never left closed with the next one unclaimed.

Viewing Progress

Molecule Lifecycle

When the Last Step Closes

Closing a molecule’s last open step closes its root in the same command, with the reason all steps complete:
Not every root closes this way: A root that bd close would refuse on its own stays open too — for example, it has an open blocker, it is pinned, or it is assigned to someone else. The step still closes, and a warning names the root and the reason:
Once the obstacle is gone, bd close <root-id> closes the root, and so does closing the last step again. A bd serve that does not close molecule roots for its clients (an older server, or one whose orchestrator manages molecules) leaves the root open: bd close prints a note naming it, and bd close <root-id> closes it. With --json, the step’s entry reports the closed root, or why it stayed open — see the JSON Output Schema Contract. For cleanup of the beads themselves:
  • bd mol squash <id> condenses a molecule’s ephemeral children into a permanent digest issue.
  • bd mol burn <id> deletes a molecule outright, no digest — for abandoned or test runs.
See Wisps for the ephemeral lifecycle these commands usually serve.

Bonding: Connecting Work Graphs

Bond means creating a dependency between two work graphs. When molecule A blocks molecule B, completing A unblocks B and an agent can continue from A into B — one compound workflow that can span days.
The command is polymorphic over its operands: Spawned issues follow the target’s phase (persistent or ephemeral) by default. Override with --pour (force persistent) or --ephemeral (force ephemeral) — see Wisps.

Dynamic Bonding

When the number of children isn’t known until runtime, bond in a loop with --ref to get readable child IDs instead of random hashes:

Advanced Features

Bond Points

Formulas can define bond points — named attachment sites for composition. Each names a step to attach before_step or after_step (with optional parallel = true):

Hooks

Step-completion hooks are not currently exposed as runnable formula actions. The historical on_complete.run example was invalid: run is not a formula field, and on_complete runtime expansion is tracked separately until it is wired end to end.

Assigning Molecules

Assign the molecule root to an agent at pour time, then track where each agent is:

Agent Pitfalls

  1. Temporal language inverts dependencies. “Phase 1 comes before Phase 2” tempts bd dep add phase1 phase2 — backwards. Use requirement language: “Phase 2 needs Phase 1” is bd dep add phase2 phase1. Verify with bd blocked.
  2. Numbered steps don’t create sequence. Steps named “Step 1/2/3” still run in parallel until you add dependencies between them.
  3. Forgetting to close work. Blocked issues stay blocked forever if their blockers aren’t closed: bd close <id> --reason "Done".

Example Workflow

See Also