How Claude Code Rewrote a Million Lines of JavaScript Runtime From Zig to Rust
Bun is a fast JavaScript runtime built as a competitor to Node.js. Its entire core was originally written in Zig, a systems language designed to be a safer, simpler alternative to C. In early 2026, after Bun's creator joined Anthropic, the runtime was rewritten in Rust — and a large share of that work was done with the help of Anthropic's coding agent, Claude Code.
The scale of the effort is what made it a sensation on developer news this week: roughly one million lines of code were translated across a single pull request, with about 6,755 commits and more than a dozen subagents working in parallel. The result passed 99.8 percent of Bun's existing test suite — a strong signal that the rewritten program behaves the same as the original.
How an AI agent rewrites a program
Large coding agents do not read an entire codebase end to end. Instead, they are fed individual source files or small modules, asked to produce a translation, and the results are merged into a queue for a compiler to verify. Claude Code's subagents fanned out across Zig files in parallel, each emitting Rust translations, while a compiler-driven feedback loop caught and fixed mismatches.
Why Rust instead of Zig
The language switch is not about speed alone. Rust has a much larger ecosystem of libraries, more build-tooling, and a deeper pool of engineers willing to contribute to a systems project. For a runtime that will be maintained for years, Rust's established toolchain and memory-safety guarantees are a practical draw even if Zig is a cleaner design.
The part the agent could not do alone
Two details reveal the limits of the automation. First, the rewritten code contains roughly 13,000 unsafe blocks — Rust's escape hatch that disables its memory-safety checks. Those blocks are legitimate in a low-level runtime, but every one of them has to be justified by a human, because the compiler cannot prove them safe. Second, Claude Code did not write the million lines entirely unsupervised; it operated inside a pipeline that Jarred Sumner, Bun's founder, designed and oversaw.
What this tells us about AI coding
- At this scale, AI is a force multiplier for large migrations, not a solo author.
- The test suite, not the AI, is the real quality gate — 99.8 percent passed matters.
- "Unsafe" zones in systems code remain a human responsibility.
- The bottleneck is shifting from writing code to reviewing it.
The Bun rewrite is a landmark because it is one of the first publicly documented cases where an AI agent contributed heavily to a million-line, production-grade systems program. It does not prove that AI can replace systems engineers — it proves that, with the right pipeline and the right safety net of tests, a human can steer an agent across a task that used to take months.