Libmagic-rs strategic-compact

Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.

install
source · Clone the upstream repo
git clone https://github.com/EvilBit-Labs/libmagic-rs
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/EvilBit-Labs/libmagic-rs "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/strategic-compact" ~/.claude/skills/evilbit-labs-libmagic-rs-strategic-compact && rm -rf "$T"
manifest: .claude/skills/strategic-compact/SKILL.md
source content

Strategic Compact

Suggests manual

/compact
at strategic points in your workflow rather than relying on arbitrary auto-compaction.

When to Activate

  • Running long sessions that approach context limits
  • Working on multi-phase tasks (research, plan, implement, test)
  • Switching between unrelated tasks within the same session
  • After completing a major milestone and starting new work
  • When responses slow down or become less coherent

Compaction Decision Guide

Phase TransitionCompact?Why
Research / PlanningYesResearch context is bulky; plan is the distilled output
Planning / ImplementationYesPlan is in TodoWrite or a file; free up context for code
Implementation / TestingMaybeKeep if tests reference recent code; compact if switching focus
Debugging / Next featureYesDebug traces pollute context for unrelated work
Mid-implementationNoLosing variable names, file paths, and partial state is costly
After a failed approachYesClear the dead-end reasoning before trying a new approach

What Survives Compaction

PersistsLost
CLAUDE.md / AGENTS.md instructionsIntermediate reasoning and analysis
TodoWrite task listFile contents you previously read
Memory files (
~/.claude/memory/
)
Multi-step conversation context
Git state (commits, branches)Tool call history and counts
Files on diskNuanced user preferences stated verbally

Best Practices

  1. Compact after planning -- Once plan is finalized in TodoWrite, compact to start fresh
  2. Compact after debugging -- Clear error-resolution context before continuing
  3. Don't compact mid-implementation -- Preserve context for related changes
  4. Write before compacting -- Save important context to files or memory before compacting
  5. Use
    /compact
    with a summary
    -- Add a custom message:
    /compact Focus on implementing indirect offsets next

Rust-Specific Considerations

  • After reading large source files (evaluator/mod.rs at 2,638 lines), compact before implementation
  • After running
    cargo test
    with verbose output, compact if moving to different module
  • After architecture review or exploration, compact before starting refactoring work