Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By agentic-tool-labsv0.10.1Apache-2.0In 1 marketplace
Runs /compact automatically when a session goes idle, timed to land just before the Anthropic prompt cache expires — or, in keepalive mode, pings the cache instead of compacting.
You run one by typing its /name in Claude Code.
1 critical to review before installing
JavaScript or TypeScript that runs inside Claude Code as you, unsandboxed. Read from its source, it runs programs; reads or rewrites your prompts.
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Runs /compact for you when a session has been sitting idle, timed to land
just before Anthropic's prompt cache expires. You can attach your own focus
instructions to it. There's also a keepalive mode that pings the cache instead
of compacting, for when you'd rather keep your local context exactly as it is.
Anthropic's prompt cache has two lifetimes: 5 minutes (the default,
cache_control: {"type": "ephemeral"}) and 1 hour ("ttl": "1h"). While a
session's cached prefix is alive, re-sending it costs about 0.1× the base input
price. Once it expires, the next turn pays for a full cache write: 1.25× on the
5-minute cache, 2× on the 1-hour one.
So the useful moment to compact is a few minutes before the cache dies. That's late enough that if you come straight back you still land on a warm cache, and early enough that the compaction request itself reads the warm prefix instead of paying to write the whole thing again.
The defaults follow from that: 55 minutes for the 1-hour cache, 4 minutes for the 5-minute one. The plugin asks which you use the first time it runs.
Claude Code's hooks can't start a compaction. There's no idle or timer hook, no
hook output that submits a turn or runs a slash command, and PreCompact can
only block a compaction that's already under way.
So the plugin does the one thing that does work: it types /compact into your
terminal for you.
turn ends ──▶ Stop hook (arm.js)
├─ context below the token floor? → do nothing
└─ spawn a detached timer process, recording an armId
you type ──▶ UserPromptSubmit hook (disarm.js) → kill timer, delete state
idle ──▶ timer.js wakes, re-verifies the armId and that the transcript
has not been touched, then types "/compact" + Enter into the
pane this session is running in
Where Claude Code loads the plugin's mod (hooks/register.ts, listed under
modules in hooks/hooks.json), no typing happens: the mod arms its own
timer when a turn ends, cancels it on your next prompt, and compacts through
the engine ($.session.compact, the call /compact makes). It reads the same
config (idle window, token floor, compaction prompt) and writes the same fire
log. Keepalive mode still types its ping. The mod loads with the plugin
(update it, then /reload-plugins); claude --debug logs a line naming it
if it did not load.
Works under managed Claude Code: the mod arms on turn.complete, which an
organization's policy does not pass over the way it does a user plugin's
classic.* hooks, so it compacts through the engine with no admin step. Where
the Stop hook (arm.js) also ran and armed its injection timer, the mod stops
that timer after it arms, whichever of the two ran first.
Without the mod, the plugin needs a way to send keystrokes to your terminal. By default it only uses methods that can pick out your specific pane or tab. Methods that type into whichever window has focus are off unless you turn them on (see Blind injection).
You need Node.js 18 or newer on your PATH. Claude Code's npm install brings
its own Node, but the native installer doesn't, so check this. If node is
missing the hooks fail harmlessly and the plugin just never fires;
/idle-compact doctor will tell you.
You also need a supported terminal (see Terminal support).
/plugin marketplace add agentic-tool-labs/agent-tools
/plugin install idle-compactor@agent-tools
In the first session after installing, the plugin asks you two things: the idle
threshold, and the smallest context worth compacting. Run /idle-compact setup
whenever you want to change those answers.
It works fine on its own. The two other compaction plugins in this repo, compaction-capture and compaction-guard, are separate installs.
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub agentic-tool-labs/agent-tools --plugin idle-compactorPlugins from other owners that cover similar ground