The open-source tool rust-anything introduces a safe, stepwise path to port existing apps to Rust with automated behavior verification: your original business logic and code structure (AST — Abstract Syntax Tree) remain 100% intact, while Prettier formatting speeds up 19x.
In software engineering circles, “Rewrite it in Rust” has long been a staple meme. Yet behind the humor lies an unavoidable production reality: heavy interpreted scripts and CLI utilities in Node.js or Python inevitably hit a hard runtime performance wall. But for tech leads, the biggest nightmare of rewriting a core service isn’t the steep Rust learning curve or the borrow checker — it’s the paralyzing fear of subtly breaking dozens of hidden edge cases accumulated over years in legacy code.
Below, we break down how the “digital twin” architecture in rust-anything works, how to pair it with autonomous AI agents like Claude Code, and where this migration delivers genuine ROI.

1. Real Benchmarks: Turning Minutes into Seconds
To stress-test the concept, the author of rust-anything chose benchmark tools where every millisecond matters and zero behavioral drift is tolerated: the ubiquitous code formatter Prettier and the fuzzy-search engine Fuse.js.
Prettier makes the ultimate proving ground. It is an opinionated code formatter that doesn’t just shuffle whitespaces; it completely reconstructs code according to strict line-length rules while strictly guaranteeing Abstract Syntax Tree (AST) preservation. Any behavioral discrepancy in a rewrite would immediately corrupt production code for thousands of engineers.
| Tool / Task | Original (JS) | Rust Native | Speedup |
|---|---|---|---|
|
Prettier 2,360 files |
128.6 s Node.js |
6.9 s Rust |
⚡ 19x 18.6x faster |
|
Fuse.js 50k lines |
1.42 s JavaScript |
0.044 s Rust |
🚀 32x faster |
The gap stems directly from runtime architecture. Node.js V8 has achieved extraordinary milestones with JIT compilation, but AST interpretation, Garbage Collection pauses, and dynamic typing overhead cannot match a native Rust binary compiled down to bare-metal machine code via LLVM.
The difference between a 2-minute wait and 7 seconds is the difference between an annoying Git pre-commit hang and a frictionless IDE response that developers don’t even register.
2. The Digital Twin Principle: Record → Reimplement → Verify
The traditional “Big Bang Rewrite” fails in roughly 90% of software projects, causing blown deadlines and nasty regression bugs. Legacy code is filled with implicit domain knowledge and idiosyncratic bugfixes long forgotten by the original authors.
rust-anything provides a pragmatic black-box pipeline for incremental refactoring:
- Record Phase (Behavioral Snapshot): The tool wraps the original runtime (e.g. Node CLI or Python script) and runs it across your existing test suites and real fixtures. It logs CLI arguments, standard streams (
stdin,stdout,stderr), exit codes, and filesystem mutations into an immutable baseline dataset. - Reimplement Phase (Incremental Porting): A developer or an autonomous coding agent re-implements the logic in Rust, module by module.
- Verify Phase (Automated Arbitration): Running
rust-anything verifyreplays the recorded inputs against the new Rust binary. If the output files or AST structures diverge by even a single character, the tool outputs an exact diff pinpointing the broken test case.
No guesswork: when your Rust rewrite passes 100% of the original runtime’s recorded behavioral tests, you have identical functionality with zero regression risk — running an order of magnitude faster.
3. Supported Tech Stacks and Workloads
While the Prettier benchmark grabbed the spotlight in the JavaScript community, the architecture is language-agnostic. rust-anything supports a broad range of source stacks:
- TypeScript & JavaScript (CLI formatters, linters, bundlers, and AST tools);
- Python (data processing pipelines, compute-heavy scripts, background workers);
- Go, Java, Ruby, C (network daemons, utilities, and microservices).
Whether you’re porting command-line utilities, HTTP microservices, or shared dynamic libraries, you can isolate compute-heavy hotspots and move them to native code without touching outer infrastructure.
4. Synergies with AI Agents: Closed Feedback Loops
The real leap in engineering velocity occurs when connecting modern AI coding agents: Claude Code, Codex, Cursor, or OpenCode.
The classic limitation of LLMs writing Rust is hallucinating plausible yet brittle code that stumbles over rare edge cases. Pairing an agent with rust-anything creates a closed autonomous feedback loop:
# 1. Record baseline behavior from the original project against real test fixtures
rust-anything record --cmd "node ./bin/prettier.js --write ./fixtures/**/*.js"
# 2. The AI agent (e.g., Claude Code) iterates autonomously:
# cargo check -> rust-anything verify -> inspect diff -> fix divergence
# 3. Final verification pass before merging
rust-anything verify --target ./target/release/prettier-rs
When verify outputs a precise failure diff, the agent autonomously self-corrects until the entire test matrix turns green. We previously examined how to build these zero-friction workflows in our guide on automation with Claude Code.
5. An Honest Engineering Perspective: Trade-offs & Limits
Beyond the excitement of 19x and 32x speedups, senior engineers must consider real-world operational constraints:
- Rust isn’t generated by magic:
rust-anythingis a verification test harness, not a transcompiler. System design, memory layouts, and logic implementation must still be authored by engineers or supervised AI agents. - CPU-Bound vs. I/O-Bound Realities: If your bottleneck is code parsing, data compression, cryptography, or AST traversal, Rust yields immediate 10x-20x gains. But if your application spends 95% of its wall time waiting on PostgreSQL queries or external APIs, compiling to native code won’t make the network latency disappear.
- Reliability is strictly bounded by test coverage: The tool only validates what was captured during the Record phase. If edge cases (such as exotic Unicode surrogate pairs) were absent from initial test runs, those blind spots will quietly carry over into the Rust port.
Nonetheless, the industry shift toward native systems tooling is unmistakable: from ultra-fast headless browsers like Obscura written in Rust to the next-gen web toolchain (Biome, Oxc, Turbopack, Rolldown).
Putting This Approach Into Real-World Production
A full-scale rewrite of an entire monolithic product just for the sake of Rust is an easy way to burn through engineering budgets. But surgical optimization of critical bottlenecks fundamentally shifts software economics.
The winning strategy today: keep business logic agile on high-level languages (TypeScript, Python, Go), while offloading performance-critical bottlenecks — CLI linters, parsers, and pre-commit hooks — to Rust using rust-anything and agentic coders. When a 2-minute local CI bottleneck shrinks to a 6-second blip, you’re not just speeding up builds; you’re returning mental focus and momentum to your entire team.
Primary Reference Links:
- Project Repository: erkamyaman/rust-anything on GitHub
- Official Formatter Website: Prettier.io
- Source Code: prettier/prettier on GitHub