
Bun just shipped a complete Zig-to-Rust rewrite — 535,000 lines of code translated in 11 days using Claude Code agents running in parallel. The result is already live in Claude Code v2.1.181. Bun v1.4.0 is coming. The rewrite eliminated a documented class of memory safety bugs, shrank the Linux binary from 88 MB to 70 MB, and ignited the loudest debate about AI-generated code quality in production the developer community has seen yet.
Why Rust: The Problem Was Real
This was not a language fashion statement. Bun v1.3.14 shipped with 19 documented memory bugs — use-after-free crashes, double-frees, and leaks in zlib, HTTP/2, UDP sockets, and TLS. The root cause was architectural: Bun mixed Zig’s manual memory management with JavaScriptCore’s garbage collector, and correctly handling value lifetimes across that boundary was a recurring failure point. A call to Bun.build() leaked 3 MB per invocation — across 2,000 builds, that’s 6,745 MB of unreclaimed memory.
Rust’s borrow checker enforces correct lifetimes at compile time. Zig’s defer mechanism does not — it leaves correctness to the programmer and code review. Jarred Sumner, Bun’s creator, put it plainly: “For Bun, correctly handling the lifetimes of garbage-collected values and manually-managed values has been a major source of stability issues.” The rewrite was the answer to a specific, measurable problem.
How the Rewrite Worked: Not Just Prompting
The methodology is worth understanding, because it’s more engineered than a “prompt and ship” story. Sumner spent three hours on preparation before touching a single file: generating PORTING.md (a mapping of Zig patterns to Rust equivalents) and LIFETIMES.tsv (a struct-by-struct field lifetime analysis). He then ran a trial on three files with full adversarial review before scaling to all 1,448 source files.
Each task followed a four-role structure: one Claude instance implemented, two reviewed in separate context windows — never seeing the original Zig, only the diff — and one fixed what the reviewers flagged. The separate context windows are the key design decision: they prevent the implementer’s reasoning from contaminating the review. This adversarial setup caught more than 50 real bugs before merge, including an async close race condition where a Box<uv::Pipe> was dropped while libuv still held the pointer for a pending callback.
At peak, 64 Claude instances ran simultaneously across four worktrees. The total: 6,502 commits, 695 commits in a single hour on day three, and roughly 1,300 lines of code per minute. API cost came to approximately $165,000 — Sumner noted that the human equivalent would be “three full-year engineers,” a comparison that understates the tradeoff since those engineers could not have feature-frozen Bun for 11 days.
What Shipped
The performance gains are real but modest. HTTP throughput improved 4.5–4.8% across Bun.serve, node:http, and fastify. The Next.js build benchmark dropped from 13.62 to 13.03 seconds. Binary size fell roughly 20% on every platform — Windows went from 94 MB to 76 MB. The memory leak story is more dramatic: in-process Bun.build() now stabilizes at ~610 MB across 2,000 builds rather than 6,745 MB. Claude Code’s startup on Linux improved from 517ms to 464ms — a 10% gain that Sumner described as “barely anyone noticed — boring is good.”
Post-merge, the team found 19 regressions. All were fixed. The most instructive: a debug assertion whose side effects were silently erased in release builds, breaking hot-module reloading. Rust’s behavior differs from Zig’s ReleaseFast in ways that exposed a real latent bug in the original code.
The “Unreviewed Slop” Debate
Andrew Kelley, creator of Zig, called the result “unreviewed slop.” His criticism is worth taking seriously: the Rust port contains roughly 13,000 unsafe blocks — about 4% of the codebase. Critics call it “Zig semantics dressed in Rust syntax,” arguing the borrow checker’s guarantees are opt-in and most of the code has opted out.
The counter-argument is also credible. Sumner documented that 78% of those unsafe blocks are single-line pointer operations required for C library interop (JavaScriptCore, BoringSSL, SQLite) — not logic errors hiding in unsafe Rust. The 19 post-merge regressions were found and fixed, and 24/7 coverage-guided fuzzing across 12 parsers continues to run.
The honest answer: adversarial multi-agent review with two independent context windows is a serious quality process, not a rubber stamp. It is not equivalent to senior engineers reading every line. Whether that gap matters depends on what you’re shipping. For Bun — a runtime that already had 19 documented bugs before the rewrite — it appears to have been an acceptable tradeoff.
What This Means for You
If you use Bun, the Rust version is already powering Claude Code. Bun v1.4.0 will bring the same changes to the standalone release with no breaking changes — your existing code, configs, and CLI workflows are unaffected. Expect fewer edge-case crashes, a smaller binary, and a contributor pool drawn from a much larger Rust ecosystem.
The larger implication is the methodology itself. Sumner’s adversarial multi-agent pipeline — documented in the 6,502-commit PR — is a replicable framework: prepare thoroughly, implement in parallel, review with separate context windows, validate relentlessly. Mitchell Hashimoto put it bluntly: “There’s absolutely no way an engineer with that salary would’ve been able to achieve the milestones Claude did in 11 days.” That may be the more important takeaway from this rewrite than anything Rust-specific. And it’s already shipped to millions of Claude Code users who never noticed the switch.








