budget

budget is a command for Claude Code from egorfedorov/claude-context-optimizer. It costs 0 tokens per session (892 once invoked), scanned A, original, MIT.

A manager for the amount of text an AI coding session can keep in its working context. It shows or changes the token limit, warning points, automatic compaction point, and fallback model used for cost estimates.

In plain words
What is it for?
Use it to inspect the current budget, set a token limit, or choose the fallback model used when estimating session costs.
Why use it?
It helps prevent a session from running out of context and makes the chosen budget and warnings visible. Automatic compaction shortens older context so more room is available for new work.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: reads .claude/ paths; positional $N argument; mentions Claude Code.

Part of the context-optimizer plugin — 6 skills, 23 commands, 3 agents, 6 hooks shipped together

Good fit Use it to inspect the current budget, set a token limit, or choose the fallback model used when estimating session costs.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/egorfedorov/claude-context-optimizer/budget
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/egorfedorov/claude-context-optimizer

Made for: Claude Code.

Or install context-optimizer, the plugin that ships this one along with the rest of its 6 skills, 23 commands, 3 agents, 6 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for budget

README.md
[![agentmods](https://agentmods.dev/badge/commands/egorfedorov/claude-context-optimizer/budget/github.svg)](https://agentmods.dev/commands/egorfedorov/claude-context-optimizer/budget)
Your own site
<a href="https://agentmods.dev/commands/egorfedorov/claude-context-optimizer/budget"><img src="https://agentmods.dev/badge/commands/egorfedorov/claude-context-optimizer/budget/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for budget

Your own site · 80×15
<a href="https://agentmods.dev/commands/egorfedorov/claude-context-optimizer/budget"><img src="https://agentmods.dev/badge/commands/egorfedorov/claude-context-optimizer/budget.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 892 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00892
Opus 5.5 $0.00000 $0.00357
Sonnet 5.5 $0.00000 $0.00178
Haiku 4.5 $0.00000 $0.00089

Measured today against content hash 04f8ddee9d66, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

budget scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/cco/commands/budget.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context Budget Manager

Manage the token budget for Claude Code sessions. Model-aware — picks the right effective context window and prices per model. The session's REAL model is read from the transcript by the budget hook; config.model is only the fallback. Everything from Sonnet 4.6 up is 1M; Haiku 4.5 is 200K.

Parse :

status (or no arguments)

Show current budget config + auto-compact settings: Read ~/.claude-context-optimizer/config.json and ~/.claude-context-optimizer/budget-config.json (either may be missing). If no config exists, show defaults (200K working budget on a 1M window, opus-5.5 fallback model, warn at 50/70/85/95%).

set <tokens>

Update the budget limit. Parse the token count (200K, 1M, 500000 all OK). Update ~/.claude-context-optimizer/config.json (the user approves the write):

{
  "budgetTokens": <parsed_number>,
  "warnAt": [50, 70, 85, 95],
  "autoCompactAt": 90,
  "model": "opus-5.5"
}

If budgetTokens exceeds the chosen model's context window, warn the user.

model <name>

Set the FALLBACK model for cost estimation (used only when a session's transcript has no model id yet). Supported keys:

  • haiku-4.5 (alias haiku) — $1/$5 per M, 200K
  • sonnet-4.6 (alias sonnet) — $3/$15 per M, 1M
  • sonnet-5 — $2/$10 per M, 1M
  • sonnet-5.5 — $2/$10 per M, 1M
  • opus-4.7 / opus-4.8 — $5/$25 per M, 1M
  • opus-5 (alias opus) — $5/$25 per M, 1M
  • opus-5.5 (default) — $4/$20 per M, 1M, cache reads at 0.05×
  • fable-5 — $10/$50 per M, 1M
  • fable-5.1 (alias fable) — $10/$50 per M, 1M, cache reads at 0.025× (vs 0.1× elsewhere)

opus-4.8-1m / opus-4.7-1m / opus-extended are back-compat aliases only — there is no 1M surcharge; the 1M window is standard at $5/$25.

Update the model field in config.json. When switching to a 1M-context model and the current budgetTokens is below 500K, ask if the user wants to bump it to 1M.

auto <on|off>

Toggle auto-compact at thresholds (80% / 90%). Update ~/.claude-context-optimizer/budget-config.json:

  • auto on → autoCompactEnabled: true
  • auto off → autoCompactEnabled: false

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 74 lines · 0 tokens per session scan A 04f8ddee9d66

Subscribe to this mod's changes

budget is a command published in the GitHub repository egorfedorov/claude-context-optimizer (116 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 892 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-18.