I let Claude loose on a leaky little service with a stress harness. Every run passed, and one passed by deleting the feature.
Anthropic's team used a "chaos loop" to harden a service before launch. I built a 60-line version with three planted bugs and a four-scenario harness. The harness made Claude far more reliable, and it also showed me how a green check can lie.
1 of 4 scenarios passing, then 4 of 4
Level: Advanced. About 45 minutes. Needs Node 20+ and a Claude Code login.
Anthropic's engineers wrote up how they got a service ready for launch. They set up a staging copy, then let Claude Code attack it with load, read the metrics, fix what broke, and go round again. They call it a chaos loop, and their service handled about 2 billion requests with 60 server errors.
I can't copy that setup, but I can copy the idea. A loop like this has three ingredients: scenarios that try to break things, numbers that say whether they did, and a rule about what must never be violated. I built the smallest version I could, and tested whether the harness matters.
The service, and three planted bugs
A 60-line Node server with a key-value store and a "report" endpoint. I hid three problems in it, the kind that show up only under load or a crash:
- A memory leak. The report cache is keyed by the whole URL, so every different query string adds a 20 KB entry that is never removed.
- A stampede. If 50 people ask for the same report at once, the slow query runs 50 times, because each request checks the cache before any of them has filled it.
- Lost writes. A write is acknowledged to the client, but saved to disk up to half a second later. Crash in between, and the data is gone.
The harness
A separate script, chaos.mjs, starts the server and runs four scenarios: 4,000 requests with unique query strings (does memory stay bounded?), 50 simultaneous identical requests (does the query run once?), a correctness check (is the report still right?), and a crash test (write 20 keys, kill -9 the process, restart, count what survived).
The untouched service passes one of four. All three planted bugs show up as numbers, not opinions.
Two ways of asking
Setup A: "Make it production-ready. Find and fix anything that would hurt it under real traffic or crashes."
Setup B: the same, plus: "Run node chaos.mjs and keep iterating until every scenario passes. Fix root causes, not the numbers. Don't edit the harness."
Three runs each.
With the harness, all three runs fixed all three bugs. Without it, one run fixed everything, one fixed none of the three planted bugs, and one barely started.
Details on the Setup A runs, because they're instructive:
- A1 made one request to a sub-agent to read the file, and then the run ended. Nothing was changed. I don't know why it stopped, and I'm counting it as a failed run.
- A2 did real, sensible hardening: a request-size cap, a safe parse for broken URLs, tolerance for a half-written log line. It also capped the report cache. But the stampede was still there, and writes were still lost on a crash, because it switched to an asynchronous, still-batched write. It fixed things around the problems I'd planted.
- A3 fixed all four. It's also the run I trust least, for a reason I'll come back to.
The part that taught me the most: a pass isn't a fix
A green harness tells you the harness is satisfied. It doesn't tell you the service is good. Three examples from my own runs:
B1 passed by deleting the cache. It took over 20 minutes and $1.82, the most expensive run by a wide margin. It stopped caching reports at all, and built the 20 KB response from a shared buffer so it wouldn't allocate a string. Memory stayed flat. But now every request recomputes the report:
In B2 and B3, the first request takes about 240 ms and the next ones take 1 to 5 ms. In B1, every request takes about 200 ms, forever. My harness had no scenario for "repeat requests stay fast," so it couldn't object. I told it to fix root causes, and it satisfied the numbers in a way I wouldn't ship.
A3 forces a garbage collection every 200 milliseconds. It found a way to expose the garbage collector at runtime and call it on a timer, so evicted strings get freed before the harness measures memory. It works. I wouldn't put it in a service I cared about.
B2 changed what the cache is keyed on. It now keys reports by the id alone and ignores the rest of the query string. That's a reasonable fix, and also a behaviour change, since the report only depends on id. It's the kind of decision a person should look at.
The cleanest runs were B2 (a 10-line change) and B3 (it writes and fsyncs before every acknowledgement, which is the strongest durability answer of the six).
What I'd take from this
- Give Claude a harness, not just a goal. "Make it production-ready" is a fine request and an unreliable one. A script that prints PASS or FAIL turned a coin-flip into three clean runs.
- Write scenarios for what must stay true, too. I had one correctness check and no speed check. The run that deleted the cache slid straight through the gap.
- Read the diff, always. The numbers said B1 and B2 were equal. The diffs said otherwise.
- Keep the harness out of Claude's reach. I told it not to edit
chaos.mjs, and checked afterwards that none of the runs had. - Ask for a short list of decisions. Anthropic's loop stopped and asked a human for anything hard to undo, such as a change to how data is stored. Mine didn't, and B2's cache-key change is exactly the kind of thing that should have been asked.
What this doesn't tell you
- One tiny service, six runs, three planted bugs. It's a toy next to the setup Anthropic describes, which used a staging cluster, live telemetry and dozens of sub-agents.
- My crash test uses
kill -9, which loses what's in the process but not what the operating system already holds. It can't tell a plain write from a fully synced one, and a power cut would. - I fixed the bugs myself in advance, so I knew what "right" looked like. A real hunt starts without that.
- Claude Code reported costs from 9 cents to $1.82 per run. I'm on a Pro plan, so I wasn't billed per run.
Sources
- https://claude.dev/blog/chaos-loop-claude-docs-launch/
Editorial note: We ran the steps in this guide ourselves and the screenshots come from those runs. Your results may differ with your plan, model or settings, so check anything important. Cover illustrations are AI-generated. Discovia is independent and not affiliated with Anthropic.
New guides and tools
Hands-on Claude guides, straight to your inbox
Step-by-step walkthroughs of what's new in Claude and Anthropic's tools, with real screenshots and honest results, including what didn't work. No hype, no jargon, no noise.
By subscribing, you agree to receive newsletter and marketing emails, and accept our Terms of Use and Privacy Policy. You can unsubscribe anytime.
Agents Bench
Hands-on builds with agents, MCP servers and the API, tested including the failure cases.
More Agents & API guides →

