Overview
Compact old closed issues using semantic summarization to reduce database size. This is permanent graceful decay - original content is replaced with AI-generated summaries.Syntax
Modes
Compaction operates in three modes:Analyze Mode (Recommended)
Export candidates for agent review without requiring an API key:Apply Mode (Recommended)
Accept agent-provided summary without requiring an API key:Auto Mode (Legacy)
AI-powered compaction using Claude API (requiresANTHROPIC_API_KEY):
Compaction Tiers
Tier 1: Semantic Compression
- Eligibility: 30 days closed
- Reduction: ~70% size reduction
- Content: Detailed summary preserving key context
Tier 2: Ultra Compression
- Eligibility: 90 days closed, already Tier 1 compacted
- Reduction: ~95% size reduction
- Content: Minimal summary for archival reference
- Status: Not yet implemented
Dolt Garbage Collection
With auto-commit enabled, Dolt commit history grows over time. Use--dolt to run garbage collection:
Flags
| Flag | Description |
|---|---|
--analyze | Export candidates for agent review (no API key needed) |
--apply | Accept agent-provided summary (no API key needed) |
--auto | AI-powered compaction (requires ANTHROPIC_API_KEY) |
--summary <path> | Path to summary file (use ’-’ for stdin) |
--actor <name> | Actor name for audit trail (default: “agent”) |
--id <issue-id> | Compact specific issue |
--all | Process all eligible candidates |
--tier <1|2> | Compaction tier (default: 1) |
--limit <n> | Limit number of candidates (0 = no limit) |
--force | Bypass eligibility checks (requires —id) |
--dry-run | Preview without compacting |
--stats | Show compaction statistics |
--dolt | Run Dolt garbage collection |
--json | Output JSON format |
Examples
Agent-Driven Workflow
The recommended workflow uses an agent to review and summarize issues:View Statistics
See how many issues are eligible for compaction:Compact Specific Issue
Batch Compaction
Dolt Cleanup
After accumulating many commits, run garbage collection:When to Use Compact
Usebd compact when:
- Database size is growing: Old closed issues accumulate over time
- Historical context isn’t needed: Issues closed 30+ days ago rarely need full detail
- Disk space is limited: Compaction can reduce database size by 70%+
- Dolt history is large: Frequent auto-commits create many commit objects
bd compact when:
- Issues might be reopened: Original content is permanently lost
- Legal/compliance requirements: Some industries require full audit trails
- Recent closure: Wait 30 days before compacting to ensure stability
How It Works
Analyze Mode
- Identifies eligible issues based on tier criteria
- Exports full issue content (description, design, notes, acceptance criteria)
- Outputs JSON for agent consumption
- No database changes
Apply Mode
- Validates eligibility (bypass with
--force) - Replaces all text fields with provided summary
- Records compaction metadata (tier, sizes, timestamp)
- Adds audit trail event
- Preserves issue structure (ID, status, relationships)
Auto Mode
- Validates ANTHROPIC_API_KEY is set
- For each eligible issue:
- Sends content to Claude API
- Receives semantic summary
- Applies summary via same path as Apply Mode
- Shows progress bar for batch operations
Dolt GC Mode
- Locates
.beads/doltdirectory - Runs
dolt gccommand - Reports size before/after
- Removes unreachable commits
Troubleshooting
”Issue not eligible for compaction”
Cause: Issue doesn’t meet tier criteria (age, status, compaction level) Solution:- Check eligibility with
bd compact --stats - Use
--forceflag to bypass (with caution) - Wait until issue meets age requirements
”ANTHROPIC_API_KEY not set”
Cause: Auto mode requires Claude API access Solution:- Use Analyze/Apply mode instead (recommended)
- Or set environment variable:
export ANTHROPIC_API_KEY=sk-...
”Dolt directory not found”
Cause:--dolt flag used in non-Dolt repository
Solution: Only use --dolt in repositories using Dolt backend
”Summary not shorter than original”
Cause: Provided summary is larger than original content Solution:- Review and shorten the summary
- Use
--forceflag if summary is intentionally longer
Related Commands
bd show- View issue details before compactingbd list- Find old closed issues to compactbd dolt- Manage Dolt database directlybd backup- Back up before compaction