erkamyaman/rust-anything
Rewrite your whole app in Rust, one piece at a time, checked against the original's recorded behavior at every step. CLIs, HTTP servers and libraries in TypeScript, Python, C, Go, Ruby and Java.
rust-anything is a developer tool that helps you rewrite an existing application in the Rust programming language — but instead of doing the rewrite all at once (risky, slow, often abandoned), it lets you do it piece by piece, verifying each piece against the original behavior before moving on.
The core idea:
Record — Run your original app (Node.js, Python, C, Go, Ruby, Java, and previews for PHP and C#) on a set of test inputs. The tool captures what the app returns or throws for each case, saving it as a recording.
Port — You (or your coding agent like Claude Code, Codex, Cursor, or Gemini CLI) write Rust code to replace one function, one file, or one module at a time. The tool does not translate code for you — it provides the scaffolding, the bridge so the rest of your app can call the Rust code with the same API, and the test cases.
Verify — The tool replays every recorded case against your Rust code. If all cases match, the port is proven correct. If not, it shows you the mismatches.
Ship — Once a piece passes, you can wire it into production, optionally running both versions side-by-side ("shadow mode") to catch anything the recording missed.
Why it's useful:
- Speed — Rust is often much faster. The README shows real benchmarks: a TypeScript search went from 10 ms to 0.5 ms (20x faster), a Python slugify from 98 ms to ~5.8 ms (17x), a Ruby shellescape from 88 ms to ~7.5 ms (11.8x).
- Safety — The original stays the source of truth. Nothing ships until every recorded case matches.
- Incremental — You can port just the slow hot path, not the whole app. Or port everything, one unit at a time.
The workflow (simplified):
profile → analyze → bridge → record → port.rs → diff → bench → shadow → gate
profile— finds where time is actually spent (hot functions, loops worth moving).analyze— plans what to port first, in what order, and flags risks.bridge— generates the Rust crate with bindings and stubs, so the rest of your code can call Rust with the same API.record— runs the original on edge cases (emoji, NaN, negative numbers, overflow, etc.) and saves the results.diff— replays those cases against your Rust code; must match 100%.bench— times both versions to give a verdict on speed.shadow— runs both in production, returns the original's result, logs mismatches.gate— the final check: formatting, linting, tests, no unsafe code, no panics where the original returns errors — only then is a port "done."
Whole-app porting:
For porting an entire application (not just one function), there are extra commands:
app record— records the whole app's behavior from its documented examples (like$ mytool ...lines in READMEs) and generated edge cases.app replay— runs any build against those cases and reports pass/fail.app front-door— creates a Rust binary that starts by running the original, then gradually hands commands to Rust as each unit is ported.app wire— connects a ported unit into the Rust front door.app lift— when everything passes with zero fallbacks, removes the original from the loop, leaving pure Rust.
Installation:
cargo install rust-anything(from crates.io)npm install -g rust-anything(for JavaScript projects)- Prebuilt binaries for macOS, Linux, Windows on GitHub releases
rust-anything setupregisters it with Claude Code, Codex, Cursor, and Gemini CLI (adds an MCP server and a skill).
What it can't catch:
The tool only verifies what the recording covers. If your test cases don't exercise a particular behavior, mismatches there won't be caught. The README explicitly warns about this.
Status:
- Full support: TypeScript/JavaScript, Python, C, Go, Ruby, Java
- Preview: PHP and C# (can record/replay whole apps, but porting individual units into Rust is still in development)
- License: MIT
- Independent project, not affiliated with the Rust Foundation.
In one sentence: rust-anything is a safety net for incremental rewrites — it records what your app does today, checks every Rust replacement against that recording, and only lets you ship when behavior matches exactly.
Related
- Project
- Project
- Project
- Project