How to Ship Millions of Lines of Agent-Written Code — Jarred Sumner, Anthropic
Bun creator Jarred Sumner explains how agents built an ahead-of-time compiler for Bun through five rewrites in about a month, with verification deciding the approach: test suites that predate the project, identical behavior across JIT, AOT, and type-stripped runs, fuzzing, and hourly metric scorecards. He also covers batch-writing with 140 agents, long-lived subagents, and steering against agents that talk themselves out of ambitious ideas. First-party account; memory, startup, and benchmark figures are unpublished, and the compiler was in internal dogfooding and canary at the time.
Jarred Sumner, the creator of Bun, who says he works at Anthropic, describes how agents built an ahead-of-time (AOT) compiler for Bun, the JavaScript runtime that powers Claude Code. A just-in-time (JIT) compiler compiles JavaScript while the program runs; an AOT compiler does that work before the program starts. Sumner merged the result as a pull request of several million lines after a little more than a month and five rewrites. His main lesson is that the way you verify the code should decide how you build it: the project relied on test suites written before it began, comparisons between JIT and AOT runs of the same program, and fuzzing.
Source basis: This summary uses the video's English auto-generated YouTube captions, with names and obvious caption errors corrected in the transcript (for example Jarred, Claude Code, Test262, Fuzzilli, UglifyJS, and "slop" for "slow"). No translation or original-audio check was performed. This is a first-party account by the project's author. Memory, startup, and benchmark figures are his, given without published methods, and the compiler was in internal dogfooding and a canary build at the time of the talk.
Key points
- The project began as a request to make Claude Code use less memory and start faster. Sumner's opening prompt allowed changes to either WebKit or Bun; Bun runs on JavaScriptCore, WebKit's JavaScript engine. He says the AOT compiler is a larger project than his summer rewrite of Bun in Rust. The compiler went through five rewrites in a little over a month, and he expected the fifth to ship the week after the talk. 00:01–02:42(opens in a new tab)
- Verification shapes the approach. Sumner says a project like this is constrained by how you test that the code works, and that choosing how to build it comes after deciding how to confirm it is not buggy. 01:47–02:42(opens in a new tab)
- Claude Code was not rewritten in Rust because its tests would have had to be rewritten too. Sumner says roughly half the CPU time of a typical JavaScript application goes to compiling code on demand, which is why teams rewrite JavaScript code in Rust or Go. Bun's Zig-to-Rust rewrite was manageable because Bun's tests are written in TypeScript, so the same tests could run against both versions. Claude Code's tests are written in TypeScript, the same language as Claude Code, so a Rust rewrite of Claude Code would have needed a ported test suite. Once the tests are rewritten, he says, you can no longer trust them. The team chose to make JavaScript faster instead. 02:42–05:26(opens in a new tab)
- The checks come mostly from tests the agents did not write. The compiler runs against Bun's existing test suite, WebKit's tests, Test262 (the JavaScript conformance suite), and Claude Code's tests, and Bun's own test runner can run in AOT mode. Sumner stresses that these tests predate the project, so the agent could not have changed them to pass. Most remaining failures come from two deliberate breaking changes. One is a ban on assigning properties to
Object.prototype, which blocks prototype-pollution attacks and also helps performance. 06:22–08:16(opens in a new tab), 16:32–18:11(opens in a new tab), 18:11–19:12(opens in a new tab) - Comparing three builds of the same program turns correctness into a fuzzing problem. An application can run with the JIT, compiled ahead of time, and with its TypeScript types removed. If all three behave the same, the compiler works at least for that application. Claude then wrote code generators to fuzz many code patterns, and the team extended Fuzzilli, the JavaScript-engine fuzzer used by V8, to cover TypeScript types. Sumner adds that you must also check that tests catch real bugs, because it is easy to believe a fuzzer is finding bugs when it is not. 08:16–09:07(opens in a new tab), 17:24–18:11(opens in a new tab)
- TypeScript types are treated as predictions, not facts. Because TypeScript types do not have to be correct, the compiler does not trust them. When it can prove that a value always has the same shape (monomorphic), a property read becomes a direct field access; otherwise it checks the value every time. Sumner says models are good at writing compilers, which made this kind of problem a good fit. 06:22–07:24(opens in a new tab), 15:31–16:32(opens in a new tab)
- The work alternated between a large writing batch and a long fixing phase. In the writing phase, many agents write code at once and the build runs only once, because repeated compiles waste time on build errors. For the third version, 140 agents wrote code at the same time before the team worked to get Claude Code running on the result. In the fixing phase, many individual agents make the code compile, pass tests, and actually work. Sumner says he used to rely on Claude Code workflows, but with recent models he mostly uses long-lived subagents that keep the relevant code in their context window. 09:07–10:49(opens in a new tab), 11:40–13:42(opens in a new tab), 14:44–16:32(opens in a new tab)
- Several versions were thrown away for code quality or build time. The first version reused as much of JavaScriptCore as possible, which capped how good it could be, and Sumner says Claude Code "was a gigabyte," which he calls terrible; the talk does not say whether that was memory or file size. After the team added a TypeScript type checker to Bun, a later version started Claude Code twice as fast and used about a third of the memory, but Sumner calls its code slop. In one example, any object with a property named
archivewas assumed to possibly use theBun.archiveAPI. During planning, agents also wrote about 1,500 Markdown design files, which he calls unreasonable for anyone to read. The fourth version had good code but took 50 seconds to compile Claude Code, too slow for JavaScript developers who expect no compile step. The fifth had good code and builds under 20 seconds. He concludes that for a large project that has not shipped, rewriting is easier than refactoring, and that most of the code volume is tests and the repeated rewrites. 09:07–14:44(opens in a new tab), 21:00–21:51(opens in a new tab) - Agents misjudge ideas and lose track without regular measurement. Claude often sized up an idea and talked itself out of trying it, and Sumner says it is easy to convince yourself that your measurements are good when they are not; he thinks some rejected ideas should be tried again. To keep track, he had an agent post an hourly scorecard in Slack comparing the current and previous values of the metrics the team prioritized. Without constant re-measuring, he says, results drift worse. 13:42–15:31(opens in a new tab), 16:32–17:24(opens in a new tab), 21:00–21:51(opens in a new tab)
- Most of the human work was steering. Sumner's most frequent message was "continue." Beyond that, he asked leading questions such as why the agent was doing something, whether it could do something else, and why it was taking so long, because the agent tends to invent rules for itself and underestimate what it can do. Without pushing for ambition, he says, models aim for 0.1% improvements instead of 10%. 19:12–20:10(opens in a new tab), 21:00–22:29(opens in a new tab)
- The reported results are first-party benchmarks. Sumner reports that Claude Code compiled this way uses about 4x less memory and starts about 2x faster, and that the single-threaded compiled TypeScript compiler beats the single-threaded Go port of TypeScript 7. On JetStream 3, a standard JavaScript-engine benchmark, he says Bun's compiled output beats both JavaScriptCore's JIT and Node.js's V8 JIT on most tests. AOT is not always faster: code that relies heavily on the interpreter, through
evalornew Function, does not speed up, as in UglifyJS. Throughout the project, the team used Claude Code compiled with the new compiler to build the compiler. 04:38–06:22(opens in a new tab), 18:11–19:12(opens in a new tab), 20:10–21:00(opens in a new tab)
Full video: https://www.youtube.com/watch?v=TvsF67C2F54(opens in a new tab)