一键导入
context-budget
Token audit across agents, skills, and MCP with cost optimization guidance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Token audit across agents, skills, and MCP with cost optimization guidance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Convert PDF/EPUB library to Markdown and generate Obsidian MOC notes
Hook-based compaction suggestions at logical task boundaries
Context window management — track spend, decide when to compact, preserve state
Session-start orientation — loads context, surfaces learnings, confirms registry
Quality and semantic review — catches what automated tools miss
Planner → Architect → Critic deliberation loop — produces a formally validated ADR
| name | context-budget |
| description | Token audit across agents, skills, and MCP with cost optimization guidance |
| version | 0.1.0 |
| level | 2 |
| triggers | ["audit context usage","token budget","context cost","optimize context"] |
| context_files | ["context/project.md"] |
| steps | [{"name":"Inventory Collection","description":"Count skills, agents, MCP servers, and hooks"},{"name":"Token Estimation","description":"Estimate tokens per component category"},{"name":"Cost Calculation","description":"Calculate per-session cost at current model pricing"},{"name":"Bottleneck Identification","description":"Identify highest token consumers"},{"name":"Optimization Recommendations","description":"Suggest consolidation or reduction strategies"}] |
Token audit and cost optimization for Claude Code configurations. Identifies context bloat and suggests fixes.
Without context budgeting, you:
Context budgeting makes token consumption visible and actionable.
~300 tokens per skill, loaded only when invoked. Typically 1-3 per session = 600-1,500 tokens. Already efficient (on-demand loading).
~1,500 tokens per agent, loaded when spawned. Typically 1-2 per session = 1,500-3,000 tokens. Session-isolated. Consolidate if spawning 5+ per session.
Base cost per tool: ~500 tokens (tool schema with parameters, descriptions, examples) Loaded when: MCP server connected at session start
Critical insight: 30-tool MCP server = 15,000 tokens per message. Example: 4 MCP servers (filesystem, github, brave-search, obsidian) = ~19,000 tokens per message. 50-turn session: 950K tokens just for schemas. Primary cost driver.
~1,500 tokens (loaded per message). Keep under 200 lines.
~1,000 tokens per file when loaded. 5 files = 5,000 tokens. Low priority.
~75 tokens per hook. Hooks run outside LLM. Negligible cost.
Session Configuration:
Per-Message Cost: 19,000 (MCP) + 1,500 (CLAUDE.md) + 3,000 (context) + 750 (hooks) = 24,250 tokens 50-Turn Session: 24,250 × 50 = 1,212,500 tokens input At Sonnet pricing ($3/MTok): $3.64 per session (input only)
MCP contribution: 19,000 / 24,250 = 78% of per-message cost
Problem: 38 tools loaded, only using 12 regularly
Solution: Split MCP servers by usage frequency
Savings: 26 tools × 500 = 13,000 tokens per message 50-turn session: 650,000 tokens saved = $1.95 per session
Problem: MCP tools loaded on main agent even though only subagents use them
Solution: Follow psc_comet pattern (mcp-agent with MCP-only access)
Savings: 19,000 tokens × 40 turns (if mcp-agent needed for 10/50 turns) = 760,000 tokens = $2.28
Problem: 8 skills with 60%+ overlap (e.g., multiple research skills)
Solution: Merge into 1-2 unified skills
Savings: Marginal (skills are on-demand), but improves usability
Problem: CLAUDE.md at 180 lines with verbose descriptions
Solution: Use directive imperatives (short commands) instead of explanations
Savings: 500-1,000 tokens per message = 25,000-50,000 per session = $0.08-$0.15
Problem: All 5 context files loaded at session start, even if only 2 are needed
Solution: Skills specify which context files they need (already implemented in frontmatter)
Savings: 3 files × 1,000 tokens × 50 turns = 150,000 tokens = $0.45 per session
# Context Budget Report
**Date:** 2026-03-28
**Configuration:** psc_comet
## Component Inventory
- Skills: 31 (on-demand)
- Agents: 10 (spawn-on-need)
- MCP Servers: 4 (38 tools total)
- CLAUDE.md: 140 lines
- Context Files: 5
- Hooks: 10
## Token Breakdown (Per Message)
| Component | Tokens | % of Total |
|-----------|--------|------------|
| MCP Tools | 19,000 | 78% |
| CLAUDE.md | 1,500 | 6% |
| Context Files | 3,000 | 12% |
| Hooks | 750 | 3% |
| Skills | 600 | 2% |
| **Total** | **24,850** | **100%** |
## Session Cost Estimate
**50-turn session:** 24,850 × 50 = 1,242,500 input tokens
**Model:** Sonnet ($3/MTok input, $15/MTok output)
**Input cost:** $3.73
**Output cost (est 50K tokens):** $0.75
**Total:** ~$4.48 per session
## Optimization Opportunities
1. **MCP isolation** (high impact): Move MCP to mcp-agent only
- Savings: ~$2.28 per session (51% reduction)
2. **MCP server splitting** (high impact): Separate core vs extended tools
- Savings: ~$1.95 per session (44% reduction)
3. **Context file lazy-loading** (medium impact): Load only when skill requires
- Savings: ~$0.45 per session (10% reduction)
**Combined potential savings:** $4.68 → $2.00 per session (57% reduction)
Premature optimization: Optimizing context before measuring. Audit first, optimize second.
Ignoring MCP cost: Focusing on skill consolidation (2% of cost) while ignoring MCP bloat (78% of cost).
No tracking over time: Running audit once. Context bloat accumulates. Audit quarterly.
Optimizing for tokens, ignoring value: Removing high-value MCP tools to save tokens. Optimize low-value components first.