Agent Instructions

This project uses bd (beads) for issue tracking. Run bd prime at the start of any session (after compaction, clear, or a new session) to load the workflow context.

Quick Reference

bd prime              # Load workflow context (run at session start)
bd ready              # Find available work
bd show <id>          # View issue details
bd update <id> --claim                  # Atomically claim work
bd update <id> --status in_progress     # Or set status explicitly
bd close <id>         # Complete work
bd dolt push          # Push issue DB to remote (Dolt)
bd dolt pull          # Pull issue DB from remote (Dolt)

Note: bd sync no longer exists in current bd versions. Beads now uses Dolt as the issue database and auto-commits every write to Dolt history. Use bd dolt push / bd dolt pull for remote sync.

Beads Tasks

When creating Beads tasks, always include Acceptance Criteria.

Acceptance Criteria: Must Be Verifiable. Each criterion must be something that can be objectively checked, not something vague.

Good criteria (verifiable)

Bad criteria (vague)

Always include as final criterion

For tasks with testable logic, also include

For tasks that change UI, also include

Agent Warning: Interactive Commands

DO NOT use bd edit — it opens an interactive editor ($EDITOR) which AI agents cannot use.

Use bd update with flags instead:

bd update <id> --description "new description"
bd update <id> --title "new title"
bd update <id> --design "design notes"
bd update <id> --notes "additional notes"
bd update <id> --acceptance "acceptance criteria"

# Use stdin for descriptions with special characters (backticks, !, nested quotes)
echo 'Description with `backticks` and "quotes"' | bd create "Title" --description=-
echo 'Updated text' | bd update <id> --description=-

Non-Interactive Shell Commands

ALWAYS use non-interactive flags with file operations to avoid hanging on confirmation prompts.

Shell commands like cp, mv, and rm may be aliased to include -i (interactive) mode on some systems, causing the agent to hang indefinitely waiting for y/n input.

Use these forms instead:

cp -f source dest           # NOT: cp source dest
mv -f source dest           # NOT: mv source dest
rm -f file                  # NOT: rm file

# For recursive operations
rm -rf directory            # NOT: rm -r directory
cp -rf source dest          # NOT: cp -r source dest

Other commands that may prompt:

Landing the Plane (Session Completion)

When ending a work session, you MUST complete ALL steps below. Work is NOT complete until git push succeeds.

MANDATORY WORKFLOW:

  1. File issues for remaining work — Create bd issues for anything that needs follow-up
  2. Run quality gates (if code changed) — Tests, linters, builds
  3. Update issue status — Close finished work, update in-progress items
  4. PUSH TO REMOTE — This is MANDATORY:
    git pull --rebase
    git push
    bd dolt push        # Sync issue DB to Dolt remote
    git status          # MUST show "up to date with origin"
    
  5. Clean up — Clear stashes, prune remote branches
  6. Verify — All changes committed AND pushed (both code and beads)
  7. Hand off — Provide context for next session

CRITICAL RULES:

Issue Tracking with bd (beads)

IMPORTANT: This project uses bd (beads) for ALL issue tracking. Do NOT use markdown TODOs, task lists, or other tracking methods.

Why bd?

Quick Start

Check for ready work:

bd ready --json

Create new issues:

bd create "Issue title" --description="Detailed context" -t bug|feature|task -p 0-4 --json
bd create "Issue title" --description="What this issue is about" -p 1 --deps discovered-from:bd-123 --json

# Use stdin for descriptions with special characters (backticks, !, nested quotes)
echo 'Description with `backticks` and "quotes"' | bd create "Title" --description=- --json

Claim and update:

bd update <id> --claim --json
bd update bd-42 --priority 1 --json

Complete work:

bd close bd-42 --reason "Completed" --json

Issue Types

Priorities

Workflow for AI Agents

  1. Check ready work: bd ready shows unblocked issues
  2. Read execution metadata first: before deciding local vs delegated work, model, or reasoning level, inspect structured metadata:
    bd show <id> --json | jq '.[0] | {id,title,metadata,description,notes}'
    

    The execution metadata keys execution_agent_type, execution_suggested_model, execution_reasoning_effort, execution_mode, and execution_parallel_group are authoritative hints when present. Use description and notes as fallback context.

  3. Claim your task atomically: bd update <id> --claim
  4. Work on it: Implement, test, document
  5. Discover new work? Create linked issue:
    • bd create "Found bug" --description="Details about what was found" -p 1 --deps discovered-from:<parent-id>
  6. Complete: bd close <id> --reason "Done"

Auto-Sync (Dolt Backend)

bd automatically syncs via Dolt:

Task Verification (CRITICAL)

Never close a task without verifying ALL acceptance criteria.

Before marking any task complete:

  1. Run bd show <id> to see the full acceptance criteria
  2. Verify each criterion individually against the actual code/implementation
  3. Run verification commands (typecheck, tests, browser check) if listed
  4. Only close when ALL criteria pass — partial completion = task stays open

Common mistakes to avoid:

If any criterion fails: The task is NOT complete. Either fix the gaps or leave it open.

Important Rules

Using bv as an AI sidecar

bv (beads_viewer) is a graph-aware triage engine for Beads projects. Instead of parsing the issue DB or hallucinating graph traversal, use robot flags for deterministic, dependency-aware outputs with precomputed metrics (PageRank, betweenness, critical path, cycles, HITS, eigenvector, k-core).

Scope boundary: bv handles what to work on (triage, priority, planning). For agent-to-agent coordination (messaging, work claiming, file reservations), use MCP Agent Mail.

⚠️ CRITICAL: Use ONLY --robot-* flags. Bare bv launches an interactive TUI that blocks your session.

The Workflow: Start With Triage

bv --robot-triage is your single entry point. It returns everything you need in one call:

bv --robot-triage        # THE MEGA-COMMAND: start here
bv --robot-next          # Minimal: just the single top pick + claim command

# Token-optimized output (TOON) for lower LLM context usage:
bv --robot-triage --format toon
export BV_OUTPUT_FORMAT=toon
bv --robot-next

Other Commands

Planning:

Command Returns
--robot-plan Parallel execution tracks with unblocks lists
--robot-priority Priority misalignment detection with confidence

Graph Analysis:

Command Returns
--robot-insights Full metrics: PageRank, betweenness, HITS, eigenvector, critical path, cycles, k-core, articulation points, slack
--robot-label-health Per-label health: health_level, velocity_score, staleness, blocked_count
--robot-label-flow Cross-label dependency: flow_matrix, dependencies, bottleneck_labels
--robot-label-attention [--attention-limit=N] Attention-ranked labels by: (pagerank × staleness × block_impact) / velocity

History & Change Tracking:

Command Returns
--robot-history Bead-to-commit correlations
--robot-diff --diff-since <ref> Changes since ref

Other Commands:

Command Returns
--robot-burndown <sprint> Sprint burndown, scope changes, at-risk items
--robot-forecast <id\|all> ETA predictions with dependency-aware scheduling
--robot-alerts Stale issues, blocking cascades, priority mismatches
--robot-suggest Hygiene: duplicates, missing deps, label suggestions, cycle breaks
--robot-graph [--graph-format=json\|dot\|mermaid] Dependency graph export
--export-graph <file.html> Self-contained interactive HTML visualization

Scoping & Filtering

bv --robot-plan --label backend              # Scope to label's subgraph
bv --robot-insights --as-of HEAD~30          # Historical point-in-time
bv --recipe actionable --robot-plan          # Pre-filter: ready to work (no blockers)
bv --recipe high-impact --robot-triage       # Pre-filter: top PageRank scores
bv --robot-triage --robot-triage-by-track    # Group by parallel work streams
bv --robot-triage --robot-triage-by-label    # Group by domain

Understanding Robot Output

All robot JSON includes:

Two-phase analysis:

For large graphs (>500 nodes): Some metrics may be approximated or skipped. Always check status.

jq Quick Reference

bv --robot-triage | jq '.quick_ref'                        # At-a-glance summary
bv --robot-triage | jq '.recommendations[0]'               # Top recommendation
bv --robot-plan | jq '.plan.summary.highest_impact'        # Best unblock target
bv --robot-insights | jq '.status'                         # Check metric readiness
bv --robot-insights | jq '.Cycles'                         # Circular deps (must fix!)
bv --robot-label-health | jq '.results.labels[] | select(.health_level == "critical")'

Performance: Phase 1 instant, Phase 2 async (500ms timeout). Prefer --robot-plan over --robot-insights when speed matters. Results cached by data hash.

Use bv instead of parsing the beads DB directly — it computes PageRank, critical paths, cycles, and parallel tracks deterministically.