Deep dive
Shipping millions of agent-written lines: how Bun's AOT compiler was built and verified with Claude
Jarred Sumner, Bun's creator, now at Anthropic, describes adding an ahead-of-time (AOT) compiler to Bun, the runtime Claude Code runs on, written largely by Claude and rewritten five times in about a month. The talk is about method: how to trust a change too large for anyone to review line by line. Results quoted are the speaker's and were internal at the time of the talk.
"How to Ship Millions of Lines of Agent-Written Code — Jarred Sumner, Anthropic" by AI Engineer — Watch on YouTube → Conference talk; captions spell Claude Code as "Cloud Code".
The method, step by step
- Let verification choose the approach. The team decided not to rewrite Claude Code in Rust because its tests are in TypeScript and would have had to be ported, and rewritten tests can't be trusted. Bun's own Rust rewrite worked because its tests were in a different language from the code, so the same tests ran against both versions. Making JavaScript itself faster kept the existing tests valid.
- Use tests that predate the project. Bun's suite, WebKit's tests, Test262 and other existing suites, plus Bun's test runner running in AOT mode. An agent can't have shaped tests that existed before it started.
- Run differential checks. Run each program three ways (JIT, AOT-compiled, and with types stripped). If all three behave the same, the compiler is right for that program. Then have Claude write code generators to fuzz many patterns, and extend an engine fuzzer (V8's Fuzzilli) to cover TypeScript types.
- Check the tests catch things. It is easy to believe a fuzzer is finding bugs when it isn't.
- Batch the big write, then fix. In the bulk-writing phase, don't build after every change; one version ran about 140 agents writing code at once, then one build. Afterwards, switch to many individual agents fixing, compiling and passing tests.
- Prefer long-lived subagents to scripted workflows. With recent models, long-running subagents keep the relevant code in context and are less wasteful than the earlier Claude Code workflow approach.
- Re-measure continuously. An hourly scorecard posted to Slack compared key metrics with the previous version. Without it, quality drifts.
Try it
bun upgrade --canary
The talk ends by pointing to Bun's canary build to try the AOT compiler with Bun's compile command. bun upgrade --canary is in Bun's documentation; the AOT mode itself was still rolling out, so check Bun's docs for the current flag.
What went wrong along the way
- Version 1 reused as much of JavaScriptCore as possible and made Claude Code a gigabyte.
- Version 2 added a type checker (
bun check) and Claude was told to use it: startup was twice as fast with about a third of the memory, but the code was "slop", for example treating any property calledarchiveas a possible use of the Bun.archive API. - Versions 3 and 4 fixed quality but compiled too slowly (about 50 seconds for Claude Code), which JavaScript developers won't accept.
- Version 5 had good code and builds under 20 seconds, and is the one shipping. The reported result: about 4x less memory and about 2x faster startup for Claude Code, and faster than both JavaScriptCore's and V8's JITs on most of the JetStream 3 benchmark. Code that relies on
evalornew Functionis not faster. - Breaking change: the compiler bans assigning to
Object.prototype, which blocks prototype-pollution attacks and also helps performance.
Gotchas
- Claude "sizes up" an idea and can talk itself out of a good change with bad measurements. Push back with questions like "why are we doing this?" and "what's taking so long?".
- It underestimates what it can do. Without nudging, you get 0.1% improvements instead of 10%.
- It loves writing Markdown design docs; 1,500 of them is not useful.
- For a project that hasn't shipped, rewriting is often easier than refactoring.





