Smart Compact
Hooks that save changed files, open todos and recent commands before Claude Code compacts, then re-inject them afterwards.
$4
Works with the AI Agents you already use
Smart Compact
Example session with this skill installed
A 3-hour refactor session hits auto-compact at 85% context.
- Read your context and instructions
- Compiled the smart compact
After compaction the session starts with: Current task, Open todos ([in_progress] Migrate auth middleware), Files modified (src/auth.ts, tests/auth.test.ts), Recent shell commands, Last 3 user messages.
Connects securely to your tools. The creator never sees your data.
About this skill
Compaction drops detail. Smart Compact keeps the parts of a long session you need to resume.
How it works
- A PreCompact hook's output is display-only, so it cannot carry state into the compacted context. Only SessionStart
additionalContextcan. - So one script handles three hooks: Stop (silent refresh each turn, gated by a context-usage threshold) and PreCompact (final refresh) write a summary to a sidecar file; SessionStart with source compact/resume reads it, injects it as
additionalContextand deletes it. - The summary lists: current task, open TodoWrite items, files modified, recent shell commands and the last user messages. It is built by rules from the transcript, not by an LLM, so it costs no tokens.
What you get
smart_compact.py, a single stdlib-only Python file.--previewto see what would be preserved, with no install.- Config file for threshold, list sizes and context window size.
Tested with a synthetic transcript: preview, Stop writes the sidecar, PreCompact prints a message, SessionStart(compact) emits additionalContext and removes the sidecar, SessionStart(startup) stays silent.
The summary is rule-based: it lists facts (files, commands, todos, messages), not reasoning. Open todos come from the most recent TodoWrite call only. If a future Claude Code version changes the transcript format the summary becomes empty and the hooks stay silent; they never block. Set context_window_tokens to your model's real window or the threshold percentage will be wrong. The summary quotes recent shell commands and messages, so review it before sharing.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
Requires
Permissions
File Scopes
No network access. Hooks always exit 0.