See Scope Atlas on your own project. Get a walkthrough →
← BlogCloud runs

How to stop an AI coding agent from burning through your budget overnight

An unattended agent fails expensively. A loop at 2 a.m. keeps billing until something stops it. Put a hard limit at every level: the run, the queue, and the account. Then make the tasks small enough that it rarely matters.

Short answer: Put a hard stop at three levels. Cap each run, in dollars or time. Cap the queue, in tasks, dollars or minutes, and stop it at the first failure. Cap the account, with a spend limit at your provider or a subscription that has usage limits built in. In Claude Code's headless mode the per-run cap is --max-budget-usd. In Scope Atlas every queue takes a budget, each cloud run stops at two hours, and runs stop when the month's run hours are used.

How an overnight run gets expensive

It's rarely one big mistake. It's a small one, repeated:

  • A test fails, the agent changes something, the test fails differently, and it keeps going.
  • The task was vague, so the agent keeps finding more to do. "Add a login page" turns into OAuth, roles and a session store.
  • Every retry rereads the same large files, and you pay for the reading every time.
  • One task fails and the next five start anyway, built on top of the broken one.

You can't fix this by watching. The point of running overnight is that you aren't watching. So the limits have to be mechanical.

Level 1: cap each run

Give every run a ceiling it can't negotiate with.

  • Claude Code, headless: claude -p "…" --max-budget-usd 5 stops spending at $5. It only works in print mode, which is the mode you use for unattended runs anyway.
  • A clock: wrap the run in a timeout, so a run that's stuck but cheap still ends.
  • Scope Atlas cloud runs stop at two hours each, so one stuck task can't spend the night.

Level 2: cap the queue

Most overnight damage happens between runs, when the next task starts on top of a failed one.

  • Stop at the first failure. A failed run should pause everything after it.
  • Budget the whole queue, not just each task.
  • Gate the risky tasks. Some tasks should wait for a human, like a migration or anything touching billing.

In Scope Atlas you queue a module and the tasks run in dependency order. You set a budget in tasks, dollars or minutes, and the queue stops when it's hit. A failed run pauses the queue instead of burning the rest. Any task can require your approval before it starts, or you let the queue run to the cap. In your editor, the Autopilot skill runs the same loop through MCP, with the plan as its only state.

Level 3: cap the account

The last line of defense is the bill itself.

  • On a subscription (a Claude or ChatGPT plan), the plan's usage limits cap the damage. The agent stops when you hit them.
  • On API keys, nothing stops by default. Set a monthly spend limit in your provider's console and turn off automatic credit top-ups for keys your agents use.
  • In Scope Atlas, cloud runs draw on run hours: 30 a month on Builder, 30 per person on Team. When they're used, runs wait for the next month or you add 20 hours for $10. Runs never bill past the hours you have. The model bill stays on your own subscription or keys; we don't resell the model.

The real fix: smaller tasks

Limits stop the damage. They don't stop the cause. Agents run long when they don't know when they're done.

A task sized for one session, with acceptance criteria that say what done looks like, gives the agent a place to stop. "Add a login page" has no edge. "Email and password login form, posts to /api/login, shows the server's error message, no OAuth" does. That's most of what planning a feature before an agent touches code is about.

Small tasks, clear criteria, and hard caps at three levels. Then leaving it running overnight is a decision you can make calmly.