context-budget

Reviewed at commit 9519cda

Measures a Claude Code session's fixed startup context payload per item at a pinned binary version, including per-tool attribution of the built-in tool pools…

What we checked

Shows a live breakdown of what fills your context window in a pane or above the prompt, and asks you first whenever Claude edits a Claude Code settings file. Its audit skill starts short headless Claude Code sessions to measure what each built-in tool costs at startup and keeps a ledger in the plugin's data folder; project settings are changed only through its fix option after you approve.

Review details

Static review of the source at the pinned commit; not run. The register.tsx module hooks session.start, session.end and prompt.submit only to register the /context-budget command (it does not read prompt text), handles command.run for /context-budget live [pane|band|off], refreshes on session.measure through $.session.usage({ breakdown: 'summary' }) only while the pane or band is shown, and draws through ui.render (Pane and AbovePrompt) with $.ui.open/close/panes/toast and plugin-state atoms; nothing is written to the transcript. Shell hooks: a SessionStart command runs the bundled prerequisites.sh or prerequisites.ps1 (PowerShell with -ExecutionPolicy Bypass on its own script) in node-notice mode, which only checks that node is on PATH, shows a notice if not and creates a once-per-session latch directory in the temp folder; a PreToolUse hook on Write|Edit|NotebookEdit runs settings-write-ask.mjs, which reads the target path, runs git rev-parse to find the main checkout root, and returns permissionDecision ask (never allow) for user, project, local or managed settings files; it fails open on errors and has a userConfig kill switch. The audit skill (no pre-approved tools, so Claude asks before each Bash call) runs skills/audit/scripts/measure.mjs, which spawns the claude binary on PATH (or --binary) as claude -p /context, once per denied tool with --disallowedTools and without permission bypass, or uses the Agent SDK query() with maxTurns 1 when @anthropic-ai/claude-agent-sdk resolves from the plugin data folder or, as a fallback, from the current project's node_modules; reads the claude binary to grep for setting names; and writes snapshot, attribution, ledger and report JSON/Markdown under ${CLAUDE_PLUGIN_DATA}/audit/<state-key>/ (state-key.sh derives the key from the git remote and root with path-injection guards). The fix path edits project .claude/settings(.local).json one approved lever at a time and only prints user-global edits. The SDK npm install is printed for the user, never run; the setup skill pre-approves only Bash(node --version*) and Bash(claude --version*). Claude may fetch the cited docs pages on code.claude.com when re-verifying levers. No network calls in code. Read fully: manifests, hooks.json, register.tsx, parts.tsx, types, both prerequisites scripts, settings-write-ask.mjs, measure.mjs, state-key.sh, levers.test.sh and the audit, check and setup SKILL.md files. By targeted search: measure.test.sh (developer test, not loaded at runtime), the reference JSON/Markdown and evals, and lib/prerequisites.mjs from the clone (only reached by prerequisites.sh check mode, which no hook or skill uses; it probes with spawnSync and writes a marker file, no network). Not reviewed: the Agent SDK and the Claude Code binary it measures.

What it uses
  • Reads your prompts: no
  • Sees tool calls: yes
  • Blocks or changes tool calls: yes
  • Reads or writes files: yes
  • Runs programs on your machine: yes
  • Calls the model (uses tokens): no
  • Sends data over the network: no
  • Stores data: yes
  • Shows something on screen: yes
Hooked events

Measures a Claude Code session's fixed startup context payload per item at a pinned binary version, including per-tool attribution of the built-in tool pools that /context reports only as totals, derived by A/B deny differencing. Falls back from an SDK meter to a headless /context parser, then to an error rather than a wrong number. Keeps a before/after ledger per lever. Shows a live context breakdown in a pane or above the prompt. Report-only by default; fix applies one approved project trim.

Made this mod? Add a badge to your README

modsforClaude badge for context-budget

Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.

[![Listed on modsforClaude](https://modsforclaude.com/badge/context-budget.svg)](https://modsforclaude.com/mods/context-budget/)

← All mods