Agent skill

Context Budget

by affaan-m in affaan-m/ECC

审核Claude Code上下文窗口在代理、技能、MCP服务器和规则中的消耗情况。识别膨胀、冗余组件,并提供优先的令牌节省建议。

MITAuto-check passedAgent Workflows

Install Context Budget

skills CLI
$ npx skills add affaan-m/ECC --skill context-budget -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install affaan-m/ECC context-budget --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .claude/skills && cp -r skills-src/docs/zh-CN/skills/context-budget .claude/skills/context-budget && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
context-budget
GitHub stars
277k
Used in
1 other repo
Token cost
~709 tokens
SKILL.md length
148 words
Files
1
Skills in repo
683
Repo updated
First seen
Licence
MIT

At a glance

审核Claude Code上下文窗口在代理、技能、MCP服务器和规则中的消耗情况。识别膨胀、冗余组件,并提供优先的令牌节省建议。

  • Tasks that involve Context engineering
  • SKILL.md covers 使用时机, 工作原理, 示例 and 最佳实践
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Context Budget is an agent skill from affaan-m/ECC. 审核Claude Code上下文窗口在代理、技能、MCP服务器和规则中的消耗情况。识别膨胀、冗余组件,并提供优先的令牌节省建议。

Its SKILL.md is about 710 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows, covering Context engineering. It works with Model Context Protocol. The repository describes itself as: The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond. The licence is MIT.

When your agent uses it

  • Tasks that involve Context engineering

Example prompts

  • “/context-budget”

What it can do on your machine

Read from SKILL.md and the folder at commit 2d515e4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Context Budget loads about 709 tokens when it runs. Until then it costs about 20 tokens; SKILL.md has 148 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~20
When it runs · the whole SKILL.md, loaded when a task matches
~709

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from affaan-m/ECC at commit 2d515e4, republished under its MIT licence (© affaan-m). 148 words, ~709 tokens.

Download SKILL.mdSave it as .claude/skills/context-budget/SKILL.md (or your agent's skills folder).
name
context-budget
description
审核Claude Code上下文窗口在代理、技能、MCP服务器和规则中的消耗情况。识别膨胀、冗余组件,并提供优先的令牌节省建议。
origin
ECC

上下文预算

分析 Claude Code 会话中每个已加载组件的令牌开销,并提供可操作的优化建议以回收上下文空间。

使用时机

  • 会话性能感觉迟缓或输出质量下降
  • 你最近添加了许多技能、代理或 MCP 服务器
  • 你想知道实际有多少上下文余量
  • 计划添加更多组件,需要知道是否有空间
  • 运行 /context-budget 命令(本技能为其提供支持)

工作原理

阶段 1:清单

扫描所有组件目录并估算令牌消耗:

代理 (agents/*.md)

  • 统计每个文件的行数和令牌数(单词数 × 1.3)
  • 提取 description 前言长度
  • 标记:文件 >200 行(繁重),描述 >30 词(臃肿的前言)

技能 (skills/*/SKILL.md)

  • 统计 SKILL.md 的令牌数
  • 标记:文件 >400 行
  • 检查 .agents/skills/ 中的重复副本 — 跳过相同副本以避免重复计数

规则 (rules/**/*.md)

  • 统计每个文件的令牌数
  • 标记:文件 >100 行
  • 检测同一语言模块中规则文件之间的内容重叠

MCP 服务器 (.mcp.json 或活动的 MCP 配置)

  • 统计配置的服务器数量和工具总数
  • 估算模式开销约为每个工具 500 令牌
  • 标记:工具数 >20 的服务器,包装简单 CLI 命令的服务器 (gh, git, npm, supabase, vercel)

CLAUDE.md(项目级 + 用户级)

  • 统计 CLAUDE.md 链中每个文件的令牌数
  • 标记:合并总数 >300 行
阶段 2:分类

将每个组件归入一个类别:

类别标准操作
始终需要在 CLAUDE.md 中被引用,支持活动命令,或匹配当前项目类型保留
有时需要特定领域(例如语言模式),未在 CLAUDE.md 中引用考虑按需激活
很少需要无命令引用,内容重叠,或无明显的项目匹配移除或延迟加载
阶段 3:检测问题

识别以下问题模式:

  • 臃肿的代理描述 — 前言中描述 >30 词,会在每次任务工具调用时加载
  • 繁重的代理 — 文件 >200 行,每次生成时都会增加任务工具的上下文
  • 冗余组件 — 重复代理逻辑的技能,重复 CLAUDE.md 的规则
  • MCP 超额订阅 — >10 个服务器,或包装了可免费使用的 CLI 工具的服务器
  • CLAUDE.md 臃肿 — 冗长的解释、过时的部分、本应成为规则的指令
阶段 4:报告

生成上下文预算报告:

上下文预算报告
═══════════════════════════════════════

总预估开销:约 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
  • MCP 是最大的杠杆:每个工具模式约消耗 500 令牌;一个 30 个工具的服务器开销超过你所有技能的总和
  • 代理描述始终加载:即使代理从未被调用,其描述字段也存在于每个任务工具上下文中
  • 详细模式用于调试:需要精确定位导致开销的确切文件时使用,而非用于常规审计
  • 变更后审计:添加任何代理、技能或 MCP 服务器后运行,以便及早发现增量

© affaan-m, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in docs/zh-CN/skills/context-budget of affaan-m/ECC.

Open the folder on GitHubat commit 2d515e4

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in affaan-m/ECC, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Context Budget next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Context Budget compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Context Budget this skillaffaan-m/ECC277k1 repos~709Automated safety check: PassMIT
Context Mode Output Sandboxmksglu/context-mode26k—~4.1kAutomated safety check: PassCustom licence
Context Mode for Antigravity CLImksglu/context-mode26k—~850Automated safety check: PassCustom licence
Base HelpChristopherKahler/base292—~2.6kAutomated safety check: PassCustom licence
LemmalogJordyZomer/lemmalog329—~2.8kAutomated safety check: PassMIT
Cortex Mem MCPsopaco/cortex-mem313—~2.8kAutomated safety check: PassMIT

Similar skills

  • Context Mode Output Sandbox

    mksglu/context-mode

    Routes large command, file, API and browser output through context-mode tools so only the needed result enters the agent's context, instead of dumping it via Bash.

    26k GitHub stars~4.1k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Routing rules for using context-mode MCP tools in Antigravity CLI: sandboxed code runs, file analysis, indexed search and web fetches that keep large output out of the conversation.

    26k GitHub stars~850 tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Base Help

    ChristopherKahler/base

    Coach mode for the base CLI: teaches what to do and why, rather than just answering.

    292 GitHub stars~2.6k tokensUpdated 4 days ago
    Agent WorkflowsAuto-check passed
  • Lemmalog

    JordyZomer/lemmalog

    Externalize working memory and logical state into the lemmalog Datalog engine (MCP).

    329 GitHub stars~2.8k tokensUpdated 10 days ago
    Agent WorkflowsAuto-check passed
  • Cortex Mem MCP

    sopaco/cortex-mem

    Persistent memory enhancement for AI agents. An agent skill from sopaco/cortex-mem.

    313 GitHub stars~2.8k tokensUpdated 2 mo ago
    Agent WorkflowsAuto-check passed
  • MCP Code Search Tool Selection

    Context-Engine-AI/Context-Engine

    Rules for choosing Qdrant-Indexer semantic search over grep or file reads when exploring code, debugging or asking where and why questions.

    402 GitHub stars~1.3k tokensUpdated 3 mo ago
    Agent WorkflowsAuto-check passed

More from affaan-m/ECC

All 682 skills in this repo
  • Skill Stocktake

    affaan-m/ECC

    Audits your installed Claude skills and commands for quality, with a quick mode for recently changed skills and a full mode that evaluates all of them through subagents.

    277k GitHub starsUsed in 5 repos~3.1k tokens
    Auto-check passed
  • Ingests, indexes, searches, edits and monitors video, audio and live streams through the VideoDB Python SDK, returning stream links, clips and timestamps.

    277k GitHub starsUsed in 3 repos~3.5k tokens
    Auto-check: notes
  • Docs Governance

    affaan-m/ECC

    Route broad documentation-governance requests to existing ECC skills and run an opt-in, read-only audit of mapped documentation roles, links, ADR indexes, and evidence references.

    277k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Rules Distillation

    affaan-m/ECC

    Scans installed skills for principles that recur across them and proposes rule-file changes: append, revise, add a section, create a file or leave as covered.

    277k GitHub starsUsed in 2 repos~2.3k tokens
    Auto-check passed
  • Builds DRAFT counterparty agreements from one markdown template and a small JSON spec per party, with clauses picked by the party's role.

    277k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Set an ECC-specific frontend design direction for production UI work.

    277k GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed

Categories

Questions about Context Budget

What does Context Budget do?

审核Claude Code上下文窗口在代理、技能、MCP服务器和规则中的消耗情况。识别膨胀、冗余组件,并提供优先的令牌节省建议。. Context Budget is an agent skill from affaan-m/ECC.

When should I use Context Budget?

Context Budget fits situations like: tasks that involve Context engineering.

How do I install Context Budget in Claude Code?

Run `npx skills add affaan-m/ECC --skill context-budget -a claude-code`. Or copy the skill folder (docs/zh-CN/skills/context-budget in affaan-m/ECC) into .claude/skills/context-budget in your project. Claude Code loads it when a task matches its description.

How do I install Context Budget in Codex?

Run `npx skills add affaan-m/ECC --skill context-budget -a codex`. Or copy the skill folder (docs/zh-CN/skills/context-budget in affaan-m/ECC) into .agents/skills/context-budget in your project. Codex loads it when a task matches its description.

Can I use Context Budget in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add affaan-m/ECC --skill context-budget -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/context-budget, .gemini/skills/context-budget, .github/skills/context-budget and .opencode/skills/context-budget in your project.

What does Context Budget need to run?

SKILL.md names no scripts, command-line tools or credentials: Context Budget is instructions for the agent only.

Does Context Budget access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Context Budget safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Context Budget use?

Context Budget is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Context Budget use?

About 709 tokens (SKILL.md is roughly 2.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Context Budget?

Skills that share tags, products or a category with Context Budget: Context Mode Output Sandbox (mksglu/context-mode, 26k stars), Context Mode for Antigravity CLI (mksglu/context-mode, 26k stars), Base Help (ChristopherKahler/base, 292 stars) and Lemmalog (JordyZomer/lemmalog, 329 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Context Budget?

affaan-m (a GitHub user) maintains it in affaan-m/ECC, which has 276,673 GitHub stars. The repository holds 683 skills in this directory. The repository was last updated on October 11, 2026.

Source: affaan-m/ECC on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.