Anthropic Uses Claude to Migrate One Million Lines of Code in Two Weeks, Turning a Long-Delayed Language Rewrite into a Weekend Breakthrough

Technology17.Jul.2026 01:4910 min read

Anthropic has revealed how its engineering teams used Claude Fable5, Opus4.8, and dynamic workflows to migrate 10 large codebases within a month. Two standout projects included Bun's migration from Zig to Rust in under two weeks and Anthropic Labs' conversion of a 165,000-line Python codebase to TypeScript over a single weekend. The company also outlined.

Anthropic Uses Claude to Migrate One Million Lines of Code in Two Weeks, Turning a Long-Delayed Language Rewrite into a Weekend Breakthrough

In conventional software engineering, replacing the language of a mature codebase has usually been treated as a last resort. The reasons are familiar: multi-year timelines, substantial risk, and the burden of maintaining old and new systems in parallel while the migration drags on. Even when teams know their current stack no longer fits the product’s needs, many postpone the decision because the cost of moving feels too high.

Anthropic now argues that this calculus is changing. In a post published on July 16, the company said its internal developers used Claude Fable5, Opus4.8, and dynamic workflows over the past month to migrate 10 code packages to new languages. Those packages ranged from tens of thousands to hundreds of thousands of lines each. The broader takeaway is significant: AI-assisted language migration at large scale is no longer just a theoretical possibility, but something teams can execute and verify in practice.

From multi-year effort to weeks—or even a weekend

Anthropic highlighted two examples that show how dramatically timelines can shrink when the migration process itself is redesigned around AI.

Bun: roughly one million lines moved from Zig to Rust in under two weeks

Bun co-founder Jarred Sumner used Claude Code to migrate Bun from Zig to Rust. According to Anthropic, the process generated about one million lines of code in less than two weeks. Before the code was merged into the main branch, the full CI pipeline passed completely. After merging, the team identified 19 regressions, all of which have since been fixed. The Rust version shipped in June alongside Claude Code.

Anthropic Labs: Python to TypeScript over a single weekend

Mike Krieger, co-lead of Anthropic Labs, migrated a Python codebase into 165,000 lines of TypeScript over the course of one weekend. The effort relied on hundreds of agents, eight stage gates, and three rounds of adversarial review. To ensure the new implementation behaved the same as the old one, the team built a parity-checking system that compared each command’s output against the Python version line by line.

Anthropic’s framing is telling: the real challenge is not simply rewriting code, but fixing the process that produces the code.

Why teams may want to revisit language migration now

Most language migrations begin for the same reason: the tradeoffs that made sense when the project started no longer match the product’s current stage. In some cases, the old stack starts limiting performance or maintainability. In others, the ecosystem around a newer language becomes more mature while the older one loses momentum.

Bun is one example of that shift. Sumner originally chose Zig for its near-C-level performance and minimalism, which helped him build a product quickly as an individual developer before the era of large-model-assisted engineering. But as Bun expanded, the downsides of that choice became harder to ignore.

Anthropic notes that by 2026, Bun’s CLI had surpassed 10 million monthly downloads and was being used heavily inside Claude Code. Yet before AI entered the workflow, a migration still would have been difficult to justify. A project like this typically means freezing the roadmap, dedicating multiple quarters of engineering time, and accepting a very real chance of failure.

AI changes that risk profile. Anthropic’s view is that even if a migration attempt fails, the worst-case outcome may now be deleting a branch and starting over rather than absorbing years of sunk cost.

That does not mean these efforts are cheap. Bun’s migration reportedly consumed 5.9 billion uncached input tokens and 690 million output tokens, which Anthropic says would translate to about $165,000 at API pricing. Krieger’s migration used 27 million tokens. Still, the benefits can be meaningful enough to offset the expense.

In Krieger’s case, an internal tool had been distributed as a single binary. Using the Python toolchain, compiling for each platform took around eight minutes, and running the full build matrix required about 30 minutes. After moving to TypeScript, the same compilation took roughly two seconds, binary startup became six times faster, and one separate deployment pipeline was no longer needed.

Why AI is well suited to large-scale code translation

Anthropic argues that language migration lines up unusually well with what advanced models do best.

  • It can be parallelized naturally. Files, modules, or crates can be split across many agents working at the same time.

  • The context is already available. The existing codebase acts as the clearest possible specification for the target implementation.

  • Verification is objective. Compilers, test suites, and diffing tools can all serve as hard judges.

  • Failures generate the next tasks automatically. Compile errors, crashing smoke tests, and failing assertions immediately become repair work.

  • Rules can improve over time. Once an agent discovers how to handle an edge case, that knowledge can be turned into guidance for every agent that follows.

In these workflows, both Krieger and Sumner used Fable at critical points, especially its advisory mode, to coordinate different model tiers and reduce token consumption.

Anthropic’s six-step playbook for migration

From these projects, Anthropic distilled a reusable method that it says can apply across languages and codebase types.

Before anything else: build an uncompromising judge

The company’s first requirement is a unified validation system capable of judging both the original and the translated code. Existing tests are often tightly coupled to the internals of the old language and cannot be reused as-is. That means teams may need to sort, rewrite, and harden them before migration begins, with adversarial agents checking that the process did not weaken the tests.

During the Python-to-TypeScript move, Krieger built a parity harness covering seven real scenarios. Any behavioral mismatch was treated as a defect to be fixed.

1. Define the rules, map dependencies, list the gaps

At the outset, teams need a clear migration handbook, a dependency map, and a record of major language differences.

  • Rulebook: If the architecture remains the same, this functions like a translation guide between type systems and idioms. If the architecture changes, it becomes closer to a design document.

  • Dependency map: This identifies which files can be migrated independently and which must move together.

  • Gap list: This records fundamental mismatches between languages, such as manual memory handling differences in Zig versus Rust, or interface declaration requirements in Python versus TypeScript.

Anthropic said Sumner even assigned eight sub-agents to watch for recurring failure modes and use what they found to improve the rules.

2. Run a throwaway pilot migration

Before committing to the full codebase, Anthropic recommends a small experimental translation. The goal is not to make lasting progress, but to stress-test the method itself.

Sumner reportedly had different agents translate the same files using the draft rules, then compared the outputs to refine the guidance. This early pass also exposed two major issues before they became large-scale problems. Anthropic stresses that the artifacts from this phase should be discarded; what matters is the learning, not the code.

3. Move into a multi-agent implementation loop

Once the rules are stable enough, the main migration begins through a repeated cycle of implementation, review, and repair.

Lighter models can handle much of the translation work, while stronger models focus on review. Krieger used Claude Sonnet while 12 sub-agents were operating in parallel. Anthropic says the task queue should be deliberately mechanical: for example, the system can determine completion based simply on whether a target file exists on disk. That makes the workflow easy to resume after interruption.

When agents are uncertain, they do not need to solve everything immediately. They can leave explicit markers behind and let later compile, test, and repair stages deal with unresolved sections.

4. Compile and fix according to the error list

The compiler becomes one of the most important impartial judges in the process. How often teams compile depends on cost.

Krieger included the TypeScript compiler in every cycle because each run took only seconds. Sumner, by contrast, delayed Rust compilation until later because running cargo was more expensive. During Bun’s migration, once circular dependencies were addressed, thousands of Rust module errors surfaced. Anthropic says the team then created new classification logic to decide which errors required deletion, movement, or boundary refactoring before the issue count gradually came down.

5. Run smoke tests and tackle crashes or systemic failures

Smoke tests provide another source of mechanical truth. Crashes are grouped by root cause and then handed back to repair agents, along with adversarial reviewers, to prevent shallow fixes from slipping through.

6. Compare behavior line by line

After translation, compilation, and smoke testing, the final step is to verify that both codebases behave the same way. This is where the parity infrastructure built at the beginning becomes decisive. Any mismatch feeds directly into another repair loop.

Anthropic also suggests that later stages can introduce a dedicated build daemon to centralize expensive operations such as rebuilding binaries and rerunning affected tests, then report the results back to repair agents.

For teams without strong preexisting tests, Krieger had Claude write scripts that executed both old and new versions across seven real-world scenarios and compared the outputs. Each failing scenario then got its own repair agent until all cases passed. After that, Claude was asked to design an end-to-end test suite on its own and continue running and fixing issues over four consecutive nights.

Operational lessons Anthropic draws from the process

The company’s advice is practical and process-oriented rather than model-centric.

  • Do not obsess over individual failures. Single errors should flow through the loop; human attention is better spent identifying patterns.

  • Keep review adversarial and validation mechanical. Compilers, diff tools, and test scripts should do as much judging as possible.

  • Do not reserve every task for the largest model. High-volume implementation can be handled by smaller models, while stronger ones focus on rulemaking and review.

  • Invest human effort early. Building the rulebook and robust validation harness takes time, but it is what makes later automation effective.

  • Make the queue resumable. Completion should be defined through externally observable signals, such as whether target files have been created.

What the migrations delivered

According to Anthropic, Bun’s Rust migration is already in production. Around 4% of the Rust code still sits inside unsafe blocks, largely for one-line pointer operations at C/C++ boundaries, but the overall quality of the codebase has improved.

The company says tooling found and eliminated all memory leaks previously detected in the project. In one benchmark involving 2,000 repeated builds, memory usage dropped from 6745MB to 609MB. Binary sizes on Linux and Windows fell by 19%, and cross-language optimization produced speedups of 2% to 5% on real workloads including HTTP serving, next build, and tsc.

Anthropic’s larger point is that language migration projects long considered too disruptive to attempt may now deserve a fresh look. With AI agents, stronger test infrastructure, and dynamic workflows, massive rewrites are starting to look less like all-or-nothing bets and more like engineering processes that can be structured, measured, and managed.