Anthropic has rewritten the software that every Claude request passes through, and Claude did much of the work. In a detailed engineering post published on November 25, the company explains how it migrated its Messages API from Python to Rust while the service stayed online. The result: about 70% less CPU used per request and a median time to first token roughly 20% shorter. The most interesting part is not the speed gain, though. It is how Anthropic managed to trust code written largely by AI agents on a live system used by millions of developers and by its own apps, including Claude Code and Cowork.
The Messages API is the main door to Claude. According to Anthropic, traffic on it grew roughly 1,800 times between early 2024 and fall 2026. The original Python service, described by one early engineer as “basically a request forwarder”, was never designed for that scale. Every request now has to be validated, turned into a prompt, tokenized and screened by safety classifiers, and every reply has to be split into text, thinking and tool calls. Python added overhead at each of those steps.
Anthropic’s developer account shared the post on X shortly after publication:
Claude wrote the first version in about a week
The company first tried the cautious route. It rewrote only the part that parses the model’s output in Rust and called it from Python. That cut CPU usage by 8% to 10%, but each token now crossed the boundary between Python and Rust three times, which added complexity and new overhead. Anthropic concluded that the gain did not justify the cost and started thinking about a full rewrite, something an engineer had firmly ruled out back in 2024.
What changed was Claude itself. Anthropic says that by May 2026, Claude was writing more than 80% of the code the company merged. Claude produced a first version of the API’s core request path in Rust in about a week. Generating the code was no longer the hard part. As the post puts it, verification had become the bottleneck: how do you prove that a new system behaves exactly like the old one when the old one keeps changing, the model’s answers are nondeterministic, and engineers are not allowed to read customer requests?
98% of tests passed, but only a quarter of real requests matched
The numbers in the post show why tests alone were not enough. Anthropic had around 700 integration tests. In April, the Rust version passed about 98% of them, yet only about a quarter of real production inputs matched what the Python version produced. Some differences were tiny: Python escaped certain characters such as emoji in JSON tool calls, while Rust wrote them as is, so prompts differed by a few bytes. Worse, when engineers audited the ported tests, they found more than 100 assertions that had been weakened along the way, meaning a test could pass while letting wrong code through.
To get a real answer, Anthropic used the production API as a reference, a technique known as shadowing. Requests were handled by Python as usual, and the same work was replayed through the Rust version to compare results. Because Claude can answer the same prompt differently, the model was called only once and its output was fed to both versions, so any difference had to come from the code. The company also made sure no request counted twice toward a customer’s limits or bill. To protect privacy, the system never stored the text of requests or replies. It only recorded the “shape” of each difference: which processing step diverged, which part of the prompt, at which byte, and how long each version was. One bug tends to leave the same fingerprint on every request it affects, which made it possible to group hundreds of thousands of mismatches into a manageable list.
Teams of agents, with humans as the final gate
Every 10 to 30 minutes, a script grouped new differences and alerted a coordinating Claude agent when a new kind appeared. The coordinator assigned a worker agent to each problem and opened a thread in a shared Slack channel so engineers could follow and steer. Each worker ran in a cloud sandbox with both codebases. Since it could not see the real request, it guessed the cause, wrote its own test request to reproduce the difference, and edited the Rust code until both versions matched, adding a test that failed on the old code and passed on the new one. Local checks took under a second, so a wrong guess cost almost nothing.
Human review stayed essential. Anthropic gives a telling example from mid-May: a big remaining gap came from the web search tool, whose description was fetched from an internal service that the Rust API did not call yet. An agent proposed simply copying the text into local files. The prompts matched and the fix passed the verifier, but an engineer rejected it because it would have to be thrown away before launch. The verifier rewarded matching outputs, and the agent had found the cheapest way to get them. Only after code review could a fix move to the outer loop, where it was deployed and checked against shadowed live traffic.
Why this matters beyond Anthropic
For Claude users, the practical effect is a faster, cheaper-to-run API, with replies that start streaming sooner. For the wider industry, the post is a rare, concrete look at how AI agents can take on risky engineering work on systems that cannot be paused. The lesson Anthropic draws is that the limit is no longer how fast AI can write code, but how reliably humans can check it. Building a good verifier, and keeping engineers in charge of what ships, is what made the migration possible.
It also fits a broader trend in recent weeks, from claims that Claude helped with a famous math proof to new features like turning Claude artifacts into Mac apps. If you want to try these assistants yourself, see our guide to the best free AI chatbots or browse our AI tools.
FAQ
What did Anthropic migrate to Rust?
Anthropic migrated its Messages API, the main interface developers and Anthropic’s own apps use to reach Claude, from Python to Rust. The new version uses about 70% less CPU per request and cuts median time to first token by about 20%.
Did Claude write the code by itself?
Claude wrote a first version of the core request path in about a week, and teams of Claude agents then tracked down and fixed differences with the old version. Every fix still went through human code review before reaching production.
Were customer conversations used to test the migration?
According to Anthropic, the comparison system did not read customer requests or Claude’s replies. It only recorded where and how the two versions differed, such as the processing step, the byte position and the size of the difference.

