context-budget
Audit context window consumption across TAOM agents, skills, rules, MCP servers, and CLAUDE.md. Report token estimates, flag bloat, recommend trims.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Audit context window consumption across TAOM agents, skills, rules, MCP servers, and CLAUDE.md. Report token estimates, flag bloat, recommend trims.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Root-cause native Bannerlord CTDs (AccessViolation in TaleWorlds.Native.dll) via Event Log offsets, offline disassembly, and live debugger forensics. No symbols needed.
Dispatch an independent Codex verification job directly via `codex exec` Bash call, then retrieve and present results
Inspect all changed files, group by logical concern, and guide atomic per-concern commits following TAOM's 50/72 rule and commit trailer convention.
Load a snapshot saved by /context-save and present it so this session can pick up where the last one left off without re-deriving decisions.
Launch parallel deep-dive agents to review completed work for quality, standards, compatibility, completeness, and cross-system data flow
Respond to a Bannerlord engine update (Steam force-bump or deliberate migration) — preserve the decompile baseline, regen, diff, re-verify bindings and creature data, control-battle.
| name | context-budget |
| description | Audit context window consumption across TAOM agents, skills, rules, MCP servers, and CLAUDE.md. Report token estimates, flag bloat, recommend trims. |
| argument-hint | [{"optional":"--verbose for per-file breakdown"}] |
Quantifies what TAOM's .claude/ setup consumes from the context window before a single user message is processed. Drives every other context optimization decision (e.g., whether two-layer skill injection or three-layer compression are urgent or premature).
Adapted from affaan-m/everything-claude-code.
bash .claude/skills/context-budget/scan.sh
This walks every .claude/ component, the .mcp.json, and CLAUDE.md, then prints a structured report.
For a per-file breakdown, run with --verbose:
bash .claude/skills/context-budget/scan.sh --verbose
Sample structure:
TAOM Context Budget Report
===========================
Total estimated baseline overhead: ~XX,XXX tokens
Context model: Claude Opus 4.7 (1M)
Effective available context: ~XXX,XXX tokens (XX% headroom)
Component Breakdown:
+-----------------+-------+-----------+
| Component | Count | Tokens |
+-----------------+-------+-----------+
| CLAUDE.md | 1 | ~X,XXX |
| Agents | N | ~X,XXX |
| Skills | N | ~X,XXX |
| Rules | N | ~X,XXX |
| MCP servers | N | ~XX,XXX |
| Hooks (shell) | N | ~X,XXX |
+-----------------+-------+-----------+
Issues Found (N):
[ranked by token savings]
Top 3 Optimizations:
1. [action] -> save ~X,XXX tokens
2. [action] -> save ~X,XXX tokens
3. [action] -> save ~X,XXX tokens
Use the report to answer:
| Question | Threshold | Action |
|---|---|---|
| Are skills loading bodies into base context? | Skills total >10K tokens | Strongly consider two-layer skill injection |
| Are MCP servers dominating overhead? | MCP >50% of total | Audit for CLI-replaceable servers (gh, git wrappers) |
| Is CLAUDE.md too long? | >300 lines | Move repeating rules into scoped .claude/rules/*.md files |
| Are agent descriptions bloated? | >30 words in any agent | Tighten frontmatter — descriptions are loaded into every Task spawn |
| Are individual files heavy? | Skill >400 lines, Agent >200, Rule >100 | Split or reference an external doc |
After the first run on a clean session, record numbers in docs/context-budget-baseline.md. Re-run after any harness change to detect creep.
The scanner uses simple heuristics:
words × 1.3chars / 4~500 tokens per declared tool, fixed estimate~200 tokens per server (config + metadata)These match Anthropic's published rough tokenizer behavior to within ~10%. Good enough for budget decisions; not exact.
| Path | What it represents |
|---|---|
CLAUDE.md | Always loaded into every session |
.claude/agents/*.md | Agent descriptions loaded with every Task tool spawn (full body loaded only when invoked) |
.claude/skills/*/SKILL.md | Skills (loaded names; bodies on demand if Claude Code skill cache is two-layer — verify this!) |
.claude/rules/*.md | Scoped rules; loaded conditionally based on file glob, but counted as worst-case |
.claude/hooks/*.sh | Hook scripts — not loaded into context, but counted to surface candidates for consolidation |
.mcp.json | MCP server count + estimated tool count overhead |
Trimming the eager surface is the structural lever; these per-session knobs reduce live cost (sourced from affaan-m/ECC's token-optimization guidance, 2026-05-29 — adopted as tips, not enforced). All numeric values below are [HEURISTIC] estimates — re-verify against the current model/MCP limits, do not treat as exact:
MAX_THINKING_TOKENS (default ~32k) to ~10k for routine work — large savings on hidden reasoning cost. Raise it deliberately for genuinely hard reasoning..mcp.json / settings rather than carrying all of them./compact once a plan is finalized (clearing exploration context) rather than waiting for the auto-compact threshold. The suggest-compact hook already nudges this.These are illustrative ratios, not current counts (the inventory drifts fast — as of 2026-05-28 it was ~32 skills, 5 agents, 15 rules, 18 hook scripts, 5 MCP servers). Always run scan.sh for the live numbers; do not trust hardcoded counts in this doc:
scan.sh for the current size.harness-facts.md, only skill descriptions load at startup; bodies load lazily (only the invoked skill's body enters context). So ~32 skills cost ~32 descriptions eagerly, not 32 full bodies — the per-body line count matters only when a skill is actually invoked.If MCP dominates and CLAUDE.md is large, the highest-leverage trim is usually MCP server pruning, not skill refactoring.
This skill is adapted for TAOM's layout (skills-as-directories, .mcp.json at project root). The token estimates are conservative — actual context cost varies by Claude Code version, MCP transport overhead, and tokenizer revision. Treat numbers as ordinal (which is biggest) not cardinal (exact byte count).