/compact-guard
Smart context compaction with state preservation. Saves critical files, task progress, and working state before compaction, restores after. Use before manual compact or when auto-compact triggers.
One skill from pro-workflow.
shell
$ npx -y skills add rohitg00/pro-workflow --skill compact-guard --agent claude-codeInstalls just this skill. Get the whole plugin for auto-invocation.
How it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/compact-guard
Context preview
The summary Claude sees to decide when to auto-load this skill.
Smart context compaction with state preservation. Saves critical files, task progress, and working state before compaction, restores after. Use before manual compact or when auto-compact triggers.
Stats
Stars2,638
Forks255
LanguageJavaScript
SKILL.md
compact-guard.SKILL.md
--- name: compact-guard description: Smart context compaction with state preservation. Saves critical files, task progress, and working state before compaction, restores after. Use before manual compact or when auto-compact triggers. user-invocable: true --- # Compact Guard Protect important context through compaction cycles. Based on Claude Code internals: compaction restores max 5 files with 5K tokens each, within a 50K total budget. ## Trigger Use before `/compact` or when auto-compact warning appears. ## Key Constants (from Claude Code source) - `POST_COMPACT_MAX_FILES_TO_RESTORE = 5` โ only 5 files survive - `POST_COMPACT_TOKEN_BUDGET = 50K` โ total restore budget - `POST_COMPACT_MAX_TOKENS_PER_FILE = 5K` โ per-file limit - Auto-compact fires at `context_window - 13K` buffer ## Pre-Compact Checklist Before compacting, save these to memory or a scratch file: 1. **Current task** โ What are you working on? One sentence. 2. **Files in progress** โ Which files are being edited? (max 5 โ compaction only restores 5) 3. **Decisions made** โ Any architectural choices made this session 4. **Blockers** โ What's preventing progress? 5. **Next steps** โ What to do immediately after compact
