AOT compilation made Claude Code use about four times less memory and start about twice as fast.
2
Existing tests made the Bun rewrite and compiler project trustworthy because the agents could not have changed tests that predated the work.
3
Large agent-written projects need repeated rewrites, frequent measurement, long-lived subagents, and active human direction.
Summary
Jarred Sumner describes adding an ahead-of-time compiler to Bun, the JavaScript runtime used by Claude Code. The project produced a PR with several million lines of code and went through five rewrites in a little over a month. The compiler reduced Claude Code's memory use by about four times and made it start about twice as fast. Sumner chose to improve JavaScript execution instead of rewriting Claude Code in Rust because rewriting its TypeScript test suite would make the tests harder to trust. Existing tests from Bun, WebKit, Test 262, and Cloudflare Code helped check the generated code. He also ran three versions of applications against one another and used fuzzing to find differences. His daily work involved asking agents why they were taking a particular approach, pushing them to try harder, and checking hourly scorecards. He is direct about the weaknesses of agent-written code, including excessive documentation, slow builds, and code he considered slop.
The compiler project went through five rewrites because build time mattered as much as correctness
Sumner says the ahead-of-time compiler was rewritten five times in a little over a month. An early version was nearly shipped, but its compilation time was too long. A later version had good code and performance but still took about 50 seconds to compile Claude Code, while other projects took single-digit seconds. The fifth version brought build time below 20 seconds and was considered shippable. Sumner leaves open the possibility of a sixth rewrite because the project is still being measured and reconsidered.
The choice of implementation was driven by how the team could verify the result. Sumner says this mattered more than the specific approach to building the compiler. Rewriting Claude Code in Rust would have required porting its TypeScript test suite. Once the tests were rewritten, the team could no longer trust them in the same way. Bun was easier to rewrite because its TypeScript tests could run against both the Zig and Rust versions. Improving JavaScript execution avoided that risk.
Existing tests made generated code easier to trust
The compiler project could use tests that existed before the project began. Bun's own tests were joined by WebKit's tests, Test 262, and Cloudflare Code's tests. Bun's test runner was also made to run in ahead-of-time mode. Sumner says these tests were valuable because the agents could not have modified them as part of the compiler work. The project still had two breaking changes, mainly related to preventing prototype pollution attacks, and those changes also improved performance.
Three execution modes can be checked against one another
For applications that can run in multiple modes, Sumner compared a version using the JIT, a version compiled ahead of time, and a version without the TypeScript types. If all three behave the same, that gives evidence that the compiler works for that application. The team then used generated code and fuzzing to exercise different patterns. Sumner describes this as a good fit for agents because they can produce many code generators and run them repeatedly.
Large batches should be followed by a separate fixing phase
Sumner split the work into large writing batches followed by focused cleanup. During the initial batch, agents wrote a lot of code and the team avoided repeated builds because waiting for compilation would waste time. After the batch, agents were tasked with getting the code to compile, passing tests, and checking that it really worked. He also used many individual agents for longer-running work after the initial code had been written.
Agent-written code can look fast while being fundamentally wrong
One version improved startup time by about two times and reduced memory use by about three times, but Sumner calls the code slop. It treated any object property named archive as evidence that the Bun.archive API might be used. He rejected that version. The agents also produced large numbers of Markdown planning files, including about 1,500 files, which Sumner considered unreasonable. These examples led him to inspect the generated design and code rather than judging it only by benchmark results.
Sumner says he now relies mostly on long-lived subagents, except during the initial phase when agents write the code all at once. These agents keep the relevant code in their context and can continue working without repeatedly reconstructing the project. He contrasts this with his older approach, which relied more heavily on Claude Code workflows. The longer-lived setup worked better for following the different parts of a compiler project of this size.
Human direction means questioning plans and checking measurements
Sumner's day consists largely of asking agents why they are doing something, whether they can do it, and what is taking so long. He says agents can talk themselves into rules, underestimate what they can do, or incorrectly judge the effect of a change. He used hourly updates and scorecards to compare metrics, plus fuzzing to test whether the test process actually found bugs. He also repeatedly pushed agents to attempt larger improvements instead of settling for small gains.