Bun creator Jarred Sumner recently announced that the JavaScript/TypeScript runtime, bundler and package manager has been rewritten from Zig to Rust. The rewrite seeks to eliminate recurrent memory safety vulnerabilities via Rust's borrow checker, which catches use-after-free, double-free and similar errors at compile time.
Sumner described the motivation: "A large percentage of bugs [...] are use-after-free, double-free, and 'forgot to free' in an error path. In safe Rust, these are compiler errors and RAII-like automatic cleanup with Drop. Compiler errors are a better feedback loop than a style guide."
Historically, full rewrites are considered risky—Bun comprised 535,496 lines of Zig, and a manual rewrite would likely take a small team a year, freezing bugfixes and feature development. However, Bun's own test suite is written in TypeScript, meaning it does not depend on the runtime's programming language. Sumner decided to test whether Anthropic's latest model could handle the conversion.
Sumner executed an automated all-at-once port using a pre-release version of Claude Fable 5 orchestrated across approximately 50 dynamic workflows. The system translated Zig into Rust, often using unsafe Rust that could be refactored later, then validated the output against Bun's extensive test suite of more than one million assertions. A porting guide helped Claude map Zig patterns and types to Rust patterns and types. Adversarial agentic code reviews—with separate "implementer" and "reviewer" agents—detected issues before they reached the final port.
"The implementer doesn't review. The reviewer doesn't implement," Sumner said.
The effort was distributed across four workspace shards running 16 agents each, operating 64 Claude instances in parallel. At peak velocity, the system generated roughly 1,300 lines of code per minute and logged up to 695 commits an hour. Getting the full test suite passing required $165,000 worth of tokens—5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input tokens.
Key success factors included a PORTING.md file describing the mapping from Zig to Rust, and a LIFETIMES.tsv file describing lifetimes of every struct field in the codebase. The constant process improvement revealed that a detailed planning phase was critical to anticipating and mitigating challenges.