
Strategic Compact
Place manual /compact at logical task boundaries so long Claude Code sessions keep plans and drop stale exploration context.
Overview
strategic-compact is a journey-wide agent skill that suggests manual context compaction at logical workflow boundaries—usable whenever a solo builder needs to preserve plans and cut stale exploration before committing to
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill strategic-compactWhat is this skill?
- Recommends manual /compact after exploration before execution, after milestones, and before major context shifts
- suggest-compact.js on PreToolUse (Edit/Write): tracks tool calls, default suggest threshold 50 calls, reminders every 25
- Targets long sessions (200K+ tokens) and multi-phase flows: research → plan → implement → test
- Contrasts arbitrary auto-compaction mid-task with boundary-aware compaction
- Origin: ECC (Everything Claude Code) hook-oriented setup
- Default compaction suggestion threshold: 50 tool calls
- Periodic reminders every 25 tool calls after threshold
- Documented activation band: long sessions at 200K+ tokens
Adoption & trust: 5.5k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Auto-compaction fires mid-task and wipes research you still need, or your long agent session gets slow and incoherent as context fills up.
Who is it for?
Builders on Claude Code running 200K-scale sessions across research, planning, coding, and testing with Edit/Write heavy tool use.
Skip if: Short single-turn tasks or environments without manual compaction and custom PreToolUse hooks.
When should I use this skill?
Long sessions approaching context limits, multi-phase tasks, task switches, post-milestone work, or when responses slow or lose coherence.
What do I get? / Deliverables
You compact at milestone boundaries so implementation plans and decisions survive while exploratory tool noise is cleared before the next phase.
- Hook-driven compaction reminders
- Documented boundary checklist for when to compact
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Compact after competitor scraping so only the synthesized opportunity brief carries into validate scope.
After fifty Edit/Write tool calls, accept the hook nudge and /compact before the next feature slice.
Finish a test-fix loop milestone, compact, then start security review with a clean context window.
Switch from incident log triage to unrelated infra tweak mid-session and compact to avoid cross-task bleed.
Drop exploratory spike files from context once the prototype decision is recorded in the plan.
How it compares
Session hygiene skill with hook nudges, not a code formatter or automatic summarization MCP.
Common Questions / FAQ
Who is strategic-compact for?
Solo developers using Claude Code (ECC-style setups) who hit context limits and want compaction timed to task phases, not random auto-triggers.
When should I use strategic-compact?
Journey-wide: after idea research before validate scope notes, between build implementation chunks, before ship testing marathons, or when switching grow analytics tasks in one session; activate when responses slow or after ~50 tool calls per the default hook threshold.
Is strategic-compact safe to install?
It adds a local hook script that counts tool use and suggests compaction—review suggest-compact.js in the repo and the Security Audits panel on this Prism page before enabling hooks.
SKILL.md
READMESKILL.md - Strategic Compact
# Strategic Compact Skill 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 (200K+ tokens) - 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 (context pressure) ## Why Strategic Compaction? Auto-compaction triggers at arbitrary points: - Often mid-task, losing important context - No awareness of logical task boundaries - Can interrupt complex multi-step operations Strategic compaction at logical boundaries: - **After exploration, before execution** — Compact research context, keep implementation plan - **After completing a milestone** — Fresh start for next phase - **Before major context shifts** — Clear exploration context before different task ## How It Works The `suggest-compact.js` script runs on PreToolUse (Edit/Write) and: 1. **Tracks tool calls** — Counts tool invocations in session 2. **Threshold detection** — Suggests at configurable threshold (default: 50 calls) 3. **Periodic reminders** — Reminds every 25 calls after threshold ## Hook Setup Add to your `~/.claude/settings.json`: ```json { "hooks": { "PreToolUse": [ { "matcher": "Edit", "hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }] }, { "matcher": "Write", "hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }] } ] } } ``` ## Configuration Environment variables: - `COMPACT_THRESHOLD` — Tool calls before first suggestion (default: 50) ## Compaction Decision Guide Use this table to decide when to compact: | 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 Understanding what persists helps you compact with confidence: | Persists | Lost | |----------|------| | CLAUDE.md instructions | Intermediate reasoning and analysis | | TodoWrite task list | File contents you previously read | | Memory files (`~/.claude/memory/`) | Multi-step conversation context | | Git state (commits, branches) | Tool call history and counts | | Files on disk | Nuanced 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. **Read the suggestion** — The hook tells you *when*, you decide *if* 5. **Write before compacting** — Save important context to files or memory before compacting 6. **Use `/compact` with a summary** — Add a custom message: `/compact Focus on implementing auth middleware next` ## Token Optimization Patterns ### Trigger-Table Lazy Loading Instead of loading full skill content at session start, use a trigger table that maps keywords to skill paths. Skills load only when triggered, reducing baseline context by 50%+: | Trigger | Skill | Load When | |---