context-budget
Audit context window consumption across LOTRAOM 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 LOTRAOM agents, skills, rules, MCP servers, and CLAUDE.md. Report token estimates, flag bloat, recommend trims.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Hard-block Edit/Write outside a chosen directory. Use to scope-lock edits during a focused fix or refactor. Pair with /unfreeze to release.
Six-phase root-cause debugging for crashes, build failures, or "why is this broken" reports. Iron Law - no fixes without root cause. Auto-engages /freeze.
Release the directory edit lock set by /freeze. Edit and Write are unrestricted again. No-op if /freeze was never set.
Dispatch an independent Codex verification job for the current changes
Inspect all changed files, group by logical concern, and guide atomic per-concern commits
Check mod compatibility against a new Bannerlord version by reviewing patch targets and GameModel overrides
| name | context-budget |
| description | Audit context window consumption across LOTRAOM 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 LOTRAOM's .claude/ setup consumes from the context window before a single user message is processed. Drives every other context optimization decision.
Adapted from affaan-m/everything-claude-code via TAOM 2026-05-17.
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:
LOTRAOM 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 | Verify load semantics; consider trimming |
| 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 | Skill frontmatter eager; body only when invoked |
.claude/rules/*.md | Scoped rules; loaded conditionally based on file glob, counted as worst-case |
.claude/hooks/*.sh | Hook scripts — not loaded into context, but counted to surface candidates for consolidation |
.claude/memory/MEMORY.md | Project-local memory (first ~200 lines / ~25KB whichever binds first) |
.mcp.json | MCP server count + estimated tool count overhead |
.mcp.jsonIf MCP dominates and CLAUDE.md is large, the highest-leverage trim is usually MCP server pruning, not skill refactoring.