How Anthropic Ported a Million Lines of Code in 2 Weeks With Claude Code

Anthropic just published the actual playbook their teams use to run massive code migrations with Claude Code — and the headline number is wild: a full million-line Zig-to-Rust rewrite of Bun, done in under two weeks, with 100% of the test suite passing before merge.

Anthropic just published the actual playbook their teams use to run massive code migrations with Claude Code — and the headline number is wild: a full million-line Zig-to-Rust rewrite of Bun, done in under two weeks, with 100% of the test suite passing before merge.

What They Actually Did

This isn't a vague "AI helped us code" post — it's a six-step methodology anyone running a big migration can copy:

  • Build a rulebook, dependency map, and gap inventory before touching real code
  • Stress-test those rules on small mini-migrations first
  • Translate the rest of the codebase using the proven rules
  • Compile and let errors drive the next round of fixes
  • Run smoke tests
  • Verify behavior actually matches the original code, not just "it compiles"

Individual developers used this to migrate 10 different code packages (tens of thousands to hundreds of thousands of lines each) using Claude Fable 5 and Claude Opus 4.8 together with parallel "dynamic workflows." A separate example: one dev ported 165,000 lines of Python to TypeScript over a single weekend using about 27 million tokens.

The Bun Numbers

  • 1 million lines of Zig ported to Rust in under 2 weeks
  • 5.9 billion uncached input tokens, 690 million output tokens — roughly $165,000 in API cost
  • Only 19 regressions found after merge, all fixed
  • Memory usage dropped from 6,745 MB to 609 MB, binaries 19% smaller, 2-5% faster

Anthropic also released a migration starter kit and a code-modernization plugin on GitHub if you want to try the pattern yourself.

Watch Out

  • This is not cheap — $165k in tokens for a million-line migration. Scale your expectations to your codebase size.
  • You need real test coverage (or the ability to build verification harnesses) or you can't trust the "it works" signal
  • About 4% of Bun's migrated code still needed hand-marked "unsafe" blocks — this isn't 100% hands-off
  • Anthropic's own framing: don't migrate languages just because you can — you need a real bottleneck driving the decision

Key Takeaways

  • Front-load your human effort into the rulebook and stress-test steps — the later steps run mostly on autopilot
  • Use cheaper/faster models for the bulk grunt-work translation, and save the bigger model for writing rules and reviewing output
  • Let mechanical signals (compiler errors, failing tests) drive the next fix instead of hand-patching files one by one
  • Build work queues that check disk state so a crash doesn't lose progress

Source

How Anthropic runs large-scale code migrations with Claude Code


Source: claude.com

We break down Claude Code news like this every day in the free community. Join the crew on Skool.