catnap tells Claude at 50% context what the context is and that it should finish what it's working on, write a handoff, and then initialize compaction itself. When Claude finishes its task, catnap compacts, and Claude can then pick up work again. The handoff replaces Claude Code's default summary, so we don't do similar work twice. If Claude for some reason doesn't compact before 60%, it gets a stricter note. And Claude Code's default auto-compact kicks in at 70% as a backstop. The 3 numbers are all settings.
After I took on catnap, 0 of 129 naps came mid-task: 98 of them in benchmarks and 31 in my own sessions.
The cost is the same as the default auto-compact kicking in at the same point, in tokens and dollars, on 200K and 1M context windows. Compared to the default auto-compaction that kicks in when context is nearly full, catnap used 56% fewer tokens. But lowering the default auto-compact will get you most of the way there as well.
I measured memory today as well. Claude worked through tasks one message at a time while 20 instructions and facts were said in the chat, inside long chatty messages, and nowhere else. Asked right after compaction to list them from memory, no file reads: all 20 were listed with catnap and with the default compaction, in every run (15 with catnap, 5 with the default). So in my tests the memory was exactly the same, but catnap got there with a handoff 60% shorter (4.0K tokens against 10K).
I was surprised that catnap is actually faster than the default option. This wasn't even one of the reasons I wanted to make this, it just happened. Since Claude writes the handoff in one go instead of the separate summary call the default makes, and the note is shorter, tasks finish sooner: measured end to end, 406 seconds instead of 464.
Try it with nothing installed:
npx github:LippInc/catnap
It prints how often auto-compact cut in mid-task in your own logs (reads numbers only, sends nothing).Install (needs Claude Code 2.1.287 or later, where mods are on by default):
claude plugin marketplace add LippInc/catnap
claude plugin install catnap@lippinc
Currently Claude Code only, tested on Windows and Linux. The memory test used made-up coding tasks on a 200K window.Some related tools: compact-adviser, handoff-compact, session-pilot and sub-agent-compact. What catnap adds: Claude finishes its piece first, and the numbers on where the cut lands.