Delegates when to compact to the model. At each turn end, and before an idle session's prompt cache lapses, it asks the session's own model whether to compact.
To truly cherish the things that are important to you, you must first discard
those that have outlived their purpose.
— Marie Kondo, The Life-Changing Magic of Tidying Up
sparkjoy is a Claude Code plugin that lets Claude decide when to compact,
keeping the full 1M window available for work that needs it. Since Dec 1, Claude
Code defaults to compacting once the context passes about 370k tokens, almost
always while Claude is still working[^window]. Against that default, sparkjoy
gets 20% more work done per dollar, though as my sessions
ran it cost 8% more per request.
The ways a Claude Code session gets compacted, with and without sparkjoy:
When it compacts
/compact
when you run it
Claude Code
at ~370k tokens (~965k with /autocompact 1M), usually mid-turn
Claude Code (idle)
from 200k, just before the 1-hour cache expires[^idle]
sparkjoy
at a turn end from 250k, if the model says to
sparkjoy (idle)
from 175k, just before the cache expires, if the model says to
Context size over a session with sparkjoy, compared
with what the same requests would have carried under Claude Code's 400K default
and its full 1M window:
Every request reads the full context, so the area under each line is total
tokens read. Over the whole session, the 400K default compacted mid-turn 24
times and sparkjoy never did. sparkjoy kept context past 370k while the model
judged the work still needed it.