Install any skill in seconds. Free to start, no credit card required.
Get Started Free →エージェント、スキル、MCPサーバー、ルールにわたってClaude Codeのコンテキストウィンドウ消費を監査します。肥大化、冗長なコンポーネントを特定し、優先順位付けされたトークン節約の推奨事項を生成します。
.claude/skills/affaan-m-context-budget/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 49% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 3% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 101% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 4% | 0% |
| case-11 | ✗→✓ | ▲ Improved | -1% | 0% |
分析 Claude Code 会话中每个已加载组件的令牌开销,并提供可操作的优化建议以回收上下文空间。
/context-budget 命令(本技能为其提供支持)扫描所有组件目录并估算令牌消耗:
代理 (agents/*.md)
description 前言长度技能 (skills/*/SKILL.md)
.agents/skills/ 中的重复副本 — 跳过相同副本以避免重复计数规则 (rules/**/*.md)
MCP 服务器 (.mcp.json 或活动的 MCP 配置)
gh, git, npm, supabase, vercel)CLAUDE.md(项目级 + 用户级)
将每个组件归入一个类别:
| 类别 | 标准 | 操作 | |--------|----------|--------| | 始终需要 | 在 CLAUDE.md 中被引用,支持活动命令,或匹配当前项目类型 | 保留 | | 有时需要 | 特定领域(例如语言模式),未在 CLAUDE.md 中引用 | 考虑按需激活 | | 很少需要 | 无命令引用,内容重叠,或无明显的项目匹配 | 移除或延迟加载 |
识别以下问题模式:
生成上下文预算报告:
上下文预算报告
═══════════════════════════════════════
总预估开销:约 XX,XXX 个词元
上下文模型:Claude Sonnet (200K 窗口)
有效可用上下文:约 XXX,XXX 个词元 (XX%)
组件细分:
┌─────────────────┬────────┬───────────┐
│ 组件 │ 数量 │ 词元数 │
├─────────────────┼────────┼───────────┤
│ Agents │ N │ ~X,XXX │
│ Skills │ N │ ~X,XXX │
│ Rules │ N │ ~X,XXX │
│ MCP tools │ N │ ~XX,XXX │
│ CLAUDE.md │ N │ ~X,XXX │
└─────────────────┴────────┴───────────┘
WARNING: 发现的问题 (N):
[按可节省词元数排序]
前 3 项优化建议:
1. [action] → 节省约 X,XXX 个词元
2. [action] → 节省约 X,XXX 个词元
3. [action] → 节省约 X,XXX 个词元
潜在节省空间:约 XX,XXX 个词元 (占当前开销的 XX%)在详细模式下,额外输出每个文件的令牌计数、最繁重文件的行级细分、重叠组件之间的具体冗余行,以及 MCP 工具列表和每个工具模式大小的估算。
基本审计
/context-budget
技能:扫描设置 → 16个代理(12,400个令牌),28个技能(6,200),87个MCP工具(43,500),2个CLAUDE.md(1,200)
标记:3个重型代理,14个MCP服务器(3个可替换为CLI)
最高节省:移除3个MCP服务器 → -27,500个令牌(减少47%开销)详细模式
/context-budget --verbose
技能:完整报告 + 按文件细目显示 planner.md(213 行,1,840 个令牌),
MCP 工具列表及每个工具的大小,重复规则行并排显示扩容前检查
User: 我想再添加5个MCP服务器,有空间吗?
Skill: 当前开销33% → 添加5个服务器(约50个工具)会增加约25,000个tokens → 开销将升至45%
建议:先移除2个可用CLI替代的服务器以保持在40%以下words × 1.3,对代码密集型文件使用 chars / 4| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 21,117 | 3,857 | -82% | 1 | 1 | 0% | 3,523 | 1,852 | -47% | 0 | 0 | — |
case-02 | fail→fail | 17,170 | 3,897 | -77% | 1 | 1 | 0% | 2,538 | 1,842 | -27% | 0 | 0 | — |
case-03 | fail→fail | 18,418 | 6,762 | -63% | 1 | 1 | 0% | 3,208 | 1,982 | -38% | 0 | 0 | — |
case-04 | fail→pass | 12,335 | 9,896 | -20% | 1 | 1 | 0% | 2,117 | 3,148 | +49% | 0 | 0 | — |
case-05 | pass→pass | 10,709 | 2,736 | -74% | 1 | 1 | 0% | 2,004 | 1,878 | -6% | 0 | 0 | — |
case-06 | fail→pass | 10,192 | 2,154 | -79% | 1 | 1 | 0% | 1,763 | 1,818 | +3% | 0 | 0 | — |
case-07 | pass→pass | 11,546 | 2,613 | -77% | 1 | 1 | 0% | 1,785 | 1,828 | +2% | 0 | 0 | — |
case-12 | fail→pass | 6,277 | 2,595 | -59% | 1 | 1 | 0% | 892 | 1,792 | +101% | 0 | 0 | — |
case-08 | pass→pass | 13,535 | 7,551 | -44% | 1 | 1 | 0% | 2,332 | 2,887 | +24% | 0 | 0 | — |
case-09 | pass→pass | 13,265 | 4,492 | -66% | 1 | 1 | 0% | 2,164 | 2,177 | +1% | 0 | 0 | — |
case-10 | fail→pass | 13,396 | 4,893 | -63% | 1 | 1 | 0% | 2,159 | 2,235 | +4% | 0 | 0 | — |
case-11 | fail→pass | 14,191 | 3,592 | -75% | 1 | 1 | 0% | 1,978 | 1,949 | -1% | 0 | 0 | — |
case-13 | pass→pass | 11,501 | 6,048 | -47% | 1 | 1 | 0% | 1,788 | 2,366 | +32% | 0 | 0 | — |
case-14 | fail→pass | 9,149 | 2,861 | -69% | 1 | 1 | 0% | 1,418 | 1,853 | +31% | 0 | 0 | — |
case-15 | pass→pass | 10,955 | 3,680 | -66% | 1 | 1 | 0% | 1,658 | 1,976 | +19% | 0 | 0 | — |
case-16 | fail→pass | 7,947 | 2,013 | -75% | 1 | 1 | 0% | 1,261 | 1,793 | +42% | 0 | 0 | — |
case-17 | fail→pass | 10,248 | 4,566 | -55% | 1 | 1 | 0% | 1,628 | 2,154 | +32% | 0 | 0 | — |
case-18 | pass→pass | 16,928 | 10,829 | -36% | 1 | 1 | 0% | 2,963 | 3,415 | +15% | 0 | 0 | — |
case-19 | pass→pass | 16,793 | 14,078 | -16% | 1 | 1 | 0% | 3,141 | 4,162 | +33% | 0 | 0 | — |
case-20 | pass→pass | 12,197 | 8,275 | -32% | 1 | 1 | 0% | 2,092 | 2,908 | +39% | 0 | 0 | — |
case-21 | fail→pass | 9,930 | 3,060 | -69% | 1 | 1 | 0% | 1,581 | 1,917 | +21% | 0 | 0 | — |
case-22 | fail→pass | 10,309 | 5,683 | -45% | 1 | 1 | 0% | 1,640 | 2,405 | +47% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +45 percentage points is the difference between those two pass rates over the 21 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.