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.mdsource 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 Transition | Compact? | Why |
|---|---|---|
| Research / Planning | Yes | Research context is bulky; plan is the distilled output |
| Planning / Implementation | Yes | Plan is in TodoWrite or a file; free up context for code |
| Implementation / Testing | Maybe | Keep if tests reference recent code; compact if switching focus |
| Debugging / Next feature | Yes | Debug traces pollute context for unrelated work |
| Mid-implementation | No | Losing variable names, file paths, and partial state is costly |
| After a failed approach | Yes | Clear the dead-end reasoning before trying a new approach |
What Survives Compaction
| Persists | Lost |
|---|---|
| CLAUDE.md / AGENTS.md instructions | Intermediate reasoning and analysis |
| TodoWrite task list | File contents you previously read |
Memory files () | Multi-step conversation context |
| Git state (commits, branches) | Tool call history and counts |
| Files on disk | Nuanced user preferences stated verbally |
Best Practices
- Compact after planning -- Once plan is finalized in TodoWrite, compact to start fresh
- Compact after debugging -- Clear error-resolution context before continuing
- Don't compact mid-implementation -- Preserve context for related changes
- Write before compacting -- Save important context to files or memory before compacting
- Use
with a summary -- Add a custom message:/compact/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
with verbose output, compact if moving to different modulecargo test - After architecture review or exploration, compact before starting refactoring work