A fleet of Claude agents rewrote Bun from Zig to Rust in 11 days, and Claude Code now runs on it
Bun's creator ran 64 Claude Fable 5 instances in parallel to port half a million lines of Zig to Rust in 11 days for about $165,000. The rewrite went wide this week after Claude Code was found shipping the new Rust build.
Bun creator Jarred Sumner spent 11 days and roughly $165,000 in API credits pointing a fleet of Claude agents at his own runtime, and the result is that Bun is now a Rust project. The story circulated quietly after Bun published it, then went wide this week when Simon Willison cracked open the Claude Code binary and found a preview build of the Rust Bun inside it. The tool that did the rewriting now runs on the rewrite.
What actually happened
Between May 3 and May 14, Sumner spun up 64 instances of Claude Fable 5 across four Git worktrees and translated 535,496 lines of Zig into a Rust codebase that grew past a million lines, landing 6,502 commits and peaking near 1,300 lines of code per minute. The stated reason was not fashion. Bun mixed garbage-collected JavaScript with manually managed native memory, a combination that kept producing use-after-free bugs, double-frees, and leaks despite Address Sanitizer and fuzzing. Rust’s borrow checker and automatic cleanup move that whole class of bug from runtime to compile time.
The more interesting engineering detail is how the code was checked. Sumner ran an
adversarial review loop: separate Claude instances were handed only the diffs,
with no surrounding context, and told to assume the code was wrong. That pass
caught at least three real defects before merge, including a double-free on an
async libuv handle in subprocess stdio and a panic in CSS color parsing from an
eager unwrap_or. The reported outcomes are incremental rather than dramatic: 2
to 5 percent faster on benchmarks, a roughly 20 percent smaller binary, and 128
memory bugs fixed. Bun v1.4.0 is the first Rust build, and Claude Code v2.1.181
and later already ship it, where it made startup on Linux about 10 percent
faster. As Sumner put it, “barely anyone noticed. Boring is good.”
Where this lands in the market
The number that should stick is not the speedup, it is the 11 days. Sumner estimated the same port would have taken a single engineer close to a year. A rewrite that was previously a multi-quarter bet a company would rarely authorize becomes, at least in this case, a two-week line item with a five-figure API bill. That reframes a category of work most teams treat as impossible: language migrations, framework jumps, and the kind of debt paydown that never clears because no one can justify the calendar time.
The skepticism is worth taking seriously, and not only for balance. Zig’s creator Andrew Kelley pushed back hard on the framing, unwilling to let his language take the blame for what he attributed to how Bun was built rather than to Zig itself, and the broader worry is obvious: a million lines of machine-written Rust is a lot of code for a small team to genuinely understand and maintain. There is also an uncomfortable adjacent detail, in that one of the memory bugs behind the rewrite was implicated in the recent Claude Code source leak. The lesson developers should take is less “AI can now do rewrites” and more “AI can now do rewrites if you build the verification harness around it,” which is exactly what the adversarial-review loop was.
What’s worth watching
- Maintainability over the next two quarters. The real test is not the port, it is whether a small team can debug, extend, and secure a million lines of generated Rust six months from now without the original context.
- Whether the pattern generalizes. Bun had strong test coverage and a pathological memory-safety problem, close to a best case for an agentic rewrite. The open question is how the approach holds up on a codebase with weaker tests and murkier behavior.
- The verification playbook, not the model. The adversarial diff review is the reusable idea here. Expect teams attempting large agent-driven migrations to copy that harness before they copy the headline.
The plain read is that this is a real milestone in what a coding agent can be trusted to do at scale, wrapped around an honest disclaimer that the results were “boring.” Claude Code becoming a platform that rewrites the runtime it depends on is the kind of loop that was theoretical a year ago. Stackmaven will check back on how the Rust Bun holds up in production, on or around October 18.
- Bun blog: Rewriting Bun in Rust (Jarred Sumner) bun.com
- Simon Willison: Claude Code uses Bun written in Rust now simonwillison.net