$npx -y skills add affaan-m/everything-claude-code --skill context-budgetAudits Claude Code context window consumption across agents, skills, MCP servers, and rules. Identifies bloat, redundant components, and produces prioritized token-savings recommendations.
| 1 | # Context Budget |
| 2 | |
| 3 | Analyze token overhead across every loaded component in a Claude Code session and surface actionable optimizations to reclaim context space. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Session performance feels sluggish or output quality is degrading |
| 8 | - You've recently added many skills, agents, or MCP servers |
| 9 | - You want to know how much context headroom you actually have |
| 10 | - Planning to add more components and need to know if there's room |
| 11 | - Running `/context-budget` command (this skill backs it) |
| 12 | |
| 13 | ## How It Works |
| 14 | |
| 15 | ### Phase 1: Inventory |
| 16 | |
| 17 | Scan all component directories and estimate token consumption: |
| 18 | |
| 19 | **Agents** (`agents/*.md`) |
| 20 | - Count lines and tokens per file (words × 1.3) |
| 21 | - Extract `description` frontmatter length |
| 22 | - Flag: files >200 lines (heavy), description >30 words (bloated frontmatter) |
| 23 | |
| 24 | **Skills** (`skills/*/SKILL.md`) |
| 25 | - Count tokens per SKILL.md |
| 26 | - Flag: files >400 lines |
| 27 | - Check for duplicate copies in `.agents/skills/` — skip identical copies to avoid double-counting |
| 28 | |
| 29 | **Rules** (`rules/**/*.md`) |
| 30 | - Count tokens per file |
| 31 | - Flag: files >100 lines |
| 32 | - Detect content overlap between rule files in the same language module |
| 33 | |
| 34 | **MCP Servers** (`.mcp.json` or active MCP config) |
| 35 | - Count configured servers and total tool count |
| 36 | - Estimate schema overhead at ~500 tokens per tool |
| 37 | - Flag: servers with >20 tools, servers that wrap simple CLI commands (`gh`, `git`, `npm`, `supabase`, `vercel`) |
| 38 | |
| 39 | **CLAUDE.md** (project + user-level) |
| 40 | - Count tokens per file in the CLAUDE.md chain |
| 41 | - Flag: combined total >300 lines |
| 42 | |
| 43 | ### Phase 2: Classify |
| 44 | |
| 45 | Sort every component into a bucket: |
| 46 | |
| 47 | | Bucket | Criteria | Action | |
| 48 | |--------|----------|--------| |
| 49 | | **Always needed** | Referenced in CLAUDE.md, backs an active command, or matches current project type | Keep | |
| 50 | | **Sometimes needed** | Domain-specific (e.g. language patterns), not referenced in CLAUDE.md | Consider on-demand activation | |
| 51 | | **Rarely needed** | No command reference, overlapping content, or no obvious project match | Remove or lazy-load | |
| 52 | |
| 53 | ### Phase 3: Detect Issues |
| 54 | |
| 55 | Identify the following problem patterns: |
| 56 | |
| 57 | - **Bloated agent descriptions** — description >30 words in frontmatter loads into every Task tool invocation |
| 58 | - **Heavy agents** — files >200 lines inflate Task tool context on every spawn |
| 59 | - **Redundant components** — skills that duplicate agent logic, rules that duplicate CLAUDE.md |
| 60 | - **MCP over-subscription** — >10 servers, or servers wrapping CLI tools available for free |
| 61 | - **CLAUDE.md bloat** — verbose explanations, outdated sections, instructions that should be rules |
| 62 | |
| 63 | ### Phase 4: Report |
| 64 | |
| 65 | Produce the context budget report: |
| 66 | |
| 67 | ``` |
| 68 | Context Budget Report |
| 69 | ═══════════════════════════════════════ |
| 70 | |
| 71 | Total estimated overhead: ~XX,XXX tokens |
| 72 | Context model: Claude Sonnet (200K window) |
| 73 | Effective available context: ~XXX,XXX tokens (XX%) |
| 74 | |
| 75 | Component Breakdown: |
| 76 | ┌─────────────────┬────────┬───────────┐ |
| 77 | │ Component │ Count │ Tokens │ |
| 78 | ├─────────────────┼────────┼───────────┤ |
| 79 | │ Agents │ N │ ~X,XXX │ |
| 80 | │ Skills │ N │ ~X,XXX │ |
| 81 | │ Rules │ N │ ~X,XXX │ |
| 82 | │ MCP tools │ N │ ~XX,XXX │ |
| 83 | │ CLAUDE.md │ N │ ~X,XXX │ |
| 84 | └─────────────────┴────────┴───────────┘ |
| 85 | |
| 86 | WARNING: Issues Found (N): |
| 87 | [ranked by token savings] |
| 88 | |
| 89 | Top 3 Optimizations: |
| 90 | 1. [action] → save ~X,XXX tokens |
| 91 | 2. [action] → save ~X,XXX tokens |
| 92 | 3. [action] → save ~X,XXX tokens |
| 93 | |
| 94 | Potential savings: ~XX,XXX tokens (XX% of current overhead) |
| 95 | ``` |
| 96 | |
| 97 | In verbose mode, additionally output per-file token counts, line-by-line breakdown of the heaviest files, specific redundant lines between overlapping components, and MCP tool list with per-tool schema size estimates. |
| 98 | |
| 99 | ## Examples |
| 100 | |
| 101 | **Basic audit** |
| 102 | ``` |
| 103 | User: /context-budget |
| 104 | Skill: Scans setup → 16 agents (12,400 tokens), 28 skills (6,200), 87 MCP tools (43,500), 2 CLAUDE.md (1,200) |
| 105 | Flags: 3 heavy agents, 14 MCP servers (3 CLI-replaceable) |
| 106 | Top saving: remove 3 MCP servers → -27,500 tokens (47% overhead reduction) |
| 107 | ``` |
| 108 | |
| 109 | **Verbose mode** |
| 110 | ``` |
| 111 | User: /context-budget --verbose |
| 112 | Skill: Full report + per-file breakdown showing planner.md (213 lines, 1,840 tokens), |
| 113 | MCP tool list with per-tool sizes, duplicated rule lines side by side |
| 114 | ``` |
| 115 | |
| 116 | **Pre-expansion check** |
| 117 | ``` |
| 118 | User: I want to add 5 more MCP servers, do I have room? |
| 119 | Skill: Current overhead 33% → adding 5 servers (~50 tools) would add ~25,000 tokens → pushes to 45% overhead |
| 120 | Recommendation: remove 2 CLI-replaceable servers first to stay under 40% |
| 121 | ``` |
| 122 | |
| 123 | ## Best Practices |
| 124 | |
| 125 | - **Token estimation**: use `words × 1.3` for prose, `chars / 4` for code-heavy files |
| 126 | - **MCP is the biggest lever**: each tool schema costs ~500 tokens; a 30-tool server costs more than all your skills combined |
| 127 | - **Agent descriptions are loaded always**: e |