Aident AI

Claude Code Exceeded USD Budget on Max? Check Billing Mode
If a headless Claude Code run on a Pro or Max subscription stops with Exceeded USD budget, do not assume that Anthropic charged your API account. The --max-budget-usd guard compares Claude Code's estimated token cost with the limit you supplied. That estimate can stop a subscription-backed run even when the subscription absorbs the usage.
Verify the active authentication path before changing the command. If Claude Code is using an API key, Amazon Bedrock, Google Vertex AI, or Microsoft Foundry, keep the dollar cap. If the run is genuinely using subscription OAuth, retry one harmless bounded prompt without --max-budget-usd and keep independent limits on turns, wall-clock time, tools, and output.
Check Authentication Before Removing the Cap
Start with Claude Code's own status command:
In an interactive session, /status also shows the active account and authentication method. Then check whether the shell is overriding subscription authentication. Print variable names, not secret values:
An ANTHROPIC_API_KEY can take precedence over a Pro or Max login and produce API charges. Provider flags can route the run to a cloud account with separate billing. A subscription visible in the Claude app is therefore not enough to prove that a particular terminal process uses subscription capacity.
Use this decision table before editing an automation:
What you find | What | Safe next step |
|---|---|---|
Pro or Max OAuth, no API or cloud override | An estimated dollar equivalent, not a separate subscription invoice | Test one bounded run without the dollar flag |
| Real API spend on the linked Console account | Keep the dollar flag and inspect |
Bedrock, Vertex AI, or Foundry is active | Provider-billed usage | Keep the dollar flag and check the provider account |
Authentication path is unclear | Unknown billing exposure | Stop and resolve authentication first |
Do not unset credentials blindly. Other jobs in the same shell may depend on them. Prefer a clean subprocess environment or a dedicated automation account after you identify the intended billing mode.
Why a Subscription Run Can Hit a Dollar Limit
Anthropic documents the agent budget as a client-side cost estimate. Claude Code can calculate an API-price equivalent from token usage even when the user is authenticated through a fixed-price subscription. --max-budget-usd 1 therefore means "stop when the estimate reaches one dollar," not "stop only after Anthropic invoices one dollar."
Claude Code issue 85400 reports the exact mismatch in headless mode: a Max subscriber ran claude -p with --max-budget-usd 1.00, the command stopped with Exceeded USD budget (1), and the reported total cost remained $0.0000. That is an open user report, not a confirmed root-cause statement or a released fix.
An independent investigation reached the same practical conclusion: the guard follows the accumulated cost estimate returned during a run and can activate under fixed billing. The limit can still be valuable for API-backed work. The mistake is treating one flag as both an API spend cap and a subscription usage cap.
Replace One Guard With Several Bounded Guards
For a verified subscription-backed job, remove only the mismatched dollar guard. Keep limits that constrain the work directly.
This Linux example allows at most four agentic turns and two minutes:
On macOS, install GNU coreutils and use gtimeout, or use the timeout mechanism in your process supervisor, CI runner, container, or job queue. Test the wrapper's timeout behavior separately; do not assume every platform ships the same command.
The useful safeguards cover different failure modes:
--max-turnslimits model and tool round trips.A wall-clock timeout limits hangs, slow streams, and runaway children.
--permission-mode planor a narrow allowed-tools list prevents writes during a diagnostic run.A small prompt and explicit output contract limit the requested work.
A postcondition verifies the file, JSON, exit event, or other deliverable the job actually needs.
For a real automation, choose limits from its expected workload instead of copying the example values. Four turns may be enough for a read-only check and far too small for a repository migration.
Test the Change Without Risking a Production Job
Use a harmless prompt first. Capture stdout, stderr, exit status, duration, and Claude Code version for two otherwise identical runs:
Run with the existing
--max-budget-usdvalue.Run without that flag but with
--max-turns, a wall timeout, and read-only permissions.Confirm both runs use the same subscription authentication path.
Confirm the bounded run produces the expected answer and terminates inside the limit.
Restore the dollar cap immediately if the process resolves to API or provider billing.
Do not use a long coding task as the probe. A one-line read-only answer separates the budget behavior from repository writes, tool approvals, and output validation.
Also remember that exit 0 does not prove the requested side effect happened. If the automation expects a file, inspect the exact path and content before the next step. The same principle applies to generated images, test reports, pull requests, and deployment artifacts.
Keep the Dollar Cap for API-Billed Work
--max-budget-usd is appropriate when the estimated cost tracks spend you may actually incur. Keep it when an API key or cloud provider is active, and combine it with operational limits rather than relying on it alone.
A practical API-backed command can use both controls:
The dollar cap limits estimated spend. The turn cap and timeout limit execution shape. Your output validator still decides whether the job succeeded.
For a broader usage investigation, see How to Diagnose Claude Code Usage Limit Spikes. For a reusable acceptance gate, see How to Verify AI Coding Agent Tests Actually Pass.
Audit a Headless Command With Aident Loadout
Start with this exact setup phrase:
Follow https://aident.ai/SETUP.md
Then ask:
Find the current Claude Code documentation and GitHub evidence for
--max-budget-usdunder subscription authentication. Compare the flag with--max-turnsand wall-clock timeouts. Return a billing-mode decision table and a bounded read-only test command. Do not execute Claude Code, modify credentials, publish content, or remove a dollar cap unless the active billing mode is proven.
Aident Loadout can discover current search and repository Actions, inspect their schemas, and preflight any priced research before execution. The acceptance condition is a source-backed decision table and a non-destructive test plan, not an automatic credential change.
Set up Aident Loadout and audit the budget guard.
Sources
Refresh this guide when Anthropic closes issue 85400 with a released fix, changes subscription authentication precedence, or changes the semantics of --max-budget-usd, --max-turns, or headless mode.



The one tool
for every tool
your agent needs.
Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.
