compact-guard

Installation
SKILL.md

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:

Related skills
Installs
14
GitHub Stars
2.1K
First Seen
Apr 5, 2026