Anthropic published a six-step method for running large code migrations with Claude Code, built from two internal ports: a Zig-to-Rust rewrite of the Bun JavaScript runtime and a Python-to-TypeScript conversion. Rather than asking one model to translate files sequentially, the method treats a migration as a pipeline where separate agents draft, review, and mechanically verify the output.
The first step produces three artifacts before any code moves: a rulebook of translation rules, a dependency map ordering which files migrate together, and a gap inventory of behavior the old language allowed implicitly that the new language requires explicitly. On the Bun project, that gap was manual memory management. Zig lets a function return a buffer the caller must remember to free; Rust’s ownership model catches that mistake at compile time instead of leaving it to a runtime crash. Anthropic says the rulebook has to come first because its own defaults determine which behaviors end up in the gap inventory at all.
Before scaling up, the team runs a small dry run against a handful of files. On the Bun port, one agent translated a batch using the draft rulebook, a second translated the same batch relying on general language expertise instead, and a third diffed the two outputs to surface where the rulebook broke down. That single check caught two critical issues before they could spread across the project’s 1,448 files. Every file touched during this step gets discarded afterward; the goal is fixing the rules, not banking progress.
The remaining steps repeat one loop: implement, review, fix. Anthropic split model tiers by role, routing the high-volume translation work to smaller, cheaper models while reserving its largest model for reviewers and for edits to the rulebook itself. Two independent reviewer agents check each batch on separate contexts, and a third agent breaks any tie. A mistake that keeps recurring across files doesn’t get patched file by file. It gets written into the rulebook once, and only the affected batch gets regenerated.
Verification stays mechanical throughout. A compiler run, a test-suite diff, and crash logs from smoke tests each feed their own fix queue, and a task counts as done only when its output file exists on disk, a rule that makes the whole migration resumable if it stops partway through. The Python-to-TypeScript project lacked a portable test suite entirely, so Claude built one: a seven-scenario parity harness first, then a self-designed end-to-end suite that ran unattended overnight for four consecutive nights.
The results Anthropic disclosed favor the structured approach over ad hoc rewriting. The finished Bun migration cut peak memory across 2,000 repeated builds from 6,745 MB to 609 MB, shrank the binary 19 percent on Linux and Windows, and gained 2 to 5 percent in speed on workloads like next build and tsc. About 4 percent of the resulting Rust code still sits inside “unsafe” blocks, mostly single-line pointer operations at C and C++ boundaries, a caveat Anthropic chose to disclose rather than omit.
The mechanism worth studying here is not the step count. It is where judgment gets concentrated: writing the rulebook, resolving reviewer disagreements, and defining what counts as a gap all stay with a small number of expensive model calls, while the error-prone work of translating thousands of files goes to cheaper agents boxed in by adversarial review and a referee that never negotiates, a compiler or a test suite. Most human-led migrations invert that allocation, pulling senior engineers into line-by-line translation while junior staff inherit architectural decisions by default.
For enterprises sitting on a legacy Python 2 service, an unsupported framework, or a codebase everyone has agreed not to touch, the transferable lesson is not the specific tool. It is that a migration only scales once something other than a person eyeballing a diff can declare success, whether that referee is an inherited test suite or one an agent builds first. Anthropic has posted a starter kit and a code-modernization plugin on GitHub for teams that want to pilot the process before committing headcount to a full rewrite.
Anthropic detailed the six-step migration process, including the Bun Zig-to-Rust results, in a post to the Claude blog.