Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

The rust-anything crab

rust-anything

by erKam Yaman

English · Türkçe · Українська · 简体中文 · 繁體中文 · Deutsch · Français · Русский · 日本語 · 한국어 · Azərbaycanca · Oʻzbekcha · Қазақша · Кыргызча · Türkmençe · Татарча · ئۇيغۇرچە · Português

Rewrite your whole app in Rust. Keep it working the whole way.

CLIs, servers and libraries, piece by piece, checked against the original at every step.

Node.js and TypeScript · Python · C · Go · Ruby · Java · PHP and C# in preview

crates.io version npm version 6 languages, plus 2 in preview Works with 4 agents Tests MIT license GitHub stars

Quick start · Languages · How it works · The loop · Port a whole app · Hot paths · Install · What it can't catch · FAQ

up to 20x faster · 38,251 recorded cases replayed · 0 mismatches · one command

Typing user.profile into x18n's search over 50,000 keys: TypeScript spends 143 ms, the rust-anything batch 6.9 ms, with the same results at every keystroke.
Typing a query into x18n's search over 50,000 keys: the TypeScript original against the rust-anything batch, same results at every keystroke.

Record
record runs the original on generated edge cases, semantic traps and your own inputs, and saves what it returns or throws.
Port
bridge generates the Rust crate and a wrapper, so callers keep the original API. You or your agent write the Rust.
Check
diff replays every recorded case against the Rust, and nothing ships until they all match and gate passes.
Lift
When replay passes with no fallback and every unit passes gate, app lift makes it a pure Rust app. The original is never touched.

Rewrite your whole app in Rust, one piece at a time. rust-anything records what your Node.js (TypeScript/JavaScript), Python, C, Go, Ruby or Java app does today, then checks every piece of the Rust rewrite against that recording before it moves on, until the app is pure Rust. CLIs, HTTP servers and libraries; your coding agent (or you) writes the Rust. It can only catch what the recording covers: see What it can't catch. Only need the slow part fast? Port just that, one hot path at a time:

Real workload, same results as the originalOriginalWith rust-anything
x18n's sidebar search, 50,000 keys (TypeScript, Node)10 ms per query0.5 ms: 20x faster
The same search in the browser (wasm, one thread)10 ms0.95 ms: 11.5x
slugify over 20,000 strings (Python)98 ms17x faster
Shellwords.shellescape from Ruby's standard library, 50,000 values88 ms11.8x faster
Slugify over 50,000 strings (Go)49 ms4x faster
slugify over 50,000 strings (Java)43 ms3x faster

Measured on 4 cores; every number has a benchmark in demo/ that first checks the results are identical. Calling Rust once per small function is usually slower than a JIT; rust-anything finds the loop worth moving, and moves it.

rust-anything is an independent project, not affiliated with or endorsed by the Rust Project or the Rust Foundation. "Rust" is a trademark of the Rust Foundation.

[!WARNING] record and app record run your original code, calling each function (or the whole app) on many generated inputs, and app record runs every case twice. diff, gate and app replay run the same cases again, on the port or the original. Code that writes files, talks to a database or calls the network does that once per case. Run them on a copy of the project, with a test database and no production credentials in the environment.

Quick start

Paste this into Claude Code, Codex, Cursor or Gemini CLI and let your agent install it:

Install rust-anything: run `cargo install rust-anything`, then `rust-anything setup`.
Tell me when to restart you.

Or yourself:

cargo install rust-anything   # from crates.io
rust-anything setup           # registers it with Claude Code, Codex, Cursor and Gemini CLI

No Rust toolchain yet? Prebuilt binaries for macOS, Linux and Windows are attached to each GitHub release, and for JavaScript projects npm install -g rust-anything installs the same binary.

In Claude Code you can also install it as a plugin (the MCP server and the skill; the CLI above must be on your PATH):

/plugin install rust-anything --marketplace erkamyaman/rust-anything

setup adds the MCP server to each agent it finds and installs the workflow skill where the agent reads skills. It keeps your other settings, is safe to run again, and --remove undoes it. Then ask your agent, for example:

  • "Rewrite this CLI in Rust with rust-anything, end to end, and prove it behaves the same."
  • "This search feels slow. Profile it with rust-anything and move the hot loop to Rust."
  • "Plan a migration of src/parser/ to Rust with rust-anything; port the first unit and prove it."
  • "Bench the Rust port in rust/text-rs against the original and tell me whether to ship it."

Works with

Agentrust-anything setup adds
Claude CodeMCP server in ~/.claude.json, skill in ~/.claude/skills/
CodexMCP server in ~/.codex/config.toml, skill in ~/.codex/skills/
CursorMCP server in ~/.cursor/mcp.json
Gemini CLIMCP server in ~/.gemini/settings.json
Any other MCP clientadd rust-anything mcp as a stdio server by hand (see Install)

Before changing a file that exists, setup saves a copy beside it (<file>.rust-anything.bak).

Or run the steps yourself:

rust-anything profile finds fuzzyScore in a loop, bridge --batch generates the Rust crate, gate passes with 2000/2000 recorded cases, and the benchmark shows 20.7x faster than TS.
The steps on x18n's fuzzyScore: profile finds the hot loop, bridge --batch generates the crate, gate passes, and the benchmark compares it with the TypeScript.

rust-anything profile . -- node bench.mjs              # what is hot, and who calls it
rust-anything bridge . src/fuzzy.ts --batch fuzzyScore:text
# write src/port.rs (or let your agent), then:
rust-anything record rust/fuzzy-rs && rust-anything build rust/fuzzy-rs
rust-anything diff rust/fuzzy-rs                       # every recorded case must match
rust-anything bench rust/fuzzy-rs                      # faster? the verdict says
rust-anything gate rust/fuzzy-rs                       # done means this passes

rust-anything does not translate code: your coding agent (Claude Code, Codex, Cursor, ...) or you write the Rust. rust-anything supplies what an agent cannot guess reliably: where the time goes, what to port first and in which order, a bridge so the rest of the code calls the Rust with its API unchanged, the exact behavior the port must match, a safe way to ship it, and a gate that says when a port is done.

Languages

LanguageUnitBridgeRecorded and replayed by
TypeScript/JavaScriptfolder or filenapi-rs or wasm-bindgen with a generated binary wire; classes and async includedNode, running the .ts sources
Pythonpackage or modulePyO3 (abi3), direct conversion, typed exceptionsPython, importing the original
C.c fileextern "C" functions with the original names and a headerthe original compiled to a shared library, called through ctypes, one fork per case
Gopackagetyped cgo calls and a generated binary wire, in a package with the original APIa generated Go driver, built as its own module
Rubyfile or folder of module functionsa magnus extension under the original modulesa generated Ruby driver
Javapackage of public static methodstyped JNI and a generated binary wire, in wrapper classes with the original methodsa generated reflection driver
PHP (preview)folder of functions and public static methodscoming next: PHP FFI over a C ABIwhole apps today: app record, app replay and the front door, for CLIs and servers (php -S)
C# (preview)folder of public static methodscoming next: P/Invoke over a C ABIwhole apps today: app record, app replay and the front door, for CLIs and ASP.NET servers (dotnet <app>.dll)

Every language except C also gets batch classes (--batch): the items cross once and stay in Rust, and each call runs over all of them on all cores.

The language is detected from the repository (go.mod, pom.xml, a .csproj or .sln, pyproject.toml, Gemfile, composer.json, package.json, else the most common source files); --lang overrides it. Types come from the source: TS types, Python hints, C, Go, Java and C# signatures, Ruby YARD tags, PHP types and phpdoc; untyped parameters used as numbers are inferred as numbers.

PHP is in preview: analyze plans a PHP app (Composer packages and PSR-4 autoloading, risks such as loose comparison and integer overflow into floats, Composer packages mapped to crates), and a PHP CLI or server can be recorded, replayed and put behind a Rust front door. Porting its units into Rust through PHP's FFI is the next step (issue #2).

C# is in preview the same way: analyze reads .csproj projects and their NuGet packages (mapped to crates), resolves using directives to folders, and flags what C# does differently (decimal, dynamic, LINQ's deferred queries, Task, lock, reflection). A C# CLI or ASP.NET server can be recorded, replayed and put behind a Rust front door; porting units through P/Invoke comes next.

Learn more

Sponsors

rust-anything is free and open source. If it helps your work, please consider sponsoring it.
Your support keeps development going.

Company sponsor: CodeRabbit

Sponsors: Ali Yilmaz, Ashley Hunter, Fatih Uzuntaş

Become a sponsor

Contributing

Issues and pull requests are welcome; CONTRIBUTING.md covers the setup, where tests go, and how to add a language. Design choices and their reasons are in DECISIONS.md. Case studies of real ports are especially welcome. Please report security problems privately (SECURITY.md), and see the code of conduct.

License

MIT © Erkam Yaman. Ports and generated code in your repository are yours.

关于 About

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.
agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript

语言 Languages

Rust99.1%
JavaScript0.6%
Shell0.1%
Python0.1%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
133
Total Commits
峰值: 133次/周
Less
More

核心贡献者 Contributors