Skip to main content

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: Export candidates for agent review without requiring an API key:
Accept agent-provided summary without requiring an API key:

Auto Mode (Legacy)

AI-powered compaction using Claude API (requires ANTHROPIC_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:
This removes unreachable commits and compacts storage to reclaim disk space.

Flags

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:
Output:

Compact Specific Issue

Batch Compaction

Dolt Cleanup

After accumulating many commits, run garbage collection:

When to Use Compact

Use bd 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
Don’t use 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

  1. Identifies eligible issues based on tier criteria
  2. Exports full issue content (description, design, notes, acceptance criteria)
  3. Outputs JSON for agent consumption
  4. No database changes

Apply Mode

  1. Validates eligibility (bypass with --force)
  2. Replaces all text fields with provided summary
  3. Records compaction metadata (tier, sizes, timestamp)
  4. Adds audit trail event
  5. Preserves issue structure (ID, status, relationships)

Auto Mode

  1. Validates ANTHROPIC_API_KEY is set
  2. For each eligible issue:
    • Sends content to Claude API
    • Receives semantic summary
    • Applies summary via same path as Apply Mode
  3. Shows progress bar for batch operations

Dolt GC Mode

  1. Locates .beads/dolt directory
  2. Runs dolt gc command
  3. Reports size before/after
  4. 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 --force flag 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 --force flag if summary is intentionally longer
  • bd show - View issue details before compacting
  • bd list - Find old closed issues to compact
  • bd dolt - Manage Dolt database directly
  • bd backup - Back up before compaction

See Also