Skip to content
Back to skills

Context Budget

ASecurity

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.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 15, 2026
ai-agentsgobashnodegitapi

Works with

  • cursor
  • cli
  • api

Security analysis

A100/100

Scanned November 23, 2026

npx -y skills add Naeha-S/ctxcap --skill context-budget --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Context Budget?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Context Budget
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/naeha-s-context-budget/badge)](https://www.skillsdirectory.com/skills/naeha-s-context-budget)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: context-budget
description: 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.
argument-hint: '[budget]'
---

# 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

```bash
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

```bash
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.