Skip to content

Guide · Agent skill

How to use the Migrate Legacy Code to Safe Rust skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The migrate-to-rust skill is an agent skill from google/skills (Apache-2.0) that guides an AI agent through porting an existing codebase to Rust. You give the agent a GitHub URL or a local folder, and it works through a staged playbook: baseline measurements, an architecture plan, a Rust implementation with tests and output-parity checks, and optionally profile-guided optimization. This guide explains what the skill does, how to install it, how to ask for it, and what to check before running it.

Migrate Legacy Code to Safe Rustgoogle/skills · Apache-2.0

Quick start

  1. 1Download the ZIP. Download the migrate-to-rust skill ZIP from this page.
  2. 2Install the skill. Unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder, or upload it under Settings → Capabilities → Skills in the Claude apps.
  3. 3Check the requirements. Confirm git, a Rust toolchain with cargo and clippy, and Python 3 are installed. Add llvm-profdata if you want PGO benchmarks.
  4. 4Make a plain request. Ask the agent to migrate a GitHub URL or local folder to Rust, naming the source language if you know it.
  5. 5Review the confirmation gate. When the agent shows the build command, run command and working directory, check them before approving.
  6. 6Review the outputs. Read migration_telemetry.json, the written report and migration_infographic.html, and check the parity and benchmark results.

What does the migrate-to-rust skill make the agent do?

The skill tells the agent to act as a systems architect, performance engineer and Rust specialist. It works on legacy C++, Fortran, Java, Python, C and Shell codebases. The source describes a staged process: the agent first records baseline measurements of the original program, then writes an architectural blueprint, implements a Rust version, and checks that its output matches the original.

During the work the agent logs timings and results to a JSON file (migration_telemetry.json) through a bundled Python script, scripts/telemetry.py. It can also produce a written report and an interactive HTML summary page (migration_infographic.html).

  • Stage 0: clone or scan the codebase, detect the language, and benchmark the legacy program
  • Stage 1: audit the code, log opportunities and latent bugs, and write a six-section blueprint
  • Stage 2: scaffold a #![forbid(unsafe_code)] Rust workspace, implement it, run tests, run A/B parity checks, and optionally apply LLVM profile-guided optimization
  • Output: telemetry JSON, a report, and an HTML infographic

How do I install the migrate-to-rust skill?

Download the skill ZIP from this page. Then choose one of two routes depending on how you use your agent.

For Claude Code, unzip the download into your personal skills folder ~/.claude/skills/, or into a project's .claude/skills/ folder if you want the skill available only in that project. Keep the skill's folder contents intact, including SKILL.md, the scripts folder and the references folder.

In the Claude apps, open Settings, go to Capabilities, then Skills, and upload the skill there.

  • Route 1 (Claude Code): unzip into ~/.claude/skills/ (all projects) or .claude/skills/ (one project)
  • Route 2 (Claude apps): Settings → Capabilities → Skills, then upload

What do you need installed before it works?

The skill depends on several tools. Check these before you start a migration, because the agent will need them during the build and test stages.

The source lists git for cloning repositories, a Rust toolchain with cargo and clippy, and Python 3 to run scripts/telemetry.py. Two items are optional: llvm-profdata for profile-guided optimization benchmarks, and the proptest crate and Criterion for property-based tests and benchmarks.

  • Required: git (to clone repositories)
  • Required: Rust toolchain with cargo and clippy
  • Required: Python 3 (to run scripts/telemetry.py)
  • Optional: llvm-profdata (PGO benchmarking; the source says the PGO benchmark stage is omitted cleanly if it is missing)
  • Optional: proptest crate and Criterion (tests and benchmarks)

How do I trigger the skill with a natural request?

You do not need a special command. Describe the migration in plain language and name the source. The skill's own description lists the kinds of requests it is meant for: migrating a GitHub repository or local codebase to Rust, porting legacy C++, Fortran, Python or Java workloads to memory-safe Rust, designing Struct-of-Arrays or SIMD Rust architectures, and optimizing Rust ports with LLVM PGO.

Be specific about the source and the goal. Giving the GitHub URL or folder path lets the agent start Stage 0 right away.

  • Migrate this C++ repository to safe Rust: https://github.com/owner/repo (replace with your URL)
  • Port the Fortran code in ./solver to Rust and compare the outputs with the original
  • Plan and migrate this local Python project to Rust, and benchmark before and after
  • Port this Java workload to Rust with a documented parity check against the original
  • Migrate this codebase to Rust and produce an HTML summary of the benchmarks

What happens during a migration, step by step?

The skill begins by cloning the repository into a local folder, by default ~/rust_migrations/{repo_name}. It then initializes the telemetry ledger and scans the legacy code. Before the agent compiles or runs any code from a cloned external repository, it must show you the resolved build command, run command and working directory and wait for your confirmation.

The source sets a retry budget of 5 self-healing iterations for failing tests, clippy lints or parity checks. If a test still diverges after that budget, the agent records the partial state and documents the remaining gap in the final report instead of looping.

  • Clone: git clone {github_url} ~/rust_migrations/{repo_name}
  • Initialize telemetry: scripts/telemetry.py init --telemetry "{workspace_dir}/migration_telemetry.json" --project-name "{project_name}" --legacy-lang "{legacy_language}"
  • Scan the legacy code: scripts/telemetry.py scan-codebase --phase before
  • Benchmark the baseline: scripts/telemetry.py log-benchmark --stage legacy_baseline
  • Start the blueprint phase: scripts/telemetry.py start-bucket --bucket blueprint
  • Render the report page: scripts/telemetry.py render-infographic
scripts/telemetry.py init --telemetry "{workspace_dir}/migration_telemetry.json" --project-name "{project_name}" --legacy-lang "{legacy_language}"

What do the benchmark and parity checks measure?

The skill expects four benchmark stages to be measured and logged: legacy_baseline, safe_rust, soa_simd and pgo_lto. The baseline measures wall-clock runtime in milliseconds and peak RSS in megabytes. Parity is checked across N deterministic seeds, within a numerical tolerance you can set with the --max-abs-error flag. Any floating-point, FMA or PRNG divergence is meant to be root-caused and logged.

The source also sets verification targets: zero cargo clippy warnings for the Rust crate (any exception must be documented) and a branch coverage target of at least 95% (again, documented exceptions only).

  • Benchmark stages: legacy_baseline, safe_rust, soa_simd, pgo_lto
  • Parity: N deterministic seeds within --max-abs-error
  • Clippy target: 0 warnings
  • Coverage target: 95% or more branch coverage

What safety points should I check first?

This skill runs scripts and uses the network. It clones repositories with git and runs scripts/telemetry.py. The skill also executes cloned build and run commands after you confirm them. Those commands can run arbitrary code from that repository, so the confirmation step is a real safety check, not a formality. Read the resolved commands and the working directory before you approve.

The source says not to run untrusted cloned repositories without review. Inspect the build files, README and CI workflows yourself first when the code is unfamiliar.

  • Read every build and run command shown at the confirmation gate before approving
  • Review the repository's build files and scripts before you run them
  • Use a local folder you already trust if you do not know the repository
  • The skill does not apply to unrelated refactors or single-line Rust syntax questions, which the skill itself says it should not handle

What people use it for

  • Porting a legacy C++ library to safe Rust while keeping outputs within a set numerical tolerance
  • Planning the migration of a Fortran numerical program and recording before-and-after benchmarks
  • Moving a Java or Python workload to Rust with a documented parity check against the original
  • Designing a Struct-of-Arrays or SIMD Rust architecture for a data-heavy legacy program

Frequently asked questions

Is the migrate-to-rust skill free to use?

The source states the skill is licensed under Apache-2.0. It does not list prices. You still need your own agent environment and the tools it requires, such as git and a Rust toolchain.

What do I need installed to run the migrate-to-rust skill?

The source requires git, a Rust toolchain with cargo and clippy, and Python 3 for scripts/telemetry.py. llvm-profdata is optional for PGO benchmarks, and the proptest crate and Criterion are optional for tests and benchmarks.

Where do I install a Claude agent skill like this one?

Unzip the downloaded ZIP into ~/.claude/skills/ for all your projects, or into a project's .claude/skills/ folder for one project. In the Claude apps, you can instead upload it under Settings → Capabilities → Skills.

Which languages can the migrate-to-rust skill port?

The description lists C++, Fortran, Java, Python and C. The SKILL.md text also includes Shell. The skill detects the language from file extensions and build files such as CMakeLists.txt, Makefile, pyproject.toml, pom.xml and *.f90.

Why does the agent ask me to confirm before running code?

Before compiling or executing code from a cloned external repository, the skill must show you the build command, run command and target directory and get your confirmation. Cloned code can run arbitrary commands, so check these before approving. The skill does not ask this for local code you explicitly told it to run.

What if the Rust port fails its tests or parity checks?

The skill logs the failure, tries to fix the root cause, and retries up to 5 self-healing iterations or 15 minutes per phase. If a test still diverges after that, the remaining gap is recorded in migration_telemetry.json and the final report instead of looping forever.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you are planning or running a migration of a legacy C, C++, Fortran, Java, Python or Shell project to Rust and want measured benchmarks and a documented parity check. Skip it for quick Rust syntax questions or small unrelated refactors, and be careful with untrusted repositories, since the skill runs their build and run commands after you confirm them.

Download the skill