source: simon willison: rewriting bun in rust
level: technical
jarred sumner rewrote bun, a javascript runtime originally in zig, into rust using ai-powered coding agents. the project took 11 days and was driven by persistent memory management bugs in zig, such as use-after-free and double-free errors. safe rust's compiler checks and automatic cleanup with drop eliminated these issues. the existing typescript test suite served as a conformance suite, allowing agents to automate the port while ensuring correctness.
the rewrite used anthropic's claude models, with an estimated api cost of $165,000. the process involved 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input token reads. sumner monitored agent workflows, used adversarial code review, and fixed the code generation process rather than manually editing the output. the new rust-based bun has been live in claude code since mid-june 2026, with a 10% faster linux startup and no major issues.
this case study shows how modern ai agents can tackle large-scale software rewrites that were once considered too risky. by combining a comprehensive test suite, agentic workflows, and rigorous review, the team merged over a million lines of ai-generated code with confidence. the approach challenges the old rule against rewriting software from scratch, demonstrating that ai assistance can make such projects feasible and reliable.
why it matters: it shows how ai agents can safely automate large code migrations, reducing bugs and development time for critical software infrastructure.