Strategic compact: manual context compaction for Claude Code
Hook-based reminder to run manual /compact at logical task boundaries instead of arbitrary auto-compaction
- What
- Hook-based reminder to run manual /compact at logical task boundaries instead of arbitrary auto-compaction
- Cost
- Free
- Needs
- Claude Code (the hook targets ~/.claude/settings.json); Node for the suggest-compact.js hook script; nothing else — guidance only
- Install
- Copy the installer prompt below into your Muse — your agent does the rest.
Curated by Skill Harbor — @affaan-m's compaction-timing skill for long Claude Code sessions: a PreToolUse hook script that watches two signals — context size (reads the session transcript's usage records and sums input+cache tokens, suggesting `/compact` at window-scaled thresholds: 160k on a 200k window, 250k on a 1M window, re-reminding every 60k more) and tool-call count (default 50, then every 25) — so compaction happens at logical boundaries (research→planning, milestone completed, before a context shift) instead of arbitrary mid-task auto-compaction. Includes a phase-transition decision table (compact after debugging and failed approaches; never mid-implementation), best practices (write the plan to a file first — the task list may not survive, since newer models removed TodoWrite by default), hook setup for `~/.claude/settings.json`, and environment configuration (COMPACT_THRESHOLD, COMPACT_CONTEXT_THRESHOLD, ECC_CONTEXT_WINDOW_TOKENS, CLAUDE_CODE_ENABLE_TODO_TOOLS). Honest caveats: the hook suggests, you decide — it never compacts by itself; files on disk survive compaction, intermediate reasoning does not; listed here with credit to its creator; MIT-licensed. Skill Harbor never reviews the code, review it yourself before use. Discovered via skills.sh.
Version:
Install
Prerequisites: Claude Code (the hook targets ~/.claude/settings.json); Node for the suggest-compact.js hook script; nothing else — guidance only Install "Strategic compact: manual context compaction for Claude Code" for me. A hook script that suggests manual /compact at logical task boundaries instead of arbitrary auto-compaction: watches context size (window-scaled thresholds from the session transcript's usage records) and tool-call count, with a phase-transition decision table, best practices (write the plan to a file before compacting), hook setup JSON and env-var configuration (COMPACT_THRESHOLD, COMPACT_CONTEXT_THRESHOLD, ECC_CONTEXT_WINDOW_TOKENS). Repository: https://github.com/affaan-m/ecc/blob/main/.agents/skills/strategic-compact/SKILL.md 1. Fetch the SKILL.md file (and any helper files) from the repository path into a temporary folder and summarize what it does in one or two sentences. 2. Safety check: review the SKILL.md and scripts for anything suspicious (unexpected network calls, shell commands, credential harvesting). This repo should contain zero secrets in code, credentials only via the secure vault, allowed hosts declared in the SKILL.md. Verify that holds here; STOP on any red flag and tell me. 3. Install it as a skill: copy SKILL.md and its helper files into the agent's skills directory, in a folder named "strategic-compact". 4. Verify with no network calls: frontmatter valid, files in place. 5. Report what was installed, where, and what I still need to do myself (e.g. add the PreToolUse hook entries to ~/.claude/settings.json, tune thresholds with env vars if wanted). GitHub is optional: if I have a GitHub account or the gh CLI, you may use it; otherwise public access is fine. Never require it unless it's in the prerequisites above. Rules: don't touch anything outside the temp folder and the install target. If anything looks off, stop and ask me.
Questions
How do I install a build?
Every product page includes a copy-paste install prompt. Paste it into your Muse and it sets the build up for you — no manual configuration.
Where does my money go?
Straight to the seller. Skill Harbor never processes payments: checkout happens on the seller’s own page, usually Stripe.
What does the ✓ next to a creator’s name mean?
It means we confirmed the identity of the person behind the listing. It says nothing about the code itself — always check a build before installing it.