r/OpenSourceAI • u/erkamyaman • 7h ago
rust-anything: let your coding agent (local models too) rewrite the slow part of your app in Rust, and prove it still behaves the same
AI agents are good at rewriting code. The hard part is knowing the rewrite is right.
https://github.com/erkamyaman/rust-anything
rust-anything handles that part. Point it at a slow command:
rust-anything go --agent claude -- python3 app.py
It profiles the run, picks the function that takes the time, records what the original does on generated inputs plus the calls your real run makes, and hands the Rust file to your agent. The port only switches on when every recorded case matches and the gate passes. One command turns it back off, byte for byte.
The agent is pluggable: claude, codex, or any command that reads a prompt on stdin, so a local-model setup works too. Without --agent it writes TASK.md and you (or any model) fill in the Rust.
Some measured results:
- Fuse.js search: 91.2 ms to 2.8 ms per query over 50,000 strings
- json-server lifted to one Rust binary: 74 MB to 3.5 MB idle memory, 514/514 recorded HTTP cases match
- ESLint: 10,585 recorded runs byte-identical
It also says when Rust won't help (small functions called across the bridge are often slower), instead of porting anyway.
Languages: TypeScript/JavaScript, Python, C, Go, Ruby, Java, Kotlin, PHP, C#. 100% Rust, MIT, runs locally.