smart-compact
Keeps your session ready, and compacts without the wait.
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.
● ready · cold in 57m● ready · cold in 57mNot measured
Opus 5.5 to write it all again when you’re backBack at the keyboard:
○ coldNot measured
Opus 5.5 eachBack at the keyboard:
● readyNot measured
Opus 5.5 to write it all again when you’re backBack at the keyboard:
○ coldNot measured
Opus 5.5 eachBack at the keyboard:
● readyWhat 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.
- Away from an idle 400k-token session: let the cache expire, re-cache on returnworked out from list prices, not measured$3.20Not measured. Opus 5.5
- One keep-alive for the same session: a cheap read resets the cache's clockworked out from list prices, not measured$0.09Not measured. Opus 5.5
- Compacting the same session while its cache is still warmworked out from list prices, not measuredabout $0.87Not measured. Opus 5.5
- How long a compaction takes, the summary written ahead against Claude Code's ownClaude Code writing the summary in the compaction to smart-compact's summary written in the background after the turn15.2 s to 3 to 5 msA handful of live compactions. Sonnet 5.5, 19 Oct 2026
- Claude Code's own summary in a 436k-token sessionthe wait while the engine wrote the summary, before smart-compact's fix102 sOne compaction. Opus 5.5, 19 Oct 2026
- The next task after a summary written ahead, against after /compactthe summary written ahead against /compact13.9% cheaper95% range 9.4 to 18.1% cheaper18 runs each. Opus 5.5, 19 Oct 2026
- Runs at full marks after a summary written ahead, against after /compactthe summary written ahead against /compact; mean score 0.981 against 0.917, a difference whose range touches zero16 of 18 against 14 of 1818 runs each. Opus 5.5, 19 Oct 2026
- What a summary written ahead costs, on a warm cacheaverage, repriced on a warm cache at list prices ($0.09 to $0.24)$0.1318 summaries. Opus 5.5, 19 Oct 2026
- How much of a summary repeats the conversation word for wordof a summary written ahead's text (17% and 20% in two of Claude Code's own summaries); the part a program could copy19%19 summaries. Opus 5.5, 19 Oct 2026
- What 1,000 tokens of summary cost over their life$0.020 written once as output, $0.008 to the cache, $0.029 read again by a median of 143 later requests; worked out from list prices$0.057Worked out, not measured. Opus 5.5, 19 Oct 2026
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
Play the recording