
cozempic
2x the effective context with smart weight-loss for Claude Code — prune bloated sessions, protect agent teams from compaction, monitor token usage with MCP tools
- version
- 1.8.39
- GitHub stars
- 429
Install
/plugin install cozempic@cozempicRun it inside Claude Code after adding the marketplace with /plugin marketplace add Ruya-AI/cozempic.
Contents
Discovered from sourceSkills 5
Run cozempic health checks:
cozempic doctor
Checks for:
- Trust dialog hang — Windows resume bug where
.claude.jsontrust entry causes hangs - Hooks trust flag — missing
hasTrustDialogHooksAcceptedcausing hooks to silently fail (v2.1.51+ bug) - Agent model mismatch — spawned subagents not inheriting team lead's model causing 403 errors
- Claude.json corruption — truncated or invalid
.claude.jsonfrom concurrent write races - Corrupted tool_use — tool blocks with names >200 chars causing 400 API errors
- Orphaned tool_results — tool_result blocks missing matching tool_use causing 400 API errors
- Zombie teams — stale agent team directories accumulating on disk
- Oversized sessions — sessions that may trigger compaction issues
- Stale backups — old
.bakfiles consuming disk space - Disk usage — total Claude Code storage footprint
To auto-fix detected issues:
cozempic doctor --fix
Run a diagnosis on the current session:
cozempic current --diagnose
The output includes:
- Weight: total session size in bytes and message count
- Tokens: exact token count (from usage data) or heuristic estimate
- Context bar: visual bar showing % of the detected context window (200K or 1M)
- Vital signs: progress ticks, file history snapshots, system reminders, thinking content, signatures, tool results
- Message type breakdown: bytes per message type
- Top 10 largest messages: biggest bloat contributors
- Estimated savings by prescription: what gentle/standard/aggressive would save
Always surface the token count and context % to the user. If context is above 60%, suggest running /cozempic:treat with a prescription recommendation:
- Under 5MB:
gentle - 5-20MB:
standard - Over 20MB:
aggressive
Start the cozempic guard daemon for continuous session protection.
Default (recommended)
cozempic guard --daemon --threshold 50 -rx standard --interval 30
This runs in the background and:
- Checkpoints team state every 30 seconds
- At 60% of threshold (30MB): applies gentle prune, no reload
- At threshold (50MB): applies full prescription + auto-reload with team state preserved
For agent teams
Guard mode is essential for sessions running agent teams. Without it, auto-compaction triggers and the lead agent loses team state (TeamCreate, SendMessage, tasks are discarded).
Options
--threshold N— hard threshold in MB (default: 50)--soft-threshold N— soft threshold in MB (default: 60% of hard)--threshold-tokens N— hard threshold in tokens (fires whichever hits first)--no-reload— prune without restarting Claude--no-reactive— disable kqueue/polling file watcher-rx NAME— prescription at hard threshold (default: standard)
Check status and stop
The daemon writes to /tmp/cozempic_guard_*.log. Check with:
ls /tmp/cozempic_guard_*.pid 2>/dev/null # is it running?
tail -20 /tmp/cozempic_guard_*.log 2>/dev/null # recent activity
kill "$(cat /tmp/cozempic_guard_*.pid)" # stop it
Treat the session and spawn an auto-resume watcher that opens a new terminal after you exit.
Steps
-
Diagnose first:
cozempic current --diagnose -
Dry-run:
cozempic treat current -rx $ARGUMENTSIf no argument was provided, use
standard:cozempic treat current -rx standard -
Show results including token savings. Ask confirmation.
-
Apply reload (treats + saves + spawns watcher in one shot):
cozempic reload -rx $ARGUMENTSDo NOT run
cozempic treat --executebeforecozempic reload— reload already treats internally. Running both would double-treat. -
Tell the user: "Treatment applied. Type
/exit— a new Terminal window will open automatically with the pruned session."
Apply a pruning prescription to the current session. Default is standard if no argument given.
When to use treat vs reload: prefer the reload skill — it does the same prune plus auto-resume in one step (/exit → new terminal opens with the pruned session). Use treat only when the user explicitly wants to stay in the current session, work in a multi-pane setup, or resume manually.
Steps
-
Diagnose first — show the user what they're working with:
cozempic current --diagnose -
Dry-run the treatment — show savings without applying:
cozempic treat current -rx $ARGUMENTSIf no argument was provided, use
standard:cozempic treat current -rx standard -
Show results — present the dry-run output including token savings (the
Tokens:line). Always surface both byte and token savings. -
Ask confirmation — use AskUserQuestion to confirm before applying.
-
Apply on confirmation:
cozempic treat current -rx $ARGUMENTS --execute -
Tell the user: "Treatment applied. A backup was created automatically. To resume with the pruned session, exit and run
claude --resume. (Tip: next time, thereloadskill does this in one step —/exitand a fresh terminal opens automatically.)"
Prescriptions
| Rx | Strategies | Typical Savings |
|---|---|---|
gentle | progress-collapse, file-history-dedup, metadata-strip | 40-55% |
standard | gentle + thinking-blocks, tool-output-trim, stale-reads, system-reminder-dedup | 50-70% |
aggressive | standard + error-retry-collapse, document-dedup, mega-block-trim, envelope-strip | 70-95% |
Safety
- Always dry-run first — never execute without showing the user what will change
- Backups are automatic (timestamped .bak files)
- Never touches uuid/parentUuid — conversation DAG stays intact
MCP servers 1
Sponsors
Details
- Marketplace
- Ruya-AI/cozempic
- Source
- plugin
- Category
- Productivity