context-budget
Skill1 starsChanged 2 months agoMITView on GitHub
Audit Claude Code context window consumption across skills, rules, agents, hooks, CLAUDE.md, and MCP servers. Reports token overhead and prioritized savings. Use this skill when: asked about context usage; asked to audit skill/rule/MCP bloat; after adding multiple skills or rules; before adding more components.
54 other projects use a version of this.
Adopted by
Most recently taken up by
- Rojios/everything-claude-codetheir own version, first seen Nov 8, 2026
- cveralyon/axel-setuptheir own version, first seen Nov 8, 2026
- ahmadvahidi/skill-atlastheir own version, first seen Nov 8, 2026
- zedarvates/frugal-skillstheir own version, first seen Nov 8, 2026
- pankaj-mahaur/Agent-Daemontheir own version, first seen Nov 6, 2026
- coco-research/cocotheir own version, first seen Nov 1, 2026
Used with
Projects with it also use agent-payment-x402, openclaw-persona-forge and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
TironFoxSkillagent-payment-x402
Add x402 payment execution to AI agents — per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents need to pay for APIs, services, or other agents.
Also in 6 projects that use this
TironFoxSkillopenclaw-persona-forge
为 OpenClaw AI Agent 锻造完整的龙虾灵魂方案。根据用户偏好或随机抽卡, 输出身份定位、灵魂描述(SOUL.md)、角色化底线规则、名字和头像生图提示词。 如当前环境提供已审核的生图 skill,可自动生成统一风格头像图片。 当用户需要创建、设计或定制 OpenClaw 龙虾灵魂时使用。 不适用于:微调已有 SOUL.md、非 OpenClaw 平台的角色设计、纯工具型无性格 Agent。 触发词:龙虾灵魂、虾魂、OpenClaw 灵魂、养虾灵魂、龙虾角色、龙虾定位、 龙虾剧本杀角色、龙虾游戏角色、龙虾 NPC、龙虾性格、龙虾背景故事、 lobster soul、lobster character、抽卡、随机龙虾、龙虾 SOUL、gacha。
Also in 5 projects that use this
loulanyueSkillnuxt4-patterns
Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.
Also in 9 projects that use this
renepfSkillorch-pipeline
Shared orchestration engine for the orch-* skill family. Defines the gated Research-Plan-TDD-Review-Commit pipeline, the size classifier, the agent map, and the two human gates that the orch-* operation skills delegate to. Not usually invoked directly.
Also in 4 projects that use this
Exploration-labsSkilltoken-budget-advisor
Proactive token budget assessment and task chunking strategy. Use this skill when queries involve multiple large file uploads, requests for comprehensive multi-document analysis, complex multi-step workflows with heavy research (10+ tool calls), phrases like "complete analysis", "full audit", "thorough review", "deep dive", or tasks combining extensive research with large output artifacts. This skill helps assess token consumption risk early and recommend chunking strategies before beginning work.
Also in 11 projects that use this
loulanyueSkillsanta-method
Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.
Also in 8 projects that use this
Other versions54 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 54
- misskey-dev/misskey★ 11ksame name
- poshan0126/dotclaude★ 871same name
- coco-research/coco★ 797same name
- OneWave-AI/claude-skills★ 378same name
- loulanyue/awesome-claude-notes★ 272same name
- Fmarzochi/EGC★ 61same name
- felvieira/claude-skills-fv★ 27same name
- Fadi88/one-man-startup★ 16same name
- tellmefrankie/ai-investment-skills★ 14same name
- woxiangyangzhimao/skills★ 14same name
44 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository10 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- global/CLAUDE.mdCLAUDE.md
- agent-reviewSkill
- exploreSkill
- pr-createSkill
- retrospectSkill
- security-scanSkill
- simplifySkill
- test-genSkill
- triangulateSkill
The file
Files
Context Budget Skill
Audits the token overhead of every component loaded into a Claude Code session and reports prioritized savings.
Inventory is deterministic (pure shell, zero Claude tokens). Claude is only used for classification and the final recommendation synthesis.
Step 1: Inventory (Shell Only, Zero Claude Tokens)
Scan every component directory and emit raw counts. Always check user-level (~/.claude/) and project-level (./.claude/ if present). Missing directories are fine — skip silently.
# Token estimation helper — words × 1.3 for prose, chars / 4 for JSON/code
est_tokens() {
local f="$1"
local words chars
read -r words < <(wc -w < "$f")
read -r chars < <(wc -c < "$f")
# pick the larger of the two estimates
local w=$(( words * 13 / 10 ))
local c=$(( chars / 4 ))
echo $(( w > c ? w : c ))
}
scan_dir() {
local label="$1" pattern="$2"
shift 2
local total=0 count=0
for root in "$@"; do
[ -d "$root" ] || continue
while IFS= read -r -d '' f; do
local t
t=$(est_tokens "$f")
total=$(( total + t ))
count=$(( count + 1 ))
echo "$label | $t | $(wc -l < "$f") | $f"
done < <(find "$root" -type f -name "$pattern" -print0)
done
echo "TOTAL | $label | count=$count tokens=$total"
}
echo "=== Agents ==="
scan_dir agents '*.md' ~/.claude/agents ./.claude/agents
echo "=== Skills ==="
scan_dir skills 'SKILL.md' ~/.claude/skills ./.claude/skills
echo "=== Rules ==="
scan_dir rules '*.md' ~/.claude/rules ./rules ./.claude/rules
echo "=== CLAUDE.md chain ==="
for f in ~/.claude/CLAUDE.md ./CLAUDE.md; do
[ -f "$f" ] || continue
echo "CLAUDE.md | $(est_tokens "$f") | $(wc -l < "$f") | $f"
doneStep 2: MCP Inventory (Shell Only)
MCP tool schemas are a major context driver (~500 tokens per tool). Detect configured servers from every source Claude Code reads.
Tool Search caveat. When the harness defers tool definitions (only
name+descriptionload up front; the JSON schema loads on demand at first call), the ~500 tokens/tool figure is an upper bound, not the steady-state cost. With deferral active, the always-loaded cost per tool is just its name+description; only schemas of tools actually invoked in the session add their full weight. Report MCP overhead as a range — name+description floor vs. all-schemas-loaded ceiling — rather than assuming every schema is resident.
# Project-level .mcp.json
for f in ./.mcp.json ~/.claude/mcp.json; do
[ -f "$f" ] || continue
echo "=== MCP config: $f ==="
# Show server names and tool counts if jq is available
if command -v jq >/dev/null; then
jq -r '.mcpServers // {} | keys[]' "$f" 2>/dev/null
else
grep -E '^\s*"[^"]+"\s*:\s*\{' "$f" | head -20
fi
done
# Claude CLI-registered servers (authoritative if present)
if command -v claude >/dev/null; then
claude mcp list 2>/dev/null || true
fiFor each connected server, record the number of tools it exposes. If the server is not currently connected (e.g. Ollama is down), note it as "inactive" rather than counting tools as zero.
Step 3: Hooks Note (Not Context Overhead)
Hooks in ~/.claude/hooks/ do not load into the prompt. They execute out-of-band. Report their count for completeness but do not include their tokens in the overhead total.
ls ~/.claude/hooks/*.sh 2>/dev/null | wc -lStep 4: Classification
For each component surfaced by Step 1, place it in one of three buckets using the criteria below. Use the component's description frontmatter when present — that is the only part guaranteed to load into every Task tool invocation.
| Bucket | Criteria | Action |
| Always needed | Referenced by CLAUDE.md, backs a slash command in active use, or matches the current project's language/framework | Keep |
| Sometimes needed | Domain-specific (e.g. language rules for a language not in this project), not referenced anywhere | Consider on-demand activation — move under a directory that is not auto-loaded, or gate behind a command |
| Rarely needed | No reference from CLAUDE.md or commands, overlapping content with another component, or no plausible use in this project | Remove or lazy-load |
Step 5: Detect Bloat Patterns
Flag each of the following if present:
- Bloated descriptions — any frontmatter
descriptionlonger than 30 words. Descriptions load into every Task invocation, so verbosity compounds. - Heavy skill files —
SKILL.mdover 400 lines. - Heavy agents — agent
*.mdover 200 lines. - Heavy rule files — single rule file over 100 lines (split into smaller overlays).
- Redundant components — skills that duplicate an agent's role, rule files that restate CLAUDE.md, agent descriptions that restate their own system prompt.
- MCP oversubscription — more than 10 active servers, or any server that wraps a CLI tool already allowed in
settings.json(e.g. agit/gh/npmMCP is pure overhead when those commands are in the allow list). - CLAUDE.md bloat — combined CLAUDE.md chain over 300 lines; extract detailed guidance into
rules/instead.
Step 6: Report
Emit the report in Japanese (per Language Policy). Use this shape:
Context Budget Report
=====================
推定オーバーヘッド合計: 約 XX,XXX tokens
コンテキストウィンドウ: {{context_window}}
実効残量: 約 XXX,XXX tokens (XX%) ← {{context_window}} が不明なら省略
内訳:
| Component | Count | Tokens |
|------------|-------|---------|
| Agents | N | ~X,XXX |
| Skills | N | ~X,XXX |
| Rules | N | ~X,XXX |
| MCP tools | N | ~XX,XXX |
| CLAUDE.md | N | ~X,XXX |
検出された問題 (N 件):
[savings 降順]
Top 3 最適化:
1. [action] → 約 X,XXX tokens 削減
2. [action] → 約 X,XXX tokens 削減
3. [action] → 約 X,XXX tokens 削減
潜在削減量: 約 XX,XXX tokens (現オーバーヘッドの XX%)Replace {{context_window}} with the running session's own window. Opus 4.6+, Sonnet 4.6+, Fable 5, and Mythos 5 are 1M; Sonnet 4.5 and earlier, and Haiku, are 200K — so the tier alone does not tell you, and neither does the model family. Nothing in the shell can report it either: settings.json carries no model key. It comes from your session context, not a command. When you cannot establish it, write 不明 and omit the 実効残量 line rather than dividing by a guessed denominator: that percentage is the number the user acts on.
Verbose mode (--verbose or "詳細" requested): additionally print the per-file table from Step 1, the full MCP tool list with per-tool schema size estimates, and side-by-side overlap between redundant components.
Best Practices
- MCP is the biggest lever — each tool schema costs ~500 tokens. A 30-tool server alone exceeds most skill collections. With Tool Search deferral active (see Step 2), that ~500/tool is a ceiling, not the resident cost — but a large server still inflates the name+description floor that always loads, so trimming unused servers still pays off.
- Agent descriptions always load — even agents never invoked in a session contribute their description to every Task call.
- Hooks are free — they execute but do not consume context. Prefer hooks over skills when the work is deterministic shell logic.
- Audit after each additive change — run this skill after adding a skill, rule, agent, or MCP server to catch creep early.
- The window is not usable space — reserve at least 40% for conversation and tool output. Overhead above 30% of the window starts degrading quality.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

