Mods

smart-compact

Keeps your session ready, and compacts without the wait.

It comes with the pack and is on from the start.

The moment

You step away for lunch with a long session open.

Without smart-compact

While you’re gone, the conversation’s cache expires: after an hour on a subscription, after five minutes on an API key. Your next prompt then writes the whole conversation to the cache again, at a higher price. For a session of 400k tokens that is $3.20$3.20$3.20
Not measured
Opus 5.5
, just to pick up where you left off.

With smart-compact

A few minutes before the cache expires, smart-compact does whichever costs less: it keeps the cache warm with one cheap request, or it compacts the conversation while the cache is still warm. Small sessions it leaves alone. The status line tells you whether your session is ready or has gone cold. Turn on compaction after a turn and it also compacts a long conversation shortly after a turn ends, when that pays back within the next few requests. Its summary is written in the background as the turn ends, from the session’s own cache, so the compaction itself takes no time you notice.

Choose how long you are away, and smart-compact’s own rules decide what happens.

You are away for
Without smart-compact$3.20$3.20$3.20
Not measured
Opus 5.5
to write it all again when you’re back
Back at the keyboard: ○ cold
With smart-compactKept warm twice, at $0.09$0.09$0.09
Not measured
Opus 5.5
each
Back at the keyboard: ● ready

What it saves

Keeping warm is worked out from prices rather than measured. For that session, letting the cache expire costs $3.20$3.20$3.20
Not measured
Opus 5.5
, one keep-alive $0.09$0.09$0.09
Not measured
Opus 5.5
, and compacting about $0.87about $0.87About $0.87
Not measured
Opus 5.5
, plus whatever detail the summary loses. Compacting after a turn was measured: with the summary written ahead the compaction took 3 to 5 ms15.2 s to 3 to 5 ms15.2 s to 3 to 5 ms
A handful of live compactions
Sonnet 5.5, 19 Oct 2026
, where Claude Code’s own took 102 s102 s102 s
One compaction
Opus 5.5, 19 Oct 2026
in a long session, and the next job came out 14% cheaper13.9% cheaper, 95% range 9.4 to 18.1% cheaper13.9% cheaper
95% range 9.4 to 18.1% cheaper
18 runs each
Opus 5.5, 19 Oct 2026
than after /compact, with 16 of 18 against 14 of 1816 of 18 against 14 of 1816 of 18 against 14 of 18
18 runs each
Opus 5.5, 19 Oct 2026
runs at full marks.

Every measurement for smart-compact

The dot is the measured change, the bar around it the 95% range, the upright line no change. Left of the line is cheaper or fewer.

Tried for smart-compact and dropped: a summary without a model.

Where it doesn’t help

A small session has little to save, so it does nothing there. If your computer sleeps past the moment to act, it can’t act, and it marks the cache as cold. Compacting after a turn is off until you turn it on: on a short task that ends right there, the payback never comes.

Turn it on or off

/cache shows the live figures and the plan. strategy: keepalive never compacts, and /mods smart-compact off turns it off. afterTurnPayback: 20 turns on compacting after a turn, and with it the summary written ahead. Every option is in the README and SETUP.md; the code is in smart-compact/.

In a real session

A real Claude Code session with compacting after a turn turned on: after Claude reads two large files and answers, the session is compacted from 126k to about 40k tokens at once, its summary written in the background, and the next question is answered from it. Play the recording