Claude Code hard budget cap plus ledger resume: 40 files for $2.24
A per-run dollar cap with a one-line-per-step ledger lets a killed run resume from the first unfinished step; the author likens it to Jev resolving 1,902 forks in code at 0.96 sharpness.
THIS IS A PURE F*CKING GOLDMINE Anthropic just shared one of the best tricks for Claude Code: put a hard dollar cap on the agent and let it resume from a ledger when it hits the wall. 40 files migrated across two runs for $2.24 total, and not a single run was allowed past its own limit. claude -p --max-budget-usd 0.50 "resume from ledger.txt" here's the split: ▸ one step equals one file, and every finished step writes one line into ledger.txt ▸ the budget is checked while the model streams, not after the bill lands ▸ subagent spend counts toward the same cap, so a swarm cannot sneak past it ▸ when the cap hits, the run stops dead and the ledger keeps the progress the part everyone gets wrong: they set a budget and then lose everything when it triggers. cut mid-step and there is no final report, the result comes back null, and an agent with no state on disk starts from zero next time. here the state is a text file. 37 done, 3 left, and the next run reads that line and picks up at step 38. run one spent $2.07 and died at the cap. run two cost $0.17 and finished the last 3 files. same job, no work lost. $0.054 per step, 40 of 40 migrated, exit 0. the cap only works with -p. in an interactive session there is nothing enforcing it. JEV engineering is the same move one layer down: 1,902 forks this run - which file, retry or stop, next or done - resolved in code at 0.96 sharpness, and only the split ones ever cost you a model call the full tree ▸ every long job runs with a hard max-budget flag, never open-ended ▸ one step equals one unit of work, never a batch ▸ each finished step appends a line to a ledger file on disk ▸ a killed run loses the current step only, never the completed ones ▸ the next run reads the ledger and resumes from the first unfinished line ▸ JEV resolves micro-forks in code so the budget goes to real work paste the tree and this prompt into Claude Code ↓ "Rebuild my long-running jobs around this tree: 1. Every batch job runs headless with a hard --max-budget-usd cap, never open-ended. 2. Split the work so one step equals one file or one unit, never a batch. 3. After every finished step, append one line to ledger.txt on disk with what was done. 4. On start, read ledger.txt first and resume from the first unfinished item. 5. Subagent spend counts toward the same cap, and the run stops dead when it is reached. 6. Add one rule to CLAUDE.md: no long job runs without a ledger and a cap. Show me every change as a diff first. No edits until I say go." ↳http://code.claude.com/docs/en/model-config save it, this is the difference between losing a run and pausing one.
This post quotes another post: x.com/sprytixl/status/2107763347097534680