July 20, 2026Eline Tiva

๐Ÿž What Is Bun? Inside the 11-Day, AI-Driven Rewrite from Zig to Rust

Bun moved 535,496 lines from Zig to Rust in 11 days with up to 64 Claude instances. The engineering process matters more than the headline.

0:00โ€”
A short story by Eline Tiva
Official Bun visual announcing its rewrite from Zig to Rust

Bun moved 535,496 lines of its JavaScript tooling from Zig to Rust in 11 days. At peak, roughly 64 Claude instances worked in parallel. The reported API-equivalent cost was about US$165,000.

Those numbers make an irresistible headline. They also hide the part developers should study: Bun did not ask one chatbot to "rewrite the codebase" and wait for magic. The team prepared migration rules, mapped memory lifetimes, divided the work, separated implementation from review, and kept a human watching the system.

Before getting to the AI experiment, one question needs a plain answer.

๐Ÿž What is Bun?

Official Bun JavaScript toolkit logo
Bun packages a JavaScript runtime, package manager, test runner, and bundler into one executable.Bun

Bun is an all-in-one toolkit for JavaScript and TypeScript development. It can run applications like Node.js, install packages like npm or pnpm, execute tests in a Jest-like format, and bundle application code for deployment.

That means a developer can use commands such as bun install, bun run, bun test, and bun build without assembling a separate tool for every step. Bun ships these capabilities in one executable and uses JavaScriptCore, the engine developed for Safari.

Bun says its command-line tool receives more than 22 million downloads per month. Claude Code and OpenCode use it as a runtime, while platforms including Vercel, Railway, and DigitalOcean provide first-party support.

Anthropic acquired Bun in December 2025. The stated plan was to keep Bun open source while using it as infrastructure for Claude Code, the Claude Agent SDK, and future AI coding products.

๐Ÿง  Why move from Zig to Rust?

Bun began in Zig. Founder Jarred Sumner credits the language with making it possible to build such a broad tool in one year. The problem was not that Zig suddenly became slow or unusable.

The problem was Bun's memory model.

Bun embeds JavaScriptCore, which automatically manages JavaScript memory through garbage collection. Much of Bun's native code, however, managed memory manually in Zig. The two sides constantly passed pointers and ownership responsibilities across the boundary.

Bun's bug list included use-after-free errors, double frees, memory leaks, and crashes along error paths. One development-server workload leaked about 3 MB on every rebuild. After 2,000 builds, Bun v1.3.14 reached 6,745 MB in Bun's test; the Rust-based v1.4.0 levelled off at 609 MB.

Rust moves more of this responsibility into its ownership system and borrow checker. Many mistakes that would otherwise appear while the program is running become compiler errors. That does not make Rust code automatically correct, but it changes when and how a large class of mistakes is discovered.

๐Ÿค– How the AI rewrite actually worked

The official account describes about 50 dynamic Claude Code workflows running over 11 days. At the busiest point, four workflows ran in separate Git worktrees, with 16 Claude instances in each. That is where the widely repeated figure of roughly 64 concurrent agents comes from.

The preparation mattered more than the headcount.

Sumner first spent about three hours working with Claude on a Zig-to-Rust porting guide. A separate workflow traced the expected lifetime of struct fields and stored the results in a shared table. Before scaling up, Bun tested the process on three files.

For each implementation task, one Claude wrote the port while at least two Claude reviewers worked in separate context windows. Their only job was to find behavioral differences, violations of the migration guide, or reasons the new code might fail. Another pass applied the feedback.

At peak, Claude generated around 1,300 lines per minute. The first output did not work. It exposed roughly 16,000 compiler errors after the codebase was split into smaller Rust crates. Bun then used more workflows to classify and repair those errors.

The final confidence did not come from the volume of generated code. It came from a language-independent test suite containing more than one million assertions across Linux, macOS, and Windows, combined with adversarial review, security review, fuzzing, and continued human monitoring.

๐Ÿ“Š What changed after the port?

Bun chart comparing Claude Code startup time before and after the Rust port
Bun says Claude Code startup on Linux improved from 517 ms to 464 ms after it began using the Rust-based port.Bun

Bun reports that v1.4.0 fixes 128 bugs reproducible in v1.3.14. The list ranges from memory leaks and crashes to smaller user-interface errors.

The initial rewrite also reduced binary size by 3.8 MB on Windows, 5.5 MB on macOS, and 6.8 MB on Linux. Later figures in the same post show the Windows binary dropping from 94 MB to 76 MB and Linux from 88 MB to 70 MB.

In Bun's own benchmarks, HTTP throughput and common application workloads improved by roughly 2.8% to 4.8%. Claude Code had quietly used the Rust port since version 2.1.181, released June 17. Bun's production telemetry showed median Linux startup falling from 517 ms to 464 ms, a 10% improvement.

These are vendor-reported results. They are useful evidence, not a universal verdict that Rust will make every Zig project faster or smaller.

โš–๏ธ The Zig creator's criticism is not just language-war drama

Andrew Kelley, creator of Zig, published a sharply worded response. Some of it was personal, but several technical objections deserve to be separated from the heat.

Kelley argued that Bun's code quality had been a problem long before the AI rewrite. In his account, Bun became a poor example of how to write Zig because the project prioritised feature velocity over reducing technical debt.

He also challenged how the performance story was framed. The Rust version used link-time optimisation, which Zig had supported. He argued that the smaller binary was tied to Bun's previous overuse of Zig's compile-time features rather than an inherent Rust advantage. Bun's own article agrees with the latter point.

His hardest question concerns review: if the old test suite failed to catch every bug in the Zig version, why should passing the same suite prove that more than a million newly generated lines are safe?

Bun's answer is not "tests caught everything." Its process added adversarial review, compiler checks, security passes, Miri, LeakSanitizer, and continuous fuzzing. Even then, the Rust code still contains substantial unsafe usage that Bun plans to reduce over time.

๐Ÿงฉ What engineering teams should learn from Bun

The impressive part is not that AI typed quickly. It is that Bun built a system capable of rejecting AI output.

A comparable migration needs at least four foundations:

  • A behavioural contract. Tests must describe what the system does independently of the implementation language.
  • Written migration rules. Agents need shared decisions for ownership, naming, architecture, and acceptable exceptions.
  • Separated roles. The model that writes a change should not be the only model judging it.
  • A repairable process. When agents repeatedly make the same mistake, fix the workflow or guidance instead of patching thousands of symptoms by hand.

The US$165,000 figure also needs context. It represents what 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached-token reads would have cost at API pricing. Bun was part of Anthropic, so this was not necessarily a cash invoice paid in the ordinary sense.

And 11 days does not mean 11 days from idea to a permanently finished codebase. Bun prepared the workflow, monitored it continuously, continued security reviews after the merge, and still has refactoring work ahead.

๐Ÿ”‘ Key takeaway

Bun is a serious piece of JavaScript infrastructure, not another framework with a clever name. Its Rust migration shows that AI can compress a codebase rewrite once considered financially unrealistic.

But the result does not support the lazy conclusion that a fleet of agents can replace an engineering team. Bun succeeded because years of tests, deep knowledge of the codebase, explicit migration documents, hostile review loops, and human judgment were already available.

Without that scaffolding, 1,300 lines per minute is not productivity. It is merely a faster way to create a larger review problem.

FAQ

Is Bun a replacement for Node.js?

Bun can replace Node.js for many JavaScript and TypeScript workloads, while also covering package installation, testing, and bundling. Compatibility is broad but not universal, so production applications should test the APIs and dependencies they use.

Do Bun users need to write Rust?

No. Application developers continue to write JavaScript or TypeScript. Rust is now used for Bun's internal implementation.

Did 64 AI agents rewrite Bun without humans?

No. About 64 Claude instances ran concurrently at peak, but Jarred Sumner designed the workflows, monitored their output, reviewed code, adjusted the process, and relied on Bun's existing test infrastructure. The official account describes roughly 50 dynamic workflows across the 11-day run.

Does the rewrite prove Rust is better than Zig?

No. It shows that Rust's ownership model suited Bun's specific memory-management problems. Some size and performance improvements also came from implementation and build changes that were not exclusive to Rust.

Keep reading