Measure and optimize token overhead across agents, skills, MCP servers, and CLAUDE.md. Identifies bloated components and produces prioritized savings recommendations.
Estimates token consumption per component in your Claude Code setup and identifies optimization targets. Inspired by everything-claude-code's context budget system.
/context-budget-audit
Run a full audit of all agents, skills, MCP servers, hooks, and CLAUDE.md files.
/context-budget-audit <component>
Audit a specific component (agents, skills, mcp, hooks, claude-md).
| Content Type | Formula | Notes |
|---|---|---|
| Prose/Markdown | words x 1.3 | CLAUDE.md, SKILL.md, agent descriptions |
| Code blocks | chars / 4 | Python, YAML, JSON in skills |
| MCP tool schema | ~500 tokens/tool | Each declared tool in an MCP server |
| Agent YAML frontmatter | ~100 tokens | Metadata overhead per agent |
For each category:
- Read all files matching the pattern
- Calculate token estimate per file
- Sum category total
| Category | Path Pattern | Expected Count |
|---|---|---|
| Agents | ~/.claude/agents/*.md | ~61 core |
| Skills | ~/.claude/skills/*/SKILL.md | ~116 |
| MCP Servers | ~/.claude.json mcpServers | 21 servers |
| Hooks | ~/.claude/settings.json hooks | 7 hooks |
| Global CLAUDE.md | ~/.claude/CLAUDE.md | 1 file |
| Project CLAUDE.md | <project>/.claude/CLAUDE.md | Per-project |
| Memory | ~/.claude/projects/*/memory/MEMORY.md | 1 file |
| Docs | ~/.claude/docs/*.md | ~15 files |
| Level | Token Range | Action |
|---|---|---|
| Green | < 50K total | Healthy, no action needed |
| Yellow | 50K-100K | Review largest components |
| Red | > 100K | Active optimization required |
## Context Budget Report
### Summary
| Category | Files | Est. Tokens | % of Budget |
|----------|-------|-------------|-------------|
| Agents | 61 | XX,XXX | XX% |
| Skills | 116 | XX,XXX | XX% |
| MCP Schemas | 21 | XX,XXX | XX% |
| CLAUDE.md | 2 | XX,XXX | XX% |
| Memory | 1 | XX,XXX | XX% |
| Docs | 15 | XX,XXX | XX% |
| Hooks | 7 | XX,XXX | XX% |
| **TOTAL** | | **XXX,XXX** | **100%** |
### Top 10 Heaviest Components
[ranked list with file path, token estimate, and savings potential]
### Optimization Recommendations
[prioritized by token savings, easiest first]
| Strategy | Savings | Effort |
|---|---|---|
| Trim verbose SKILL.md preambles | 10-30% per file | Low |
| Use progressive skill loading | 40-60% of skill budget | Medium |
| Consolidate similar agents | 5-15% of agent budget | Medium |
| Reduce MCP server declarations to actually-used ones | 20-50% of MCP budget | Low |
| Move reference docs to on-demand loading | 80-90% of docs budget | Low |
| Compress MEMORY.md (remove stale entries) | Variable | Low |