← all news

How Anthropic runs million-line code migrations with Claude Code

AI · · · source (claude.com)

Anthropic published how it runs large code migrations with Claude Code, using two real projects as evidence. The first is the port of Bun, the JavaScript runtime, from Zig to Rust: about a million lines of code produced in under two weeks, with all of Bun's existing tests passing in CI before the merge. That run consumed 5.9 billion input tokens and 690 million output tokens, roughly $165,000 at API pricing. The Rust version also came out faster and leaner, with memory in one benchmark dropping from 6,745 MB to 609 MB and the binary 19% smaller. The second was an internal Python to TypeScript migration, where one engineer moved 165,000 lines over a weekend using hundreds of agents, eight phase gates, and three rounds of adversarial review.

The method is a six-step loop rather than a single prompt. You start by writing a rulebook of translation guidelines and mapping dependencies, then stress-test the approach on sample files to catch systemic problems early. Translation runs in parallel batches, with smaller models doing the implementation and larger models reviewing, and uncertain work flagged with TODO comments. The final steps compile, run smoke tests, and check behavioral parity against the original. Two practices carry the weight: reviewers run in separate contexts so they judge the code fresh, and the work queue is mechanical and resumable, keyed on whether a file already exists, so fixer agents can grind through compiler errors in a loop instead of a person hand-patching each failure. The full write-up is at claude.com.

Why it matters

If you are staring at a legacy codebase you have wanted to move off for years, the cost math just changed: the blocker is now writing a good rulebook and a parity test, not the line-by-line labor. The published token bill and step list give you a concrete template to estimate your own migration before committing to it.

AnthropicClaude CodeAgentsEngineering