Generated by Codex with GPT-5
The Pragmatic Engineer surfaced this July 9, 2026 story in Gergely Orosz’s The Pulse: What can we learn from Bun’s rapid Rust rewrite with AI?. The concrete source is Bun creator Jarred Sumner’s detailed account, Rewriting Bun in Rust, which explains how one engineer used Claude Code and a prerelease Claude Fable 5 model to port Bun’s JavaScript runtime from Zig to Rust in 11 days.
The headline is astonishing: roughly 535,000 lines of Zig became a Rust change adding more than one million lines, work Sumner estimates would otherwise have occupied three experienced engineers for about a year. But the useful lesson is not that any team can hand a rewrite to an AI and return two weeks later. Bun succeeded because the migration was turned into a controlled system of specifications, independent reviews, compiler feedback, and exhaustive tests.
The Rewrite Had an Unusually Strong Oracle
Bun wanted to move because recurring memory leaks, double frees, race conditions, and out-of-bounds accesses were expensive to prevent in a runtime that mixes garbage-collected JavaScript with manually managed native memory. Rust could make more of those mistakes visible through its type system, borrow checker, and automatic cleanup with Drop.
A conventional rewrite was still unattractive. It would freeze feature work and security fixes for a year, while a gradual migration would leave two implementations and a large amount of temporary integration code. Sumner therefore chose a deliberately mechanical port: preserve Bun’s architecture and behavior, translate familiar Zig patterns into corresponding Rust patterns, and postpone making the code fully idiomatic.
The decisive asset was not the model. It was Bun’s language-independent TypeScript test suite, with more than a million assertions across thousands of files. Because the tests did not depend on either Zig or Rust, they could serve as an external definition of correct behavior. That made the rewrite a search problem with measurable progress rather than an open-ended request for plausible-looking code.
The Unit of Work Was a Loop, Not a Prompt
Before generating production code, Sumner spent about three hours working with Claude on a PORTING.md guide that mapped Zig types and patterns to Rust. A separate workflow analyzed field lifetimes across the codebase and produced a shared LIFETIMES.tsv. Both artifacts were reviewed by other agents and manually checked before a three-file trial run.
The full migration then used about 50 dynamic workflows. Each loop gave one agent an implementation task, sent the diff to at least two adversarial reviewers in separate context windows, and gave a fixer the reviewers’ findings. The reviewers were told to assume the code was wrong. Keeping authorship and review separate mattered because a model that has just produced a change is also biased toward accepting it.
At peak, four worktrees each ran 16 agents, or about 64 Claude instances at once. The orchestration itself needed debugging. Early agents used git stash, stash pop, and reset concurrently and damaged one another’s work, so Sumner changed the workflow rules and sharding strategy. Later stages converted compiler errors, smoke-test failures, local test failures, and CI failures into queues that agents could process repeatedly.
This is the most transferable part of the story. Sumner did not spend 11 days reviewing a million-line diff line by line. He monitored the machinery that generated and checked the diff, read samples and agent outputs, and repaired the process when it produced bad behavior.
Tests Turned Speed Into Evidence
The first generated code did not work. Compilation and testing made it converge. Two days after the first CI run, the number of failing test files had fallen from 972 to 23; another day and a half brought Linux fully green. The rewrite was merged only after the complete suite passed on all six supported platforms and Sumner manually verified that tests were actually running rather than being skipped. No tests were deleted or skipped to reach green.
The scale was extreme: 6,502 non-merge commits, 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input-token reads before merge. At API prices, Sumner estimates the run at roughly \$165,000. That figure is expensive for an experiment but cheap relative to a year of three senior engineers plus the opportunity cost of paused product work. More importantly, the realistic alternative was not a cheaper human rewrite; Sumner says Bun would simply have continued fixing the same classes of bugs individually.
The result was not magically clean. Bun documented 19 regressions caused mostly by subtle semantic differences between similar-looking Zig and Rust code, and about 4% of the Rust code remained inside unsafe blocks at publication time. Merging to main was also not the same as immediately shipping a stable release. The team followed with 11 security-review rounds, continuous parser fuzzing, and further human review.
Even with those caveats, the outcome was substantial. Bun says version 1.4 fixes 128 bugs reproducible in 1.3.14, eliminates every memory leak its improved instrumentation could detect, reduces binary size by about 20% on Linux and Windows, and improves measured performance by roughly 2% to 5% on several workloads.
What Engineering Teams Should Actually Copy
Orosz’s framing is valuable because it separates an extraordinary result from a universal recipe. Bun had a creator with deep knowledge of the original system, a highly mechanical target, an implementation-independent test suite, compiler-enforced constraints, unusually large model access, and a prerelease frontier model. A product with ambiguous requirements, weak tests, or behavior that can only be judged by users would not offer the same feedback loop.
The broader shift is still real. AI can make previously uneconomic migrations possible, but only when teams invest in the infrastructure of confidence: executable specifications, isolated work units, independent review, aggressive testing, reproducible failures, and human supervision of the process. The bottleneck is moving away from typing code and toward designing systems that can prove vast amounts of generated code behave correctly.
That is why Bun’s rewrite matters beyond Rust, Zig, or Claude. It is a concrete example of software engineering becoming less about producing each change by hand and more about building reliable factories for proposing, attacking, testing, and refining changes. The impressive number is 11 days. The durable lesson is everything Bun had to construct so those 11 days could be trusted.