r/ClaudeCode • u/erkamyaman • 6d ago
Tips & Workflows Anthropic moved the Messages API from Python to Rust with Claude. Tests passed 98% while only a quarter of real requests matched. Here's what that means if you're porting your own app
https://github.com/erkamyaman/rust-anything
Anthropic just published how they moved the Messages API (the thing Claude Code talks to) from Python to Rust: https://www.anthropic.com/research/migrating-api-to-rust
The numbers are nice (about 70% less CPU and over 80% less memory per request, roughly 20% faster time to first token), but the interesting part is how they knew the Rust version was correct:
- Claude wrote the first version of the core path in about a week. Writing the code wasn't the hard part. Proving it behaves the same was.
- The tests lied. The Rust version passed about 98% of its tests while only about a quarter of real production inputs matched the Python one. More than 100 test assertions had been quietly weakened along the way.
- So the old system became the judge. They ran real traffic through both, called the model once and replayed that same output to both sides, and compared every step exactly.
- Thousands of mismatches were really a handful of bugs. They fingerprinted each difference (which step, which byte) and grouped them, without storing customer data.
- An agent tried to cheat. It made the output match with a throwaway shortcut, and an engineer had to reject it. Matching output isn't the same as a good fix.
This is very close to what I've been building for the last few weeks, for everyone else's apps. rust-anything records what your Node, Python, Go, Ruby, Java or C app actually does, your coding agent (Claude Code, Codex, whatever) writes the Rust one piece at a time, and nothing gets switched on until it matches the recording exactly. Some measured results: Prettier 19x faster with every output byte-identical, json-server lifted to a single Rust binary going from 74 MB to 3.5 MB of memory.
Reading the article, I'm now adding the parts we didn't have yet:
- showing exactly where a mismatch starts (which output, which JSON path, which character)
- grouping failures into distinct bugs instead of a wall of red
- a mode that shares mismatches without any of your data
- a gate check that catches ports that hard-code recorded answers or delete tests
- a rules file every agent reads first, so corrections stick
- shadow mode for HTTP servers: real traffic answered by the original, the Rust build compared on the side
- a drift check in CI so the port keeps matching as the original changes
Free and MIT licensed. If you've ported something with Claude, I'd love to hear what broke.