Strategic Compact
Hook-driven system that suggests manual /compact at strategic intervals rather than relying on auto-compact which fires at arbitrary points mid-task.
How it works
A PreToolUse hook on Edit/Write runs skills/strategic-compact/scripts/suggest-compact.js which:
- •Tracks tool call count per session via a temp file keyed by
CLAUDE_SESSION_ID - •Suggests
/compactat threshold (default 50 tool calls) — signals you're likely transitioning from exploration to execution - •Suggests again every 25 calls after threshold — periodic checkpoints for stale context
Why manual over auto-compact
- •Auto-compact happens at arbitrary points, often mid-task
- •Strategic compacting preserves context through logical phases
- •Compact after exploration, before execution
- •Compact after completing a milestone, before starting the next
Configuration
Set COMPACT_THRESHOLD environment variable to override the default 50-call threshold.
Files
- •
skills/strategic-compact/scripts/suggest-compact.js— the hook implementation - •Registered in
hooks/hooks.jsonas a PreToolUse hook on Edit/Write - •Works with
scripts/hooks/pre-compact.jswhich saves state before compaction