How to set a spending limit on Claude Code

A long Claude Code session on a big codebase can cost more than a day of everything else. Here is what you can cap, and where.

Short answer

Claude Code's --max-budget-usd flag caps spend, but only in print mode (claude -p). For interactive sessions, /usage shows an estimated cost, and the Claude Console lets you set a monthly spend limit for a workspace. To stop a single session at a dollar or token limit, add a hook that counts usage and refuses the next prompt and tool call once the limit is reached.

If you use Claude Code with an API key rather than a subscription, you pay for every token. A session that reads a large codebase, retries a failing test many times, or runs in a loop overnight can cost far more than you planned. Claude Code has some controls of its own. This guide sets out what each one covers, and how to put a hard limit on a single session.

What it usually costs

Anthropic's cost page gives an average of around $13 per developer per active day, and under $30 per active day for 90% of users. The spread is wide: the model, the size of the codebase and how long the sessions run all change it. The cases that hurt are the outliers, not the average.

Claude Code's own cost controls

  • --max-budget-usd, for print mode only. When you run Claude Code non-interactively with claude -p, this flag caps the dollars spent on API calls. Claude Code's help says it only works with --print. Expect it to stop at about the amount, not to the cent.
  • /usage, to see it. For API users, its Session block shows an estimated cost at list price. It tells you; it doesn't stop anything.
  • Workspace limits in the Claude Console. You can set a monthly spend limit for a workspace. It covers everything in that workspace for the month.
  • Team and Enterprise plans. Admins can set spend limits for the organization, a group or a single member.

For scripted tasks, use the flag:

# A one-off task, capped at about $5 of API spend
claude -p "fix the failing tests in tests/api" --max-budget-usd 5

The gap: one interactive session

None of the controls above stops a single interactive session at, say, $5. A workspace limit stops everyone at the end of the month's budget, which is too late and too broad for the one session going wrong now. To stop one session, you need something that counts that session's usage as it goes and refuses the next step when it passes the limit. Claude Code's hooks make that possible: a hook runs before every tool call and every prompt, and can refuse it.

Doing it with SteerPlane

SteerPlane's Claude Code hooks count each session's tokens, price them on the server, and refuse the next prompt and tool call once the session or the month passes its limit. Two commands from version 1.2.1:

pip install "steerplane[cli]"
export STEERPLANE_API_URL=http://localhost:8000      # your SteerPlane server
export STEERPLANE_API_KEY=sk_sp_your_steerplane_key  # a key with the limits you want
steerplane claude-code install                       # this project, just you
# --scope project  -> .claude/settings.json, shared with the repo
# --scope user     -> ~/.claude/settings.json, every project

Restart Claude Code afterwards. The limits come from the key:

  • Per session: the key's cost limit per run, set on the dashboard's API Keys page. One Claude Code session is one run.
  • Per month: the key's monthly budget.
  • Tokens: a server-wide token limit per run, STEERPLANE_MAX_TOKENS_PER_RUN.
steerplane keys create --name dev-laptop --max-cost 100   # $100 a month for this key

When a limit is reached, Claude Code is told the prompt or tool call was refused and why. Raise the limit and the same session carries on. Each session shows on the dashboard as a run, with its cost and tokens, and it is marked completed when Claude Code exits. We tested this with real Claude Code on 1 December 2026.

What leaves your machine. The hook reads token counts from the session transcript and sends message ids, model names and token counts. Not your prompts, Claude's replies, your files or tool output.

One thing to know. The hook counts usage after each step, so the step that crosses the limit finishes, and the next one is refused. Set the limit a little below what you can afford. If SteerPlane can't be reached, tool calls are refused rather than let through unchecked.

The same hooks can also refuse risky commands before they run. See how to stop Claude Code from running rm -rf.

A checklist for Claude Code costs

  • Scripted runs use claude -p with --max-budget-usd.
  • Your Console workspace, or your plan, has a monthly spend limit.
  • Long interactive sessions have a limit of their own.
  • You check /usage during long sessions.
  • Each person or project has its own key, so you can see who spent what.

Questions people ask

Does Claude Code have a budget limit?

In print mode, yes: claude -p --max-budget-usd 5 stops at about that amount. Interactive sessions have no per-session dollar flag. Console workspaces and Team or Enterprise plans have monthly spend limits.

How much does Claude Code cost per day?

Anthropic's cost page gives an average of around $13 per developer per active day, and under $30 per active day for 90% of users. It varies a lot with the model and the size of the codebase.

How do I see what a Claude Code session has cost?

Run /usage. For API users its Session block shows an estimated cost at list price.

Shipping agents? Let's talk.

Become a design partner

Our first 10 design partners get every paid feature free.

  • We wire it into one of your agents with you, usually in under an hour.
  • Sign-off requests, alerts and a full record of every run, in your own dashboard.
  • Hosted by us or on your own servers, whichever you prefer.
  • A direct line to the founders, and your requests go to the top of what we build.
  • We ask you to use it on one real agent for 4 weeks and tell us what breaks.