by Ruya-AI
Context cleaning for Claude Code — prune bloated sessions, protect Agent Teams from context loss, auto-guard with tiered pruning
# Add to your Claude Code skills
git clone https://github.com/Ruya-AI/cozempicContext cleaning for Claude Code — remove the bloat, keep everything that matters, protect Agent Teams from context loss.
Claude Code context fills up with dead weight that wastes your token budget: hundreds of progress tick messages, repeated thinking blocks and signatures, stale file reads that were superseded by edits, duplicate document injections, oversized tool outputs, and metadata bloat (token counts, stop reasons, cost fields). A typical session carries 8-46MB — most of it noise. Cozempic identifies and removes all of it using 13 composable strategies, while your actual conversation, decisions, tool results, and working context stay untouched.
File size is a poor proxy for context usage — a 1.1MB JSONL can hold 158K tokens. Cozempic reads the exact token counts from Claude's usage fields in the session file, so you see real context window usage instead of misleading byte sizes. Every command shows tokens and a context % bar, and guard thresholds can be set in tokens for precise compaction prevention.
When context gets too large, Claude's auto-compaction summarizes away critical state. For Agent Teams, this is catastrophic: the lead agent's context is compacted, team coordination messages (TeamCreate, SendMessage, TaskCreate/Update) are discarded, the lead forgets its teammates exist, and subagents are orphaned with no recovery path. (#23620, #23821, #24052, #21925)
Cozempic prevents this with five layers of protection:
No comments yet. Be the first to share your thoughts!
~/.claude/teams/*/config.json for authoritative team state (lead, members, models, cwds)Zero external dependencies. Python 3.10+ stdlib only.
pip install cozempic
Then inside Claude Code:
/plugin marketplace add Ruya-AI/cozempic
/plugin install cozempic
This gives you everything: MCP tools, skills (/cozempic:diagnose, /cozempic:treat, etc.), auto-wired ...