Tools

How to Run Claude Code Unattended Without It Costing a Fortune

Last updated: April 2026

Running Claude Code while you are not watching is the obvious next step once you trust it. It is also where people lose real money. This guide covers the four things that actually matter, each of which the r/ClaudeAI community arrived at independently, and in at least one case at a cost of several thousand dollars.

Quick Answer

To run Claude Code unattended safely you need four things: a hard spending ceiling checked before every run, cron-style scheduling rather than a polling loop, a fresh context per run instead of one conversation that grows forever, and a real command that verifies the work before you accept it. Claude Code now has native scheduled tasks, which covers the scheduling piece; the other three are what a fleet harness like Nightshift adds.

  • Set a hard token or spend ceiling before anything else
  • Schedule with cron semantics, never a polling loop
  • Start a fresh context each run rather than growing one
  • Verify with a command; do not trust the agent's own report

Best For

  • Anyone already paying for Claude Code who is not using it while away from the keyboard
  • Developers who have tried a bash or cron wrapper and hit its limits
  • Teams who want unattended work reviewable as a git diff

Not Ideal For

  • One-off tasks, which are faster to run interactively
  • Work with no command that can verify it
  • Anyone unwilling to set a spending limit first

Can Claude Code already run on a schedule by itself?

It would be dishonest to write this guide without saying so. Anthropic shipped native scheduled tasks for Claude Code, and the r/ClaudeAI thread announcing it drew 1,100+ upvotes and 240+ comments. As the post put it: Claude Code now runs on a schedule, you set it once and it executes automatically, with no prompting and no babysitting.

If all you want is one task on a timer, use that. It is built in and it works.

What native scheduling does not give you is a ceiling on what a run can spend, a check that the work was actually done, several specialised roles rather than one repeated task, or isolation so two runs cannot overwrite each other. Those are the gaps this guide is about.

How do I stop an unattended agent running up a huge bill?

The most-discussed cautionary tale in r/ClaudeAI is a post titled "I accidentally burned ~$6,000 of Claude usage overnight with one command", which drew 1,200+ upvotes and 340+ comments. The figure is one user's self-report rather than a verified invoice, but the mechanism is what matters and it is entirely believable: a loop left running unattended, a context that kept growing, and nobody watching.

After 200+ comments the moderator bot summarised the community's verdict. The first instruction was blunt: "set a hard spending limit in your Anthropic account settings. It exists for this exact reason."

Do that. Then add a second ceiling inside whatever runs your agent, because an account-level limit stops you at the wall rather than stopping the work cleanly. A harness-level budget can decline to start a cycle it cannot afford, which leaves you with completed work and a clear log instead of a run cut in half.

  • Set the account-level spend limit in your Anthropic settings today
  • Add a per-day token ceiling in whatever schedules the work
  • Count retries and repair attempts against that ceiling, not just first attempts
  • Do not count cached input the same as fresh input, or you will stop far short of your real budget

Why is cron better than a polling loop for agent work?

The same community summary was unambiguous about the design error behind that bill. Using a loop for polling was called a terrible design pattern, and the recommendation was direct: use proper infrastructure such as a cron script, webhooks or GitHub Actions to call the model only when something has actually happened.

A loop that wakes, asks the model whether there is anything to do, and goes back to sleep pays for the question every time. A schedule pays only for the work. One top comment in that thread, with 194 upvotes, described exactly the right shape: an old school cron script that invokes Claude every hour to check pull requests.

That comment is essentially a description of Nightshift. The value of a harness over a hand-rolled cron script is not the scheduling, it is everything around it: staggered cadences so two roles never contend for the same rate limit window, catch-up when the machine was asleep, and a restart that does not re-run a window it already finished.

Should each run start a fresh context?

The third piece of the community verdict: if you must loop, start a fresh context each time rather than letting one conversation grow to, in their words, the size of the Library of Alexandria.

This is a cost problem before it is a quality problem. Every turn in a long conversation is re-sent, so an unattended run with one ever-growing context pays more for worse results as the hours pass.

The workable middle ground is a session per role rather than a session per run or one session forever. Each role resumes its own thread so it remembers what it decided last time, but a content role's history never inflates the engineering role's context. Anything that needs to persist longer than a session belongs in a bounded block in CLAUDE.md, not in the conversation.

Which model should I use for unattended work?

Also from the same consensus: use Sonnet for unattended tasks. Unattended work is usually repetitive and well-specified, which is exactly where a cheaper model performs close to a frontier one at a fraction of the cost.

Set the model per role rather than globally. A planning role that decides what matters next earns a stronger model. A role that writes a changelog entry from a diff does not.

How do I know the unattended work was actually done?

A separate r/ClaudeAI thread, with 390+ upvotes and 180+ comments, argues that anyone running Claude Code on larger projects should switch to a CI pipeline immediately. The instinct is right and it generalises: unattended output needs an independent check.

Without one you get the failure mode that plagues hosted autonomous agent platforms, where work is marked complete when it is not. Nobody notices until a customer does.

A gate is just a command that must pass before the work counts. For code that is your test suite. For an article it might be a word count and a check for leftover placeholder text. The full patterns, including gates for work that has no test suite, are in the verification guide below.

What does a safe unattended setup look like?

The four requirements above are the reason Nightshift exists in the shape it does. Every one of them was a community conclusion before it was a feature.

  • Hard ceiling: a daily token limit checked before each cycle starts
  • Cron semantics: staggered cadences per role, with catch-up and no double-firing
  • Fresh context: one session per role, plus a bounded memory block
  • Verification: gates that must pass, with a bounded repair attempt when they fail

Method and limitations

The engagement counts above come from a reddit-mcp query against r/ClaudeAI over the past year, sorted by relevance, and are rounded. They are a snapshot and will move.

Quotes are attributed to the subreddit only, never to usernames or post IDs. The $6,000 figure is a user's self-report and is presented as such rather than as verified spend.

No third-party keyword volume tool was used anywhere in this research, so this page makes no claims about search volume.

FAQ

Can Claude Code run on a schedule by itself?

Yes. Anthropic shipped native scheduled tasks, and for a single recurring task that is the simplest option. What it does not provide is a spending ceiling per run, verification that the work was done, multiple specialised roles, or isolation between parallel runs. Those are the reasons to use a fleet harness on top of it.

How do I stop an unattended agent running up a huge bill?

Two ceilings. Set the hard spend limit in your Anthropic account settings, which is what the r/ClaudeAI community recommends first after a widely-discussed $6,000 overnight mistake. Then add a per-day token ceiling in whatever schedules the work, so it declines to start a cycle it cannot afford rather than being cut off mid-task. Count retries and repair attempts against that ceiling too.

Why is a polling loop worse than cron for unattended agent work?

A loop pays the model to answer "is there anything to do?" on every iteration, whether or not there is. Cron pays only when work is due. The r/ClaudeAI consensus on this was blunt, calling a polling loop a terrible design pattern and recommending cron, webhooks or GitHub Actions instead.

Should I use the same model for unattended work as interactive work?

Usually not. The community recommendation is a cheaper model such as Sonnet for unattended tasks, because they tend to be repetitive and well-specified. Set the model per role so a planning role can use a stronger model while a routine role does not.

Is one long conversation better than many short ones for an overnight run?

No, and it is a cost trap. Every turn of a long conversation is re-sent, so an ever-growing context gets more expensive and less focused as the night goes on. A session per role is the practical middle ground: each role remembers its own history without inflating anyone else's context.

Was this page helpful?

Related help pages

Ready to Build Your Next Big Idea?

Join thousands of founders using BigIdeasDB to discover validated opportunities and build products people actually want.

Get Started Free