Bun creator Jarred Sumner pulled off what would have been unthinkable just a year ago. Using a pre-release version of Anthropic's Claude Fable 5, he rewrote Bun's entire codebase from Zig to Rust in 11 days[reference:9]. The migration produced over a million lines of code, with 100% of Bun's existing test suite passing in CI before the merge[reference:10].
Why Rewrite Bun?
Bun is a JavaScript runtime that does many things: it's a bundler, a package manager, and a test runner all in one. It has 22 million monthly downloads, and software like Claude Code and OpenCode depend on it. Hosting providers like Vercel, Railway, and DigitalOcean offer first-party support for Bun.
The problem was Zig. Zig is not a memory-safe language, and memory-related bugs were a constant issue. The Bun team had already patched the Zig compiler and implemented end-to-end memory leak tests, but the bug list kept growing. Sumner was tired of going to sleep worrying about crashes in Bun.
The AI-Powered Migration
A manual rewrite would have taken three engineers with full context on the codebase about a year[reference:11]. During that time, they wouldn't be able to improve Node.js compatibility, fix bugs, or implement new features. The realistic alternative was to do nothing and keep fixing bugs forever.
Instead, Sumner spent about 3 hours talking to Claude about how to map patterns from the Zig codebase to Rust. Claude serialized this discussion into a porting guide. Then Sumner asked Claude to rewrite three files at a time out of 1,448 total files. After each rewrite, he ran two separate adversarial reviews with Claude to critique the result.
The process was scaled up to 64 Claude agents working in parallel. They completed the rewrite of over 535,000 lines of Zig code over two days. Each commit was checked by two adversarial reviews before being committed[reference:12].
The Cost and the Results
The rewrite consumed 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input token reads. At API pricing, the cost was around $165,000[reference:13]. Mitchell Hashimoto called it an incredible deal, noting that there's absolutely no way an engineer with that salary would have achieved the same milestones in 11 days[reference:14].
The results speak for themselves. The migration fixed 128 bugs and improved reliability significantly[reference:15]. Bun's command-line tool now has over 10 million monthly downloads[reference:16]. The rewrite proved that AI can turn a year-long migration into a week-long project, but only when the project is well-engineered with a robust test suite.[reference:17]