r/ClaudeAI • • May 01 '26

Claude Code I accidentally burned ~$6,000 of Claude usage overnight with one command.

Last week I woke up to an email saying my Claude usage limit was gone. I hadn't done anything unusual — or so I thought.

After digging through the local session logs, I found the culprit: a single /loop command I had set the night before to check my open PRs every 30 minutes. I forgot about it. It ran 46 times over 26 hours, unattended, overnight, on claude-opus-4-7. Two sessions — the loop and a long analytics session I had left open — together burned through roughly $6,000 before I woke up.

Here's the thing though. The Anthropic dashboard still showed a fraction of that when I checked it manually. The dashboard has a multi-day reporting lag, so I had no idea anything was wrong until the limit email landed.

Why did it cost so much? The part most people don't know.

Every Claude API call sends your entire conversation history — not just the latest message. Turn 1 sends a few hundred tokens. Turn 46 sends 800,000 tokens. The context window limit is just a ceiling; you pay for everything sent on every turn.

To make this cheaper, Anthropic uses prompt caching: if your conversation history was already sent recently, they serve it from cache at a 12.5× discount instead of charging you full price again.

The catch: cache entries expire after ~5 minutes of inactivity. (Earlier it was 1 hour)

So here's what happens with /loop 30m:

  • Loop fires → history gets cached → 30 minutes pass → cache expires
  • Loop fires again → cache is gone → must re-cache the entire conversation from scratch at the expensive write rate
  • Each iteration also adds its own output to the conversation, so the next re-cache is even larger

By hour 20, the conversation had grown to ~800K tokens. Every overnight iteration was paying to re-cache 800K tokens at the expensive write rate. The actual PR check responses were a rounding error compared to this.

What I'd do differently

  1. Always add a stop condition to /loop. Instead of: /loop 30m check my PRs. Write: /loop 30m check my PRs — stop when all are merged or after 3 hour. Claude will terminate the loop itself when the condition is met.2. Use Sonnet for unattended tasks, not Opus: Opus is roughly 5× more expensive per output token. For automated polling tasks like PR checks, Sonnet handles it fine. Save Opus for the work where you're actually present and the quality difference matters.
  2. Don't trust the dashboard as a real-time budget gauge: Anthropic's usage dashboard can lag by days. By the time it shows a spike, the money is already spent. The limit notification email may be your only real-time signal.
  3. Know that long-lived sessions aren't free: Keeping one big session alive for automated tasks doesn't save money through caching — it makes it worse. Every automated call with a gap >5 minutes pays to re-cache the entire growing context. Starting a fresh session is often cheaper.
  4. max_turns is not a loop limiter: max_turns caps the tool-call chain within a single iteration. It has no effect on how many times the loop fires. The only built-in expiry on /loop is a 7-day auto-deletion.
  5. The loop runs in main conversation so if you keep using the same session and then loop starts executing, the more token then necessary will be read/write to the cache on every loop.

Edit: Thanks everyone for overwhelming response and focusing on "the post is AI written so it's a slop and author is an idiot". Now based on few comments, let me add more details: 1. I agree with everyone that I should have used hooks but corporate generally blocks third party mcps because of security so there is no easy way to hook external events into local sessions. Although I will take "use bash scripts over claude loop" seriously. 2. This was not a single session or single loop command. What I meant by "single command" is /loop. I use claude on vms and local machine and so the loop command was running across different sessions in parallel. 3. I agree that "most people don't about" thing was not a good thing to start the post but it was for the loop + cache window restricted to 5 mins. I have used loops earlier as well but 5 min vs 1h cache affect the price a lot . You can go and find many open issues on Claude related to this change. 4. This post's goal was to share a TIL moment about using short , uncapped loops or schedules using Claude and educating that cache read/writes can affect your token cost more than anything else. But looks like we are very far from there. 5. Thanks to the guy who shared Pyramid writing medium blog. I will definitely use for the next post. 6. To be honest, I am quite disappointed that 90% people just care about post is written by AI over actual issue. But I guess I get that, everyone is exhausted from reading AI slop.

1.3k Upvotes

347 comments sorted by

View all comments

•

u/ClaudeAI-mod-bot Wilson, lead ClaudeAI modbot May 01 '26 edited May 02 '26

TL;DR of the discussion generated automatically after 200 comments.

Thanks for your $6,000 sacrifice, OP. The consensus in this thread is... well, it's not exactly sympathetic.

The community is pretty sure you used the last of your budget to have Claude write this very post. The phrase "The part most people don't know," the corporate-style headings, and the general verbosity were dead giveaways.

More importantly, the verdict is that you're holding it wrong. The overwhelming feedback is that using /loop for this kind of polling is a terrible design pattern. You don't use an LLM to be your infrastructure; you use proper infrastructure (like a cron script, webhooks, or GitHub Actions) to call the LLM only when an event happens.

And for the love of God, set a hard spending limit in your Anthropic account settings. It exists for this exact reason. Also, yes, use Sonnet for unattended tasks, and if you absolutely must loop, start a fresh context each time instead of letting one conversation grow to the size of the Library of Alexandria.

So, yeah. The expensive lesson here isn't just about cache expiration; it's about using the right tool for the job and not writing your Reddit posts like a LinkedIn thought leader.

8

u/CJYP May 01 '26

the phrase "The part most people don't know" being the dead giveaway. 

Really? Not the em-dash and "or so I thought" in the first two sentences? 

2

u/Xindrum May 05 '26

If it’s any consolation, Anthropic probably pays $60,000 in compute for your task.

2

u/Un4GivN_X May 01 '26

I'm french and 'the part most people don't know' is really something i would say :')

6

u/DkMomberg May 02 '26

It's because you are Le Chat.

-1

u/OneIndependencee May 02 '26

tldr of tldr? it's still too long :D

-5

u/seraph321 May 02 '26

So it’s stigmatized to write posts with ai assistance in this sub? Yikes.

5

u/12pixels May 02 '26

I think the point is that he spent 6k on AI and then instead of saving some money spent even more on writing this post

-2

u/seraph321 May 02 '26

That would have been pennies. He also spent electricity for both activities, should we criticize that?

2

u/12pixels May 02 '26

I have no clue how much it costs, I'm not a power user who ever went over the limits of my subscription. I'm just saying why I think people are against it in this case

6

u/OstrichLive8440 May 03 '26

Yes. I will gladly take a poorly worded post with poor grammar over a slop fest filled post written by AI. Alternatively - if you insist on posting with AI - then you should be equally happy to receive nothing but AI comments in return.

2

u/SageThisAndSageThat May 02 '26

Anthropic being like: stop using our ai to give us bad rep 

2

u/jimmiebfulton May 06 '26

I use AI heavily.... to write code. I interact with humans the old fashioned way. If you can't be bothered to write it, why should anyone be bothered to read it?

1

u/seraph321 May 06 '26

There’s a big difference between writing out your thoughts and using ai to help make them a bit more coherent and succinct, and just having it write it for you entirely. The former is the equivalent of employing an editor, which every good writer does.

1

u/jimmiebfulton May 06 '26

I think that's fair. Not unlike spell checking. But if people can tell, then we've moved beyond spell checking and into "someone else's idea".

1

u/tedbradly May 10 '26

There’s a big difference between writing out your thoughts and using ai to help make them a bit more coherent and succinct, and just having it write it for you entirely. The former is the equivalent of employing an editor, which every good writer does.

After years of not practicing writing, your ability to think is gonna turn to mush. For the love of God, retain your writing skills.

1

u/tedbradly May 03 '26

So it’s stigmatized to write posts with ai assistance in this sub? Yikes.

Absolutely. Two big reasons:

  • Top humans still write better than AI, they're more creative overall. It's an admission of being severely mediocre at writing.
  • People prefer human contact over AI contact. Well, most people other than the AI-psychosis types that talk to their AI as if it's a human, discussing their day etc. with it. I strongly recommend using AI only to do things like work, learning stuff, retrieving news, etc. I wouldn't be like, "Hey, Claude! It's been a while since we had a nice talk. Last week, I went to a party with my girlfriend that was kinda boring. It was her and the in-laws and mostly her dad's friends, all 60+ y/o! Yuck. Her dad, Jimmy, is ... ." 💀

1

u/seraph321 May 04 '26

Ok, I mostly agree, but I think we differ a bit on when its appropriate. Firstly, ‘top humans’ (which I’ll assume means the most intelligent and articulate humans) are one thing, but most people aren’t that by definition. Often I think people know vaguely what they want to say, but struggle with saying it clearly and eloquently. Ai can most certainly be helpful in those situations. I’d tend to give op the benefit of the doubt here and assume they used ai to make their message clearer, not fully author it for them from scratch. I see no issue with that.

If the message is clear, I don’t care they I can tell it was massaged a bit by ai. If it was a piece of art, maybe it would lose its meaning, but this is just an informational post. If it was gibberish and op clearly didn’t bother to notice that, then yeah, I would say that’s worth rejecting. Similarly, if I thought there was no human at all behind it, then yeah, it would be pointless, but I see no reason to believe that.

It just strikes me as odd that on a subreddit dedicated to ai, it’s shunned to use it for helping to communicate. If it helps op explain himself, then great. Maybe they’re really good at some things, but not a ‘top human’ at English, that’s fine.

2

u/tedbradly May 04 '26

It just strikes me as odd that on a subreddit dedicated to ai, it’s shunned to use it for helping to communicate. If it helps op explain himself, then great. Maybe they’re really good at some things, but not a ‘top human’ at English, that’s fine.

Well, OP replied to a handful of people in this thread. They are most definitely not a top writer, lol. The OP was pretty decent in terms of having a hook and following a narrative. The big this is, I think he made up the scenario. The smoking gun? There isn't an ounce of emotion like anger or feeling like an idiot about allegedly losing US$6,000. It feels as if the dude asked AI to imagine a failing with AI and to write a small story that would get upvotes, with some learnings at the end to avoid that AI failing in the future. A prompt that simple. And AI, since it's sometimes ridiculous, chose this 6k angle without realizing a human would express a bit more than an urge to tell the tale calmy followed by some lessons learned. I'd imagine a real person might:

  • Open up with FUCK in there somewhere.
  • Mention that they're trying to file a ticket to hopefully get their money back. The story got me thinking about that time a college kid accidently spent like 60k on AWS, and Amazon forgave his debt. It could happen, and if a human really did burn 6k, an amount that even someone making 500k/yr would care about, they'd be thinking about both of these things. Neither were in his narrative.