For decades, the great rewrite has been the most feared project in software engineering. The prospect of migrating millions of lines of code from one language to another usually implies years of manual labor, an endless cycle of regression bugs, and a high probability of project abandonment. Developers are accustomed to the grueling process of porting logic line by line, hoping that the nuanced behaviors of the source language are captured in the target. However, a recent series of experiments by the Anthropic development team suggests that the era of manual porting is ending, replaced by a high-throughput automation loop that treats code not as a text to be translated, but as a system to be regenerated.
The Scale of Automated Migration
Over the past month, Anthropic has deployed a sophisticated orchestration of Claude Fable 5, Claude Opus 4.8, and dynamic workflows to migrate ten separate packages, ranging from tens of thousands to hundreds of thousands of lines of code. The most ambitious of these efforts involved the migration of Bun from Zig to Rust. In less than two weeks, the system generated 1 million lines of code. This was not a simple one-to-one mapping but a structural overhaul executed at a speed that would be impossible for a human team. In a separate project, the team migrated 165,000 lines of code from Python to TypeScript over a single weekend.
The computational and financial investment required for this level of automation is significant. The Bun migration consumed 5.9 billion uncached input tokens and 690 million output tokens. Based on current API pricing, the total cost for this single operation reached approximately $165,000. In contrast, the core phase of the Python-to-TypeScript migration was more lean, utilizing 27 million tokens. To manage this volume, Anthropic deployed hundreds of agents operating across an eight-stage gate system, supported by a three-tier adversarial review process to ensure the integrity of the generated code.
From Manual Patching to Rule-Based Loops
The fundamental shift in this approach is the abandonment of manual code correction. In a traditional migration, a developer finds a bug in the ported code and fixes it. Anthropic's loop operates on a different premise: if the code is wrong, the rule that generated the code is wrong. The pipeline begins with the preparation of judgment criteria, followed by the creation of a rulebook, a dependency map, and a list of differences between the languages. These rules are then stress-tested before the full translation begins. The rulebook acts as a living design document, while the dependency map allows the system to handle files in parallel without breaking structural relationships.
To optimize token spend and maintain quality, the team implemented a tiered advisory pattern. Bulk implementation is handled by smaller, faster models like Claude Sonnet. In the Bun case, 12 sub-agents worked in parallel to generate the bulk of the Rust code. The high-level oversight, including the creation of the primary rulebook and the final review of complex logic, was reserved for larger models like Fable 5 and Opus 4.8. To prevent hallucinations and logic gaps, the system employs two adversarial reviewers with independent contexts. If these two reviewers disagree on the validity of a code block, a third agent is brought in to act as the final arbiter.
Verification is driven by a mechanical equivalence harness. When a compilation error or a test failure occurs, the system does not treat it as a local bug. Instead, it flags the failure as a defect in the high-level rulebook. The system then modifies the rulebook and regenerates the entire affected batch of code. For the Bun migration, this was validated using a massive TypeScript-based test suite, ensuring that 100% of existing tests passed before merging. In the Python migration, the team tracked behavioral changes across seven real-world usage scenarios to ensure parity.
This methodology yielded dramatic infrastructure improvements. The Rust port of Bun saw memory usage plummet from 6,745MB to 609MB across 2,000 benchmark iterations. The binary size was reduced by 19%, and actual workload performance improved by 2% to 5%. However, the migration also revealed the inherent constraints of the target language; approximately 4% of the resulting Rust code required `unsafe` blocks to handle pointer operations at the C/C++ boundary. Similarly, the Python-to-TypeScript migration reduced binary generation time from 8 minutes to 2 seconds and increased binary startup speed by six times.
For engineers looking to implement this loop, the critical challenge lies in the design of the judge. Tests that rely on the internal functions of the source language will fail after a port because those internals no longer exist. Therefore, tests must be rewritten as external call-based assertions. Furthermore, the team emphasizes the necessity of stress-testing rules on a small subset of files to eliminate architectural flaws before committing to a full-scale migration.
Software development is shifting from the act of writing lines to the act of governing rules. When chronic memory leaks or build bottlenecks persist for years, the technical justification for a total language migration now exists, provided the organization is willing to trade API costs for systemic architectural health.




