budget-check

budget-check is a command for Claude Code from rhan1/crewline. It costs 16 tokens per session (730 once invoked), scanned A, original, MIT.

A command that estimates whether a planned list of coding tasks fits within the remaining five-hour token budget. A token budget is the limited amount of text an AI service can process in a session.

In plain words
What is it for?
It helps classify a plan as fitting, tight, or too large, estimate its token cost, and suggest concrete ways to reduce or split the work.
Why use it?
It warns when a plan may exceed the available session capacity and uses recent usage data rather than stale information.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: reads .claude/ paths; mentions subagents; mentions Codex.

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.

agentmods
npx agentmods add commands/rhan1/crewline/budget-check
Clone the repo
git clone --depth 1 https://github.com/rhan1/crewline

Made for: Claude Code.

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-check

README.md
[![agentmods](https://agentmods.dev/badge/commands/rhan1/crewline/budget-check.svg)](https://agentmods.dev/commands/rhan1/crewline/budget-check)
Your own site
<a href="https://agentmods.dev/commands/rhan1/crewline/budget-check"><img src="https://agentmods.dev/badge/commands/rhan1/crewline/budget-check.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 730 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00016 $0.00730
Opus 5 $0.00008 $0.00365
Sonnet 5 $0.00003 $0.00146
Haiku 4.5 $0.00002 $0.00073

Measured 5d ago against content hash 95ca80525bb8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

budget-check 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 5d ago.

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.

commands/budget-check.md · 67 lines

How it starts

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

Before executing a planned task list, estimate whether it will fit in the remaining 5h window. Report fits/tight/won't-fit with concrete options.

Task

$ARGUMENTS

Procedure

1. Read current session state

Read ~/.claude/.session-state.json — the statusline writes this every ~10s. You want:

  • rate_limits.five_hour.used_percentage — how much of the 5h window is used
  • rate_limits.five_hour.resets_at — Unix epoch of next reset
  • cost.total_cost_usd — informational

If the cache file is missing or >60s stale (compare timestamp field to current Unix epoch), tell the user and stop — don't proceed with stale data.

2. Determine what to estimate

  • If $ARGUMENTS is an existing file path, read its contents.
  • If $ARGUMENTS starts with / or ~ but the file doesn't exist, stop and ask the user to confirm the path.
  • Otherwise treat the argument as an inline plan description.

3. Estimate plan token cost

Count discrete action steps (bullet points, numbered items, subheaders that imply an action). Classify each:

Step shape Cost
Small edit / single-file change / targeted tool call ~8k tokens
Multi-file change / requires exploration before editing ~20k tokens
Subagent dispatch or complex search/research ~35k tokens
Bash command sequence / verification / smoke test ~5k tokens
External dispatch to Codex/Gemini (Claude pays only for spec+smoke-test) ~5k tokens

Sum steps, then add 30% overhead for turn-to-turn conversation and unexpected tool iterations.

4. Compute fit

  • Assume the 5h window budget is ~2,000,000 tokens (Opus Max approximation; tune later if needed).
  • plan_percent = round((estimate / 2_000_000) * 100)
  • projected_total = current_used_percentage + plan_percent

5. Report one of three verdicts

Format:

<✅/⚠️/❌> <verdict headline>
current 5h: X% · plan est: ~Yk tokens (Z%) · projected total: W%
  • ✅ Fits comfortably — projected total < 80%. Say "go ahead."
  • ⚠️ Tight — 80 ≤ projected < 100%. List 2–3 specific steps that could be dispatched to Codex/Gemini to cut Claude cost.
  • ❌ Won't fit — projected ≥ 100%. Offer three numbered options:
    1. Split: run the first N steps that fit, defer the rest
    2. Wait: reset is at <local HH:MM from resets_at> — suggest /execute-at-reset <plan-path>
    3. Keep planning: refine further; execute later

Read the full file on GitHub · 67 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. 5d ago First seen · 67 lines · 16 tokens per session scan A 95ca80525bb8

Subscribe to this mod's changes

budget-check is a command published in the GitHub repository rhan1/crewline (2 stars, last pushed 12d ago), licensed MIT. It adds 16 tokens to every session and 730 once invoked, about $0.0001 per session on Opus 5. 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-08-31.