Guides · Updated October 19, 2026

How to set a spending limit for Claude Code

Claude Code has several real spend controls, but each one works at a different level: a monthly limit on your account, or a per-run cap for scripted runs. What it does not have is a dollar cap for the interactive session you leave running. This guide covers the built-in options first, by how you pay, and then how to add per-session and daily caps with a hook.

First: how are you paying?

The right control depends on where Claude Code’s usage is billed:

You use Claude Code withThe ceiling you already haveNative limit you can set
An API key / Claude ConsoleNone by default; billed per tokenWorkspace spend limit in the Console
Claude Pro or MaxYour plan’s usage limits (5-hour and weekly)Monthly spend limit on usage credits, or keep usage credits off
Claude Team or EnterpriseEach seat’s allowanceAdmin spend limits on usage credits (organization, group or member)
Amazon Bedrock, Google Cloud or Microsoft FoundryYour cloud accountYour cloud provider’s budget controls

API key users: set a Console workspace spend limit

When you first sign Claude Code in with a Claude Console account, the Console creates a workspace called “Claude Code” that all Claude Code usage is billed to. Set a spend limit on that workspace (see Anthropic’s workspace docs) and Claude Code stops getting responses once the workspace reaches it. You can also set a workspace rate limit there so Claude Code can’t starve your production traffic of rate limit.

This is the right backstop for a monthly budget. It is not a per-session limit: one bad overnight run can still use the whole month’s allowance before it trips.

Pro and Max: decide what happens at your plan limit

On a subscription, your plan’s usage limits are already a hard ceiling. You hit them and you wait for the reset. The only way to spend more money is usage credits (previously called extra usage), which let you keep working past the limit at a cost:

Even with no money at stake, a looping session can burn through your 5-hour or weekly limit and lock you out for days. The per-session cap below helps with that too. For what each limit message means and how to watch your usage, see Claude Code usage limits.

Team and Enterprise: admin spend limits

Each seat’s allowance is the default ceiling. If admins turn on usage credits so members can keep going, they set spend limits at the organization, group or individual member level in the claude.ai admin settings (Organization settings → Usage). Members who hit a limit see a message naming which limit they hit. See Anthropic’s Manage costs page for the full list.

Headless runs: --max-budget-usd

For scripted or CI runs in print mode (claude -p), Claude Code has a real per-run dollar cap:

claude -p --max-budget-usd 5.00 "Fix the failing tests in src/billing"
claude -p --max-budget-usd 5.00 --max-turns 30 "..."   # also cap the number of agentic turns

Once the run’s estimated spend reaches the amount, Claude Code stops it. Subagent spend counts toward the cap, and once the cap is reached Claude Code won’t start new subagents and stops background ones (that part needs v2.1.217 or later). Things to know, from the CLI reference:

For a full CI setup across Claude Code, Codex and Cursor (job timeouts, dedicated keys, GitHub Actions), see setting a hard budget for AI coding agents in CI. The Agent SDK has the same caps as maxBudgetUsd / max_budget_usd and maxTurns / max_turns.

The gap: interactive sessions and daily totals

Put together, the native controls give you a monthly ceiling (Console, usage credits, admin limits) and a per-run cap for claude -p. What is missing is a cap on the long interactive session you start in the morning and leave working, and a daily cap across all your sessions (and other agents). You can see the session’s estimated cost in /usage or in a custom status line, but nothing stops the session when it passes a number.

A prompt like “stop if this costs more than $10” is not a cap; the model can’t see what it costs. The place to enforce it is a PreToolUse hook. Claude Code runs the hook before every tool call, and the hook can deny the call (permissionDecision: "deny") or end the session ({"continue": false}). The hook needs to read the session’s transcript, price the tokens, and compare against your cap.

Per-session and daily caps with LoopGuard

LoopGuard is an open-source (MIT) CLI that installs exactly that hook. It reads Claude Code’s own transcript for the current session, including the subagents/ transcripts next to it, prices it at API list prices, and checks it on every tool call. No proxy and no API key, so it works the same on a subscription.

npm i -g loopguard-cli          # puts `loopguard` on your PATH
loopguard init --agent claude   # adds PreToolUse + Stop hooks to ~/.claude/settings.json (backed up first)

loopguard config set sessionCapUsd 10   # per session (default 25)
loopguard config set dailyCapUsd 40     # per local day, across all guarded agents (default 100)
loopguard status                        # today's spend vs caps, recent trips

Restart running Claude Code sessions so they load the hook. What happens from then on:

For headless runs, use both: --max-budget-usd for the run, and LoopGuard’s daily cap so twenty separate $5 runs can’t add up to $100 without you noticing.

Limits worth knowing

Related

LoopGuard on GitHub · Pricing