context-budget
Audit context window consumption across DOTS 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 DOTS agents, skills, rules, MCP servers, and CLAUDE.md. Report token estimates, flag bloat, recommend trims.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Author a culture's armor items and swap troop equipment rosters via the generator + validation pipeline. Use when adding/revamping armor. Enforces the canonical-folder + cover-attribute rules.
Give DOTS lords lore-driven skill values and traits via the DOTS SkillSet system. Use when a canonical lord has wrong stats or a culture roster needs a balance pass.
Author or revamp a DOTS culture's armor set, troop tree, and recruitment wiring end-to-end. Use for new cultures or troop-tree revamps. Follows docs/ai-includes/new-culture-authoring.md.
Use when reviewing an external repo or article to adopt practices into DOTS — security-vet first, map novel vs duplicative, port (never install), review, commit your changes.
Structured 4-phase self-debug for failing agent runs (looping, drifting, burning tokens). Capture, diagnose, contained recovery, report. Complements /investigate (which is for code bugs); this skill is for harness/agent failures.
Incrementally fix dotnet build errors with minimal diffs, one error at a time
| name | context-budget |
| description | Audit context window consumption across DOTS 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 DOTS'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:
DOTS 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 DOTS'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).