Disclosure: I created this tool for our internal use but now It’s free, open source (MIT), and has zero dependencies. I run large code bases and 10+ agent teams on long overnight tasks. The two problems i faced regularly: Claude Code sessions fill up with stuff Claude doesn’t need e.g. progress ticks, file history snapshots, stale tool results, debugging session repeats, unused file reads. In a typical team session, 20-40% of the context is junk. That means compaction triggers way earlier than it should, and when it does fire, it summarises poor content and still wastes space - did i mention it also wipes agent/team state. Here’s what bloat looks like in a real session: Patient: 547f8a35 (This is the Claude Code context session) Weight: 12.75MB (5,070 messages) Progress ticks: 821 ← pure noise File history snaps: 222 ← rarely needed Tool results: 1.78MB ← stale reads from hours ago Estimated savings: gentle ~822KB standard ~2.96MB aggressive ~4.15MB What cozempic does: Runs a background guard daemon that: Continuously prunes bloat from the session JSONL and you get more usable context before compaction ever triggers Checkpoints team/agent state to disk every 30s, all agents, Agent Teams, every task, all preserved Soft threshold: gentle trim, zero disruption Hard threshold: full prune + auto-resume If “Conversation too long” hits anyway: detects the crash, prunes, kills Claude, resumes (~10s recovery) [Fixes several ClaudeCode reported bugs] [15:51:09] Checkpoint #135: 15 agents, 25 tasks, 364 msgs (11.1MB) [15:58:28] Checkpoint #139: 15 agents, 25 tasks, 369 msgs (11.1MB) [12:08:03] Checkpoint #155: 18 agents, 25 tasks, 385 msgs (12.0MB) [20:40:15] Checkpoint #174: 18 agents, 25 tasks, 405 msgs (12.7MB) That’s real output. 174 checkpoints over a multi-day session. Team state saved every time. Setup: pip install cozempic cozempic init Guard starts automatically on every session after that. No second terminal, no config. Zero dependencies. There are https://github.com/anthropics/claude-code/issues?q=is%3Aopen+compaction+context on the Claude Code repo about compaction killing sessions. This doesn’t fix the root cause (that’s on Anthropic), but auto applies patches, works around the issues and keeps your sessions alive until they do so with the added benefit of getting almost 2x usable context. Repo: https://github.com/Ruya-AI/cozempic Try it out and let us know if it helps (shipped a Windows encoding fix today from a community report). submitted by /u/Retromorphix
Originally posted by u/Retromorphix on r/ClaudeCode
