1 Million Lines in Two Weeks: How Claude Code Pulls Off Large-Scale Code Migrations
Hey everyone, it's Shiichan! Today I found a meaty piece of engineering writing that got me really excited: Anthropic shared exactly how it pulled off large-scale code migrations using Claude Code, warts and all!
Claude BlogWhat was announced?
Claude Blog published a post titled "How Anthropic runs large-scale code migrations with Claude Code." It walks through two real migration projects run by Anthropic's own developers and lays out a six-step process and set of best practices for tackling large-scale code migrations with AI agents.
The first is Bun creator Jarred Sumner's project porting Bun itself from Zig to Rust. The team produced a million lines of code in less than two weeks, and 100% of Bun's existing test suite passed in CI before the merge. Only 19 regressions surfaced after the merge, and all of them got fixed. The whole effort consumed 5.9 billion uncached input tokens and 690 million output tokens, which comes out to around $165,000 at API pricing.
The second is Mike Krieger's (co-lead of Anthropic Labs) project porting an internal tool from Python to TypeScript. His team wrote 165,000 lines of TypeScript in a single weekend, running hundreds of agents through eight phase gates and three rounds of adversarial review.
On top of that, in the past month alone, individual Anthropic developers migrated 10 code packages ranging from tens to hundreds of thousands of lines using Claude Fable 5, Claude Opus 4.8, and dynamic workflows.
The story so far
Language ports like these used to be multi-year undertakings. There's a huge amount to rewrite, and you also have to guarantee the new code behaves exactly like the old one, so doing it by hand rarely penciled out, and these projects kept getting pushed down the backlog.
Mike's team felt that pain directly. Building the internal tool with the Python toolchain took roughly eight minutes per platform, adding up to a 30-minute wait across the whole build matrix on every release. After the port, that same build takes about two seconds, the binary starts six times faster, and the team was even able to retire a separate deployment pipeline.
What changes
Migrations that used to require a multi-million-dollar investment, and so sat untouched, are now realistically within reach for a fraction of that cost using AI agents. That makes it worth revisiting the legacy codebase your team has been putting off.
Alongside the post, Anthropic also released an open-source migration starter kit on GitHub, so you can actually try building a rulebook and dependency map for your own project. If it's a framework upgrade or legacy modernization rather than a language port you're after, there's also a related code-modernization plugin.
Dive Deep
The process breaks down into six broad steps.
As a prerequisite, you need a "judge" that can evaluate the original and ported code on equal footing. Claude helps sort existing tests into ones that can be rewritten as external calls versus ones that depend on internals and can't be ported; the latter get rewritten so they run against both codebases. The team even verifies the judge itself by confirming it fails against deliberately broken code.
- Step 1: Build a rulebook (a lookup table mapping types and idioms between languages), a dependency map, and a gap inventory covering the new design requirements the target language forces, like Rust's ownership rules or TypeScript's interface contracts.
- Step 2: Stress-test the rules with a small "mini migration." Jarred caught two critical issues at this stage that would have caused a disaster if they'd fanned out across all 1,448 files.
- Step 3: Translate everything. Implementer agents do the work while two adversarial reviewers, each in a separate context, check it; when they disagree, a third agent settles it. If a reviewer keeps catching the same mistake, the fix goes into the rulebook and the affected batch gets regenerated wholesale, instead of hand-patching individual files.
- Steps 4-6: Compile, run, and match behavior. The compiler's error list, smoke-test crashes, and test-suite failures become the next work queue automatically. A dedicated "build daemon" batches patches and rebuilds once instead of letting agents trigger rebuilds independently.
Token spend is optimized by handing implementation work to smaller models and reserving larger ones for review and rule-writing. The main portion of Mike's port alone used 27 million tokens.
The results are candid too: about 4% of the Rust code in Bun sits inside "unsafe" blocks, mostly single-line pointer operations at C/C++ boundaries. Even so, a benchmark of 2,000 repeated builds showed memory use dropping from 6,745 MB to 609 MB, the binary got 19% smaller on Linux and Windows, and real workloads like HTTP serving got 2-5% faster.
Wrap-up
- Anthropic's Claude Blog shared how it ran large-scale code migrations with Claude Code, including the process behind them.
- Bun (Zig to Rust): a million lines migrated in under two weeks, 100% of existing tests passing, 19 regressions all fixed, about $165,000 in API costs.
- Internal tool (Python to TypeScript): 165,000 lines migrated in one weekend, build time cut from 30 minutes to 2 seconds.
- The six-step process, rulebook, stress test, full translation, then compile/run/behavior matching, relies on adversarial review and mechanical verification.
- An open-source migration starter kit is now available too.
This one's for engineering leaders eyeing a legacy codebase they've been putting off, and for developers who want to see a real-world pattern for running AI agents at scale.