agentleFS
Naeha-SNaeha-S/ctxcap/skills/context-budget/SKILL.md

context-budget

Skill4 starsChanged 9 days agoMITView on GitHub

Measure how many tokens agent context files cost (CLAUDE.md, AGENTS.md, Cursor rules, prompt files), find references in them to files or npm scripts that no longer exist, and plan a trim to a token budget. Use when asked how big these files are, whether they are stale or out of date, or to shrink them. Runs the offline ctxcap CLI with npx.

69 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use orch-pipeline, agent-payment-x402 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.
  • renepfSkill

    orch-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 5 projects that use this

  • TironFoxSkill

    agent-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 8 projects that use this

  • TironFoxSkill

    openclaw-persona-forge

    为 OpenClaw AI Agent 锻造完整的龙虾灵魂方案。根据用户偏好或随机抽卡, 输出身份定位、灵魂描述(SOUL.md)、角色化底线规则、名字和头像生图提示词。 如当前环境提供已审核的生图 skill,可自动生成统一风格头像图片。 当用户需要创建、设计或定制 OpenClaw 龙虾灵魂时使用。 不适用于:微调已有 SOUL.md、非 OpenClaw 平台的角色设计、纯工具型无性格 Agent。 触发词:龙虾灵魂、虾魂、OpenClaw 灵魂、养虾灵魂、龙虾角色、龙虾定位、 龙虾剧本杀角色、龙虾游戏角色、龙虾 NPC、龙虾性格、龙虾背景故事、 lobster soul、lobster character、抽卡、随机龙虾、龙虾 SOUL、gacha。

    Also in 7 projects that use this

  • loulanyueSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 12 projects that use this

  • renepfSkill

    config-gc

    Garbage collection for your Claude Code configuration. Periodically scans ~/.claude (skills, memory, hooks, permissions, MCP servers, caches) for redundant, stale, orphaned, or low-value items, then walks the user through a confirm-each-deletion cleanup. Use when the user says "clean up my config", "config GC", "too many skills", "audit my setup", "my .claude is bloated", or asks for a periodic config review.

    Also in 4 projects that use this

  • Exploration-labsSkill

    token-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 13 projects that use this

  • +2 more from renepf

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 64 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If it moved, fix the reference.

    line 33
  2. Distinctive:

    Only when the user asks to get under a token budget.

    line 39
  3. Very specific:

    If satisfiable is false, report minAchievable and stop.

    line 42
  4. Very specific:

    Verify: npx -y ctxcap --verify <planId>.

    line 47

“Common” is measured: kept by at least 6 in 10 of the 64 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Context budget with ctxcap

ctxcap is an offline CLI. It needs Node 20 or newer and no API key or config. Run it from the repository root. Counts are approximate (o200k_base encoding), so compare changes rather than absolute numbers.

Measure

npx -y ctxcap --json

Report total and each entry in files (path, tokens, delta). delta is the change against ctxcap-baseline.json; without a baseline it is the whole size. Add --compare to place the largest file at a percentile in the Context Budget Index, which is a more useful sentence than a raw count.

Find stale references

npx -y ctxcap --stale --json

Each entry in findings names a dead reference in ref and its place in path, startLine, and endLine. Before you change anything, confirm that the reference is really gone: search for the file or script under a new name. If it moved, fix the reference. Delete the line only when the thing it describes no longer exists. A run with no findings means no path or npm run script failed to resolve; it does not mean the file is current.

Trim to a budget

Only when the user asks to get under a token budget.

  1. Plan: npx -y ctxcap --plan --budget <n>.
  2. If satisfiable is false, report minAchievable and stop.
  3. Edit by startLine/endLine from each plan entry. Never rewrite a context file from memory. Never cut a span listed in preserve; the one exception is a condense entry on that span, where you apply its condensedText exactly as given.
  4. Verify: npx -y ctxcap --verify <planId>. The budget is met only when satisfied is true and violations is empty.
  5. Show the user the git diff and let them decide. Do not commit it for them.

Saved plans are local temporary state and expire after 24 hours; a PLAN_EXPIRED error means you make a new plan. Do not run --apply in CI.

Keep it from growing back

Offer these once, do not set them up unasked:

  • npx -y ctxcap --update-baseline, then commit ctxcap-baseline.json.
  • The GitHub Action Naeha-S/ctxcap@v1 with fail-on: increase, which comments the token change on each pull request.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.