r/ClaudeCode • u/erkamyaman • 1d ago
Built with Claude rust-anything: Claude Code ports your hot code to Rust, and it only ships if it behaves exactly like the original
Claude is good at writing Rust. What I didn't trust was "it compiles and the tests I have pass". So I built rust-anything around one rule: the port has to behave exactly like the original on recorded calls before it switches on.
https://github.com/erkamyaman/rust-anything
How it works with Claude Code:
rust-anything go --agent claude -- python3 app.py
- It profiles the run and picks the outermost function worth moving (the loop, not the tiny call inside it).
- It records what the original does: generated inputs plus the real calls your run makes.
- It generates the bridge and hands src/port.rs to Claude with a task file.
- diff replays every recorded case against the Rust. Claude iterates until they all match.
- gate checks the port isn't bloated (fails above 3x the original's lines), bench measures it, and only then is it switched on. One command switches it back off, byte for byte.
There's also a Claude Code plugin and MCP tools, so Claude can run analyze, diff and bench itself mid-session.
Some results:
- Fuse.js search: 91.2 ms to 2.8 ms per query over 50,000 strings
- json-server as one Rust binary: 74 MB to 3.5 MB idle, 514/514 recorded HTTP cases match
- ESLint: 10,585 recorded runs byte-identical
And where it doesn't help, it says so. I ported Google.Protobuf's C# size functions: 2,941/2,941 cases match, but it's about 33x slower, because those functions take 29 to 87 ns in .NET and every call crosses the bridge as JSON. bench flags that instead of letting you ship it.
Works for TypeScript/JavaScript, Python, C, Go, Ruby, Java, Kotlin, PHP and C#. MIT, runs locally.
https://github.com/erkamyaman/rust-anything
Happy to answer how the recording and the diff work, or where Claude gets stuck (async and callbacks stay in the original language on purpose).
•
u/AutoModerator 1d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/EconomyDoctor3287 1d ago
now we only need code that was working to begin with xD
13
u/ScreenPlayLife 1d ago
if you post this once more-
12
u/srs96 1d ago
Thanks I will port the hot part of my site which gets 10 weekly visitors
6
u/hanotak 1d ago
Stop spamming this everywhere, we get it.
1
u/NamerekDev 1d ago
Two of your numbers have a less pretty row in your docs. fuse is 32x on all 10 cores, 5.3x on one. json-server idles at 74 vs 3.5 MB with 6 posts in the db, with 10k posts it's 94 vs 41. Ok for a post i guess, but be more precise next time
1
u/mplaczek99 1d ago
"We will look at your career with great interest"
1
u/Vae-victus 1d ago
I've used this this last week to port some java spring apps as a proof of concept and it's worked great. These java "microservices" were using more than 600mb ram each for performing basic shit and in rust now some of them use as low as 15mb ram
-3
u/Ragy-ragy 1d ago
Why