{
  "markdown": "# context-optimizer\n\n<p align=\"center\">\n  <img src=\"icon.png\" alt=\"Context Optimizer\" width=\"300\">\n</p>\n\n<p align=\"center\">\n  <strong>Audit and optimize Claude Code context window usage</strong><br>\n  Plugins, hooks, CLAUDE.md, MCP servers, env settings — scored report with auto-fix.\n</p>\n\n---\n\nA Claude Code plugin that audits and optimizes your context window usage — plugins, hooks, CLAUDE.md, MCP servers, and environment settings.\n\nBorn from real-world optimization that achieved **50% token reduction** on a heavy agentic workflow (15 plugins, 30+ hooks, 4-layer CLAUDE.md cascade).\n\n## What It Does\n\nRuns a 9-phase audit:\n\n1. **Cost Analysis** — Historical token spending via [ccusage](https://github.com/LEON-gittech/ccusage)\n2. **Measure** — Count enabled plugins, hooks, CLAUDE.md tokens, MCP servers\n3. **Audit Plugins** — Score each plugin by overhead (hooks, matchers, tech stack relevance)\n4. **Audit Hooks** — Inventory all hooks across sources, detect duplicates and conflicts\n5. **Audit CLAUDE.md** — Check cascade for duplication, bloat, wrong tech stack\n6. **Audit MCP & Env** — Find unused servers, suggest env optimizations, detect connection churn\n7. **Check .claudeignore** — Verify exclusion of irrelevant files\n8. **Generate Report** — Scored report with before/after estimates\n9. **Apply Fixes** — Direct edits with user approval\n\n## New: Hidden Cost Detection (v2)\n\nRecent updates detect previously invisible costs:\n\n- **Zombie claude processes**: Sessions from agentic workflows (ralph, autopilot, ultrawork) that run for days/weeks — one case found 5 zombies including a 115-day-old process\n- **Zombie MCP processes**: Old claude sessions leave 300+ orphaned processes consuming 30+ GB RAM\n- **Subagent session accumulation**: Agent tool spawns create session records that pile up (100+ sessions per project), cluttering the resume list\n- **Stale persistent-mode state files**: `.omc/state/*-state.json` with `active: true` blocks session termination even after workflows end\n- **Deleted CWD zombies**: Worktrees get removed but the claude process keeps running with `(deleted)` CWD\n- **alwaysThinkingEnabled**: Adds 30-50% latency to every response\n- **PostToolUse hooks spawning sub-processes**: Invisible process and context cost per trigger\n- **MCP connection churn**: Reconnection loops causing I/O bloat and CPU spikes\n- **effortLevel overuse**: Using \"high\" for all tasks wastes 40% tokens\n\n## Why This One\n\n| Feature | context-optimizer | audit-setup | token-optimizer | context-optimization |\n|---------|:-:|:-:|:-:|:-:|\n| Plugin scoring | Y | - | - | - |\n| Hook duplicate detection | Y | - | - | - |\n| Per-tool-call overhead calc | Y | - | - | - |\n| CLAUDE.md cascade dedup | Y | Y | - | - |\n| MCP server audit | Y | - | - | - |\n| .claudeignore check | Y | - | - | - |\n| Env var optimization | Y | - | partial | - |\n| Auto-fix (Edit tool) | Y | Y | - | - |\n| Agentic workflow aware | Y | - | - | - |\n| Zero dependencies | Y | Y | npm pkg | Y |\n\n## Install\n\n```bash\n/plugin marketplace add LEON-gittech/claude-context-optimizer\n/plugin install context-optimizer@LEON-gittech\n```\n\nOr manually:\n\n```bash\ncp skills/context-optimizer/SKILL.md ~/.claude/skills/context-optimizer/SKILL.md\n```\n\n## Usage\n\nIn any Claude Code session:\n\n```\n/context-optimizer\n```\n\nOr ask naturally: \"optimize my context\", \"why are tokens so expensive\", \"audit my plugins\"\n\n## Real-World Results\n\nTested on a project with:\n- 15 enabled plugins → optimized to 7\n- 30+ hooks per event cycle → reduced to 18\n- 8,425 token CLAUDE.md cascade → 4,570 tokens\n- Startup overhead: ~35-50K → ~20-25K tokens (**50% reduction**)\n- Per agentic iteration: **500K-1M tokens saved**\n\nAdditional optimization case (2026-04):\n- 300+ zombie MCP processes → 0 (killed orphaned processes)\n- 9 claude processes (5 zombies, oldest 115 days) → 3 healthy processes\n- Node process memory: 14.8 GB → 4.6 GB (**69% reduction**)\n- 100+ subagent session records cluttering resume list identified\n- Stale `.omc/state/` files with `active: true` blocking session exits → cleaned\n- `alwaysThinkingEnabled` disabled → 30-50% faster response\n- PostToolUse sub-process spawn hook removed → fewer invisible processes per Skill call\n- Unused MCP servers removed → fewer processes, less context bloat\n\n## Companion: ccusage (forked with 14x speedup)\n\nUse [ccusage](https://github.com/LEON-gittech/ccusage) to measure actual token spending before and after optimization:\n\n```bash\nnpm install -g ccusage\nccusage --period day    # daily cost breakdown by model\nccusage --period week   # weekly trend\n```\n\nOur fork adds per-file caching for 14x faster analysis on large datasets.\n\n## License\n\nMIT\n",
  "bytes": 4666,
  "sha": "f3015d28884487247295c41cbd4cf6f51eddd0270c4d025d3287302146cd5dae",
  "repo_slug": "leon-gittech/claude-context-optimizer",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_leon_gittech_claude_context_optimizer_cl_63c3bcb1/readme"
}