Use this skill when: Managing Claude Code context while working with Beads, preventing context bloat, or preserving critical workflow state across sessions
Use this skill when: Managing Claude Code context while working with Beads, preventing context bloat, or preserving critical workflow state across sessions
When working with Beads (bd CLI) across multiple sessions, strategic use of /context (preserve) and /compact (compress) commands is essential to maintain high-fidelity workflow state without hitting context limits.
Without context management:
bd JSON outputs accumulateWith strategic context management:
/context - Preserve Critical StatePurpose: Create a checkpoint that preserves current state for future reference
Use when:
Pattern:
/context "Brief description of what to preserve"
/compact - Compress Verbose StatePurpose: Summarize and remove verbose details while keeping essential information
Use when:
bd list, bd show operationsPattern:
/compact "What to preserve: [essentials]. What to remove: [verbosity]."
Trigger: Beginning a new session
Action:
# After: bd import + bd ready
/context "Session start: ready work queue [bd-5, bd-10, bd-15], current focus: bd-5 (implement auth), blockers: none"
Preserves:
Trigger: Starting work on issue with 3+ dependencies
Action:
# After: bd dep tree bd-42
/context "Working on bd-42 (refactor payment system). Depends on: bd-38 (schema), bd-40 (API). Discovered from: bd-35. Plan: [steps]"
Preserves:
Trigger: Discovering 3+ new issues during work
Action:
# After creating multiple issues
/context "Discovered from bd-50: bd-51 (validation bug, P0), bd-52 (missing tests, P2), bd-53 (docs, P3). Rationale: found during refactoring"
Preserves:
Trigger: Before/after major refactoring or design changes
Action:
/context "Pre-refactor: current architecture uses [X]. Planned changes: migrate to [Y]. Affected issues: bd-60, bd-61, bd-62. Risks: [list]"
Preserves:
Trigger: Switching between unrelated issues
Action:
/context "Switching: bd-70 -> bd-80. bd-70 status: [current state], next: [action]. bd-80 context: [background], plan: [approach]"
Preserves:
Trigger: After resolving Beads merge conflicts
Action:
/context "Merge resolved: 5 issues remapped (bd-90->bd-95, ...), preserved dependencies, no data loss. New HEAD: [commit]"
Preserves:
Trigger: Closed an issue
Action:
/compact "Preserve: bd-100 closed (reason: completed auth), unblocked: bd-101, bd-102. Remove: implementation details, verbose outputs."
Result:
Trigger: Multiple bd list, bd show commands
Action:
/compact "Preserve: current ready work [bd-110, bd-111], priorities, blockers. Remove: repetitive bd list outputs, unchanged issue details."
Result:
Trigger: Context > 75% full
Action:
/compact "Preserve: active issue bd-120, dependencies, next 3 steps. Remove: completed work details, old discovery chains, routine command outputs."
Result:
Trigger: Created 5+ issues at once
Action:
/compact "Preserve: created issues [bd-130 to bd-135] with priorities [P0, P1, P1, P2, P3, P3], dependencies summarized. Remove: verbose JSON payloads."
Result:
Trigger: Extended debugging session
Action:
/compact "Preserve: current hypothesis [X], tested approaches [A, B, C], next: try [D]. Remove: failed attempt details, verbose error outputs."
Result:
Complete multi-session workflow with context management:
SESSION START:
┌─────────────────────────────────────────────┐
│ 1. bd import -i .beads/issues.jsonl │
│ 2. bd ready --json --limit 5 │
│ 3. /context "Session start: [summary]" │
└─────────────────────────────────────────────┘
↓
CLAIM WORK:
┌─────────────────────────────────────────────┐
│ 1. bd update bd-X --status in_progress │
│ 2. bd dep tree bd-X │
│ 3. /context "Working on bd-X: [context]" │
└─────────────────────────────────────────────┘
↓
DURING WORK:
┌─────────────────────────────────────────────┐
│ Execute, discover, create sub-issues │
│ At major checkpoints: │
│ /context "Checkpoint: [brief desc]" │
│ After routine operations: │
│ /compact "Preserve: [key], Remove: [...]" │
└─────────────────────────────────────────────┘
↓
COMPLETE WORK:
┌─────────────────────────────────────────────┐
│ 1. bd close bd-X --reason "..." │
│ 2. /compact "Preserve: outcome, Remove: ..." │
└─────────────────────────────────────────────┘
↓
SESSION END:
┌─────────────────────────────────────────────┐
│ 1. /context "Session summary: [...]" │
│ 2. bd export -o .beads/issues.jsonl │
│ 3. git add + commit │
└─────────────────────────────────────────────┘
Maintain detailed context when:
Action: Use /context with full details
Compress context when:
Action: Use /compact to summarize
Wrong:
/compact "Remove everything from last hour"
Right:
/compact "Preserve: current issue bd-X, dependencies [list], next steps [list]. Remove: command outputs, completed work details"
Wrong:
# After every single bd command
bd list --json
/context "Listed issues"
bd show bd-5 --json
/context "Showed bd-5"
Right:
# Only at decision points
bd list --json
bd show bd-5 --json
bd dep tree bd-5
/context "Working on bd-5 (auth feature). Blocked by bd-3 (schema). Plan: [implementation steps]"
Wrong:
# Create issues without linking
bd create "Bug found" --json
bd create "Another bug" --json
# ... context lost
Right:
bd create "Bug in validation" --json # bd-100
bd dep add bd-100 bd-95 --type discovered-from
/context "Discovered bd-100 from bd-95: validation fails on edge case [X]"
Situation: Context lost after session interruption
Recovery:
# 1. Import latest state
bd import -i .beads/issues.jsonl
# 2. Find last worked issue
bd list --status in_progress --json
# 3. Reconstruct context
bd dep tree bd-X
/context "Resuming bd-X: [reconstruct from dependencies and git history]"
Situation: Context nearly full, losing critical state
Recovery:
# 1. Identify essentials
# - Current active issue
# - Immediate dependencies
# - Next 2-3 steps
# 2. Aggressive compaction
/compact "PRESERVE ONLY: active issue bd-X, dependencies [bd-Y, bd-Z], next steps [A, B, C]. REMOVE: all completed work, all routine outputs, all discovery history except current chain."
Monitor these indicators:
beads-workflow.md - Core bd commandsbeads-dependency-management.md - Dependency patterns to preservebeads-multi-session-patterns.md - Long-horizon task contextbeads-context/references/context_examples.md for real-world examples