Guide · December 2026

Stop Claude Code from running up your bill overnight

You leave Claude Code on a long job and come back to a big usage number instead of a finished branch. Which official caps actually stop a run (--max-turns, --max-budget-usd, workspace limits), what they can't tell you, and how to notice a runaway before morning.

Lidnight stops runaway spend, silent approval stalls, and unexpected limit hits while you step away. Track Claude Code, Codex, Antigravity, Gemini and Kiro sessions, limits and cost, approve from your phone, and keep going with the lid closed.

Download freePro trial included · no card · Apple Silicon, macOS 13+

Homebrew: brew install whereisdw/tap/lidnight

Why it happens

A runaway is rarely one big mistake. It's repetition that nobody is watching. One report describes about $9,364 going out over six days because nothing stopped a loop in unattended runs (#107256); another describes turns that kept coming with no prompt, taking the 5-hour limit from 28% to 52% in about two hours (#108536).

First, know which kind of session you are running

Headless (claude -p) runs have two real stops. --max-turns N limits agentic turns, and --max-budget-usd X ends the run once estimated spend reaches that amount. The official CLI reference marks both as print mode only, and without either one a run continues until it finishes or you stop it.

Interactive sessions can't use either flag. You rely on your plan's usage limits, or on Console workspace spend limits for API accounts.

claude -p "Migrate the test suite to vitest and keep tests green" \
  --max-turns 60 \
  --max-budget-usd 5.00

The budget flag is an estimate, not a bill

Per the docs, --max-budget-usd is checked against Claude Code's client-side cost estimate, which can differ from your bill. Subagent spend counts toward it, but spend can pass the cap, so the docs say to leave headroom. When you return with --continue or --resume, totals from earlier runs don't count. Set it below the amount that would hurt, and add --max-turns so a cheap but endless loop also ends. The $5.00 above is a placeholder.

Account-level limits are the real backstop

API organizations manage Claude Code spend through Console workspaces, where you can set workspace spend limits. A flag protects one run; a workspace limit protects you from the run you forgot to put a flag on. If you use the Claude apps gateway, it can enforce daily, weekly or monthly caps per user, group or organization, and returns a 429 error on requests after a cap is passed.

What caps don't tell you

A cap ends a run. It doesn't tell you a run is going badly before it ends, and it doesn't help with an interactive session that can't take a flag, a retry loop that wastes the whole night well under your cap, or a run that hit the cap at 2 a.m. and sat idle until morning because nothing told you. Cheap habits that cover these gaps:

1. Check /usage before you leave so you know your starting point. 2. Use claude -p with both flags for anything unattended, and keep interactive sessions for work you watch. 3. Have a run tell you when it ends. A Stop hook, or a short wrapper that messages your phone when claude -p exits (finished or capped), turns silence into information (Claude Code notifications). 4. Check the first fifteen minutes. Most runaways show early: the same file edited over and over, the same command failing (detecting loops).

With Lidnight

Lidnight doesn't replace caps. Leave ending a run to the flags and workspace limits above; Lidnight tells you what happens in between. While you're away, it alerts you when a session's token rate over the last 30 minutes passes 3× the 14-day session median (once it has 14 days of history and at least 5 session samples, and at most once per session every 2 hours). It also alerts you when the same test or build keeps failing with the same error, and the service map shows runaway token use or repeated actions in red, where you can stop the session right there. Your 5-hour and weekly limits and a run-out estimate sit in the menu bar, and when you're back the report shows the tokens used. Costs are estimated at API prices, so they differ from a subscription bill. Mac notifications are free; phone alerts and drain warnings are Pro. Lidnight never ends a session on its own.

Checked 2026-11-28 against Claude Code's official docs (CLI reference, Manage costs, Hooks) and the Claude apps gateway spend-limit docs. Flags change often; check the docs.

Try Lidnight free

Apple Silicon Macs · macOS 13 or later. Every download includes a free trial of everything in Pro (14 days or 5 lid-closed runs of 10+ minutes, whichever comes first), no payment details needed. Pro is a one-time payment (1 Mac $9.99 · 3 Macs $14.99) with a 14-day refund.

Download freeBuy Pro ›More about Lidnight ›

Homebrew: brew install whereisdw/tap/lidnight