Anthropic opens up its six-step code migration playbook: a million lines of Bun moved from Zig to Rust in two weeks
- Rewriting a production codebase in another language is supposed to take four years, three to four million dollars, and a good chance of stalling halfway. Anthropic's engineers shipped 10 packages in the past month; the Bun job was a million lines, done in under two weeks, with the entire existing test suite green before merge
- The whole method rests on one line: don't fix the code, fix the loop that produced it. When the same mistake shows up across dozens of files, the correct move is to add a line to the rulebook and regenerate the batch — not to patch file by file
- Before you translate anything, build an oracle. Pull the existing tests that can run against both the old and new code, rewrite them as assertions, then check the oracle against deliberately broken code. An oracle that can't catch damage isn't an oracle, and without one you have no definition of "done"
- The engineering details are worth copying outright: the work queue recomputes from disk every time, so an interrupted run resumes; implementation runs on a small model and review on a large one; two reviewers work in separate contexts and a third agent breaks ties; anything untranslatable gets a uniform
// TODO(port)and waits - Both the bill and the payoff are on the record. Bun: 5.9 billion uncached input tokens plus 690 million output tokens, about $165,000 at API list prices. Mike Krieger's project: compiles dropped from 8 minutes to roughly 2 seconds, binary startup got 6× faster, and an entire deployment pipeline went away
Ten packages in a month
A million lines of code moved to a new language in two weeks, with the full existing test suite passing in CI before the merge.
That's from a hands-on writeup posted by ClaudeDevs, Anthropic's official account, covering how the company spent the past month using Claude Code to migrate production codebases from one language to another. The post lays out the entire process, templates included, for anyone to copy. The tools: Claude Fable 5, Claude Opus 4.8, and Claude Code's dynamic workflows.
Over the past month Anthropic's developers finished 10 packages, ranging from tens of thousands to hundreds of thousands of lines. The post details two of them.
The Bun migration was done by Jarred Sumner, Bun's co-founder, now a member of technical staff at Anthropic. The Python one was Mike Krieger, Instagram co-founder, now co-lead of Anthropic Labs.
Why nobody used to attempt this
Jarred picked Zig originally because it delivered C-level performance while staying simple enough — in his words, that simplicity is what let one person write Bun in a year, from a cramped Oakland apartment, before large models existed. Simplicity has a price, and the price never went away. Bun's CLI now clears ten million downloads a month, and Claude Code leans on it heavily internally.
As recently as last quarter, that price still wasn't enough to justify freezing a roadmap and committing resources to a multi-quarter project.
- Four years and $3–4M in engineering resources
- Roadmap frozen for the duration
- Two codebases maintained in parallel for quarters, sometimes years
- Worst case: 90% parity, and more trouble than before you started
- Tens to hundreds of thousands of dollars — still real money
- Worst case: delete the branch and try again
- The justification no longer has to be "migrate or die"
- A memory-bug patch that's been sitting in the changelog for a year, or one long-standing bottleneck, is enough
A bottleneck is exactly what pushed Mike's project over the line. His team's internal tool had to ship as a single executable, and the Python toolchain took about eight minutes to compile per platform — thirty minutes of waiting for the full build matrix on every release. In TypeScript the same compile takes about two seconds, the executable starts 6× faster, and the team retired an entire standalone deployment pipeline while they were at it.
When the same mistake keeps appearing, change the rule
The most valuable sentence in the whole piece:
The core insight is that you don't fix the code. You fix the process (loop) that produced the code.— ClaudeDevs
In practice: a review agent catches the same mistake across dozens of files, and your hands stay off those files. You add a line to the rulebook and regenerate the affected batch. The rulebook only grows over the course of the project, and the code is never hand-patched to satisfy it.