Inside Anthropic's agent-driven Python to Rust rewrite for Claude
- Python to Rust migration: Anthropic rewrote the Claude Messages API from Python to Rust to keep backend performance fast.
- Live traffic verification: The initial AI-generated Rust port passed 98% of unit tests while matching only about 24% of live production behavior.
- Autonomous bug fixing: An orchestrator agent grouped thousands of shadow traffic mismatches so Claude agents could systematically resolve parity bugs.
- Broader speed push: Alongside the backend rewrite, Anthropic is slashing token overhead with Code Mode and scaling internal workflows with Scion.
How the Rust rewrite worked
- Core API overhaul: Anthropic engineering lead Alex Michael detailed the migration architecture behind moving the Claude Messages API from Python to Rust.
- Shadow traffic replay: Engineers used the legacy Python service as a live-traffic verifier to compare real production behavior against the new Rust code.
- Orchestrated parity fixes: An orchestrator agent grouped thousands of recorded output differences into root-cause categories so Claude agents could fix issues like misread context limits and missing tool descriptions.
Why unit tests were not enough
- The 98% test trap: Developer analyses highlighted how the initial AI-generated Rust code passed 98% of unit tests yet matched only around 24% of actual live production behavior.
- Designing outer loops: Creator Ray Amjad analyzed how Anthropic structured inner, outer, and memory loops to keep autonomous agents effective during the rewrite.
- Guardrails over syntax: Engineers note that modern backend migrations now focus less on manual syntax translation and more on shadow traffic recorders, strict guardrails, and evaluation suites.
Other speed upgrades across Claude
- Code Mode cuts tokens: Instead of calling MCP tools one by one, Claude writes small scripts to run them—cutting token use by more than half in user sessions and nearly 99% in Anthropic engineering demos.
- AI-first version control: Anthropic also built Scion to handle the demands of its fast-moving, AI-heavy internal engineering workflow.
- Community Rust tooling: Echoing the rewrite pattern, open-source Claude Code skills like fast-anything now profile Python apps, rewrite slow functions in Rust, and replay up to 500 real calls.
💬 Notable Signals
“Anthropic's Rust Rewrite is a Masterclass in Agentic Engineering”
“initial Rust code passed 98% of tests while matching only ~24% of actual live production behavior”
“Anthropic's engineers cut Claude's token use by almost 99% on the same task, with the same tools and model.”