Anthropic's Bun Team Ported a Million-Line Runtime From Zig to Rust in 11 Days. Claude Wrote Almost All of It.
TL;DR
On July 8, Bun published the full postmortem of how it rewrote its JavaScript runtime from Zig to Rust. The scale is the story: roughly 535,000 lines of Zig became about 1,009,000 lines of Rust across 6,502 commits, and a pre-release Claude Fable 5 wrote almost all of it. It ran as around 50 Claude Code workflows, with up to 64 model instances going at once, over 11 days, for about $165,000 in API spend. The rewrite already shipped inside Claude Code back in June, and the most remarkable thing about it is that basically no one noticed.
What actually shipped
The rewrite itself is not new. The numbers are. Bun merged the Rust port in mid-May and shipped it to users inside Claude Code v2.1.181 on June 17. What landed on July 8 is the retrospective, and it is the first time anyone has put a full invoice on a language migration this large that was done mostly by a model.
Here is the shape of it. Bun is the all-in-one JavaScript runtime, bundler, and package manager that Anthropic acquired on December 2, 2025. The reason for that purchase is blunt, in founder Jarred Sumner's words: "Claude Code ships as a Bun executable to millions of users. If Bun breaks, Claude Code breaks." So when the Bun team decided to move the whole runtime off Zig, they were not refactoring a side project. They were re-pouring the foundation under a product doing a billion dollars a year.
Why rewrite a runtime that already works
Rewrites are the classic engineering trap: high risk, no new features, and a strong chance you reintroduce every bug you spent years killing. So why do it? Memory safety. Zig gives you speed and control but no guardrails, and a systems codebase written by hand accumulates a specific class of rot.
"A large percentage of bugs from that list are use-after-free, double-free, and 'forgot to free' in an error path. In safe Rust, these are compiler errors." - Jarred Sumner
That is the whole thesis in two sentences. A category of bug that used to be a crash report from a user at 2am becomes a red squiggle in the editor before the code ever runs. The verbosity you saw in the chart above is the price you pay for that, and Bun decided it was worth it.
How you port a million lines in eleven days
You do not hand it to one model in one giant prompt. Sumner ran the migration as roughly 50 separate Claude Code workflows, each one chewing on a slice of the codebase, with as many as 64 Claude Fable 5 instances running in parallel at the peak. Think of it less like a coder and more like a foreman running a crew of 64, where every worker is fast, tireless, and occasionally confidently wrong, and the foreman's real job is catching the third thing.
The output was 6,502 commits over 11 days of active work. Nineteen regressions got introduced along the way and were subsequently hunted down and fixed. The tell that this was a genuine port and not a rewrite-from-scratch: it is, in Sumner's framing, essentially the same codebase translated, which is exactly the kind of large, mechanical, well-specified job that models are unreasonably good at and humans find soul-crushing.
The number that makes it real: cost, and the cache
The bill was about $165,000 in API pricing. For a task that traditionally means a senior team blocked for the better part of a year, that is a rounding error, and it is the figure that will get repeated in every "should we rewrite it" argument for the next decade.
But the more instructive number is buried in the token accounting. The job burned 5.9 billion uncached input tokens and 690 million output tokens, against 72 billion cached input token reads. Picture a photocopier that remembers every page it has already scanned: the model re-read Bun's enormous source tree thousands of times, but only paid full freight for it once. Prompt caching, not raw model horsepower, is what drags a project this size from "theoretically possible" down to a mid-five-figure invoice.
What did all that buy, technically? The Rust build shrank the binary by 3 to 8 MB, fixed several memory leaks (including one that dripped about 3 MB per call in Bun.build()), and cut startup time on Linux by roughly 10%. General throughput moved 2 to 5%, and HTTP got a couple points faster. Not fireworks. That understatement is the point: the dramatic part is the process, not the diff.
What it means if you build
Do not read this as "fire the team, the model does rewrites now." Read it as a recalibration of one specific line item. The large, boring, well-defined migration, port this to that language, upgrade this framework across 400 files, replace this deprecated API everywhere, is no longer a quarter-long slog you keep postponing. It is a weekend and a four-figure API bill, if you have the test suite to keep it honest.
Because that is the real prerequisite, and it is the thing to steal from this story. Bun could do this because it had a language-independent test suite with roughly a million assertions. The tests, not the model, are what made the rewrite safe: they are the wall the 64 parallel instances kept throwing code at until it stuck. A model can port your codebase in a weekend. It cannot tell you the port is correct. Your tests do that, and if you do not have them, this playbook is not yet yours.
The honest caveats
Keep three things straight. First, every figure here is Bun's own, self-reported in a retrospective by the company that did it, and Bun is now owned by the company that makes the model, so nobody in this story is a neutral party. Second, the conditions were close to ideal: a mechanical translation, an exceptionally deep test suite, a pre-release frontier model, and a team of the exact people who wrote the original. Your CRUD app with 40% coverage is not this. Third, it was not seamless under the hood; some tests were modified during the port, and users did file GitHub issues for behavior that differed from the Zig version. "Almost no one noticed" is a compliment to the process, not a claim of zero regressions.
Key Takeaways
- On July 8, Bun published a postmortem of porting its runtime from Zig to Rust: about 535K lines became roughly 1.0M lines across 6,502 commits, with a pre-release Claude Fable 5 doing nearly all the writing.
- It ran as around 50 Claude Code workflows, up to 64 model instances in parallel, over 11 days, for about $165,000 in API spend.
- The token accounting is the tell: 72 billion cached input reads versus 5.9 billion fresh. Prompt caching is what makes a rewrite this large economically sane.
- The payoff was modest and undramatic: a 3 to 8 MB smaller binary, fixed memory leaks, and roughly 10% faster startup on Linux. The process is the headline, not the diff.
- The real enabler was Bun's test suite of about a million assertions. Models can port code fast; only your tests can certify the port is correct.
- All numbers are self-reported by an Anthropic-owned company, under near-ideal conditions. Treat it as a ceiling for what agent-driven migration can do, not a floor.
Sources: Bun (Rewriting Bun in Rust, the primary retrospective), Simon Willison (independent writeup with token figures), Techzine (files changed, regressions, acquisition), Anthropic (Bun acquisition), Bun (joining Anthropic)