How a /loop Command Burned $6,000 in Claude API Overnight

✍️ OpenClawRadar📅 Published: May 1, 2026🔗 Source
How a /loop Command Burned $6,000 in Claude API Overnight
Ad

A Reddit user reported waking up to find their Claude usage limit exhausted after a single /loop 30m check my PRs command ran 46 times over 26 hours unattended on claude-opus-4-7, burning roughly $6,000. The root cause: prompt caching behavior combined with a long-lived session.

Here's the technical breakdown:

  • Context window grows on every iteration: Each API call sends the entire conversation history. Turn 1 might be a few hundred tokens; turn 46 sends 800K tokens. You pay for everything sent on each turn.
  • Prompt caching expires after ~5 minutes: Anthropic caches conversation history at a 12.5× discount if reused within the cache window. But with /loop 30m, the 30-minute gap exceeds the 5-minute cache TTL. Each iteration pays the expensive write rate to re-cache the entire growing context from scratch.
  • Output adds to context: Each loop iteration appends its output to the conversation, making the next re-cache even larger. By hour 20, the session hit ~800K tokens.
  • Dashboard lag hides the damage: The Anthropic usage dashboard has a multi-day reporting delay. The only real-time signal was the limit notification email — by then the money was already spent.

The user's key recommendations to avoid this:

  1. Add a stop condition: Instead of bare /loop 30m check my PRs, write /loop 30m check my PRs — stop when all are merged or after 3 hours. Claude terminates the loop when the condition is met.
  2. Use Sonnet for unattended tasks: Opus is ~5× more expensive per output token. For polling tasks like PR checks, Sonnet is sufficient. Reserve Opus for sessions where you're present.
  3. Don't trust the dashboard: It lags by days. Rely on usage limit emails for real-time billing signals.
  4. Fresh sessions are cheaper: Long-lived sessions compound costs because every call with a gap >5 minutes pays to re-cache the full context. Starting a new session resets the context and avoids this.
  5. max_turns is not a loop limiter: It caps tool-call chains within a single iteration, not how many times the loop fires. The only built-in expiry on /loop is a 7-day auto-deletion.

The loop runs in the main conversation, so if you keep the same session active, each loop execution reads and writes far more tokens than necessary — amplifying costs exponentially.

Ad

If you automate Claude with /loop, always set a stop condition, use a cheaper model, and monitor with external tools. The cache discount only helps when calls are frequent enough to stay within the TTL.

📖 Read the full source: r/ClaudeAI

Ad

👀 See Also