Skip to main content

Overview

The bd mol distill command is the reverse of bd mol pour: instead of formula → molecule, it’s molecule → formula. It extracts a reusable formula from an existing epic, converting concrete values to variable placeholders for future reuse.

Usage

Arguments

  • <epic-id> - ID of the epic to distill into a formula
  • [formula-name] - Optional formula name. If omitted, derived from epic title.

Options

  • --var key=value - Replace value with {{variable}} placeholder (can be specified multiple times)
  • --dry-run - Preview what would be created without writing files
  • --output <dir> - Output directory for formula file (default: auto-detect)
  • --json - Output results in JSON format

Variable Syntax

Both formats are supported (smart detection):
The command detects which side is the concrete value by searching the epic text.

Output Locations

Formulas are written to the first writable directory (in order):
  1. .beads/formulas/ (project-level, default)
  2. ~/.beads/formulas/ (user-level, if project not writable)
Use --output to specify a different directory.

Examples

Extract Simple Workflow

Capture a successful workflow for reuse:
Output:

Extract with Variables

Replace specific values with variables:
Output:

Preview Before Creating

Use --dry-run to see the structure:
Output:

Custom Output Location

Save formula to specific directory:

Variable Substitution

How It Works

The --var flag replaces concrete values in the epic text with {{variable}} placeholders: Before:
After (with —var component=auth —var environment=staging):

Smart Detection

The command automatically detects which format you used:
Both produce the same result. Use whichever feels more natural.

Multiple Variables

Replace multiple values:

Formula Structure

The generated formula includes:
  • Title and description (from epic root)
  • Steps (from epic children)
  • Dependencies (from issue relationships)
  • Variables (from —var flags)
  • Labels (excluding internal ones)
  • Priority levels

Example Output File

.beads/formulas/feature-workflow.formula.json:

Use Cases

Capture Tribal Knowledge

Team develops a successful workflow organically:

Create Organization Standards

Standardize processes across teams:

Incremental Refinement

Start with basic formula, refine over iterations:

Document Successful Releases

Capture release processes that worked well:

Emergency Response Templates

Create templates from incident responses:

JSON Output

Workflow: Distill → Refine → Pour

1. Distill

Extract the raw formula:

2. Refine

Edit the generated formula file:

3. Verify

Test the formula:

4. Pour

Use the refined formula:

Common Patterns

No Variables (Direct Copy)

Just capture the structure:

Auto-Named Formula

Let formula name derive from epic title:

Multiple Epics, Same Formula

Distill similar epics to compare:

Error Handling

Variable Not Found

Solution: Check epic content and use actual values.

Epic Not Found

Solution: Verify epic ID with bd list --type epic.

Write Permission Denied

Solution: Create .beads/formulas/ directory or use --output.