How Claude Rewrote Bun in Rust in 11 DaysA technical deep dive into Bun’s million-line Zig-to-Rust migration, Anthropic’s agent workflow, the risks of AI-generated rewrites, and what enterprise engineering teams should learn from it.New Benchmark Results: Checkmarx Leads the Way (Sponsor)Independent benchmark testing found Checkmarx achieved the industry’s highest scanning fidelity. Read the full press release to learn how it outperformed both traditional security tools and AI-based models. For decades, migrating a production system from one programming language to another was treated as one of the riskiest projects in software engineering. A language migration could freeze a product roadmap, create two partially compatible codebases and consume years of engineering time. Even after all that work, a team might reach only 90% behavioral parity—leaving the organization with more complexity than it had before. That calculation is beginning to change. Anthropic says its developers recently migrated 10 code packages, ranging from tens of thousands to hundreds of thousands of lines, using Claude Code and multi-agent workflows. The most dramatic example was Bun, a widely used JavaScript runtime and toolkit that was ported from Zig to Rust in 11 days. Another internal Anthropic project reportedly moved a Python codebase to approximately 165,000 lines of TypeScript over a weekend. These projects do not prove that enterprises can now point an AI agent at any legacy codebase and safely rewrite it over a weekend. However, they reveal something more important:
The differentiator is no longer how quickly an agent can write code. It is whether the organization can build a deterministic system for specifying, reviewing, testing and rejecting that code. The Bun Rewrite Was Not a Typical “Vibe Coding” ProjectBun began as a JavaScript and TypeScript runtime written primarily in Zig. By 2026, its command-line tool was receiving more than 22 million monthly downloads and had become part of the runtime infrastructure behind tools including Claude Code. The decision to move to Rust was driven largely by memory-safety and lifecycle-management problems. Bun combines a garbage-collected JavaScript engine with manually managed native memory. Its maintainers had encountered recurring use-after-free errors, double frees, memory leaks and problems involving native objects whose lifetimes crossed JavaScript callbacks. Zig supported the performance and low-level control Bun needed, but cleanup frequently depended on developers placing the correct Rust offered a different failure model. Its ownership system, borrow checker and automatic Historically, however, rewriting more than 535,000 lines of Zig would have required a small team working for around a year. That would have meant slowing feature development, bug fixes and security work while maintaining a long-running migration branch. Instead, Bun founder Jarred Sumner used roughly 50 dynamic Claude Code workflows, eventually running as many as 64 agents across four worktrees. The system produced more than one million added lines, generated 6,502 commits and reached a peak output rate of approximately 1,300 lines per minute. The port consumed 5.9 billion uncached input tokens, 690 million output tokens and 72 billion cached input-token reads. Anthropic estimated the total at around $165,000 using public API pricing. That is best understood as a list-price comparison rather than an independently audited cash cost to Anthropic. The important point is not that the AI wrote one million lines. Writing the first version was only one stage of the project—and, according to Sumner, none of the generated code worked when the initial translation wave finished. The real engineering achievement was the construction of a loop that repeatedly turned failures into structured work. Traditional Migration Versus Agent-Driven MigrationThe traditional workflow treats the rewritten code as the primary artifact. The agent-driven workflow treats the migration system as the primary artifact. The code is an output that can be deleted and regenerated whenever the rules prove incomplete. That distinction changes the economics of failure. A flawed three-month manual implementation creates enormous sunk cost. A flawed AI translation batch may be discarded after correcting one paragraph in the rulebook. The Six-Stage System Behind Large AI Code MigrationsAnthropic generalized the lessons from Bun and its internal Python-to-TypeScript project into a six-stage process. First, build a judgeBefore any translation begins, the team needs a judge capable of evaluating both implementations on equal terms. This requirement is easy to underestimate. Tests written in the source language may call internal functions, inspect implementation-specific objects or depend on module boundaries that will not exist after the migration. The useful tests are those that evaluate externally observable behavior:
|