Clones, analyzes, plans, and migrates legacy codebases (C++, Fortran, Java, Python, C, Shell) from a GitHub URL or local directory to a modern, high-performance, deterministic, 100% Safe Rust architecture, tracking live telemetry across every task bucket, test failure/fix cycle, and Profile-Guided Optimization (PGO) stage, and producing a first-person AI storytelling report and interactive HTML infographic. Use when 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 (SoA) or SIMD Rust architectures, or optimizing Rust ports with LLVM PGO. Don't use for unrelated non-Rust refactoring or single-line syntax questions.
Written by Google and published in google/skills under the Apache-2.0 license. Treq shows it unchanged except for heading levels and links to files on GitHub.
Act as a Systems Architect, Performance Engineer, and Rust Specialist. Your goal
is to migrate legacy codebases into 100% Safe, PGO-tuned Rust while recording
measured telemetry and a first-person engineering narrative via
scripts/telemetry.py.
When migrating a repository or local directory ({github_url} or
{codebase_path}), follow these execution rules across agentic harnesses:
clippy
lints, or A/B parity checks fail, log the failure via
scripts/telemetry.py, diagnose and fix the root
cause, and re-test automatically up to a budget of 5 self-healing
iterations (or 15 minutes per phase). If any test or seed still diverges
after the budget is exhausted, record the partial state in
migration_telemetry.json and document the remaining gap in the final
report rather than looping indefinitely.#![forbid(unsafe_code)] Rust crate compiles with a target of 0
cargo clippy warnings (any unavoidable exception must be documented).proptest) tests pass with
a target of >= 95% branch coverage (any unavoidable exception must be
documented), with every run logged in migration_telemetry.json.N deterministic
seeds within a documented numerical epsilon (--max-abs-error), with
any floating-point/FMA/PRNG divergence root-caused and logged.legacy_baseline, safe_rust, soa_simd,
pgo_lto) are measured and logged (or omitted cleanly if a tool such as
llvm-profdata is unavailable).migration_infographic.html) is
rendered via scripts/telemetry.py render-infographic.Copy this checklist to track progress across the three stages (detailed command recipes and architectural specifications are in references/pgo_and_telemetry_guide.md):
- [ ] Stage 0: Acquire repo, initialize `migration_telemetry.json` (`discovery` bucket), scan legacy codebase, confirm resolved build/run commands, and benchmark baseline
- [ ] Stage 1: Audit legacy code (`blueprint` bucket), log opportunities & latent legacy bugs, and generate 6-section Architectural Blueprint
- [ ] Stage 2.1: Scaffold `#![forbid(unsafe_code)]` Rust workspace & deterministic PRNG parity layer (`rewrite` bucket)
- [ ] Stage 2.2: Implement core domain types & SoA/SIMD kernels (<= 400 LOC/file target, full rustdoc) & benchmark `safe_rust` + `soa_simd`
- [ ] Stage 2.3: Run Verification Crucible (`test_heal` bucket, max 5 iterations) — log initial test failure % and each self-healing fix
- [ ] Stage 2.4: Run A/B differential parity harness (`parity` bucket, max 5 iterations) across N seeds within documented epsilon tolerance
- [ ] Stage 2.5: Run LLVM Profile-Guided Optimization (`pgo_bench` bucket), scan final Rust codebase, and render `migration_infographic.html`
Resolve context parameters from the repository or directory:
| Parameter | Placeholder | Resolution Strategy |
|---|---|---|
| Source Input | {codebase_path} or {github_url} |
Accept a GitHub URL (https://github.com/...) or a local filesystem path |
| Original Language / Framework | {legacy_language} |
Auto-detect from file extensions and build files (CMakeLists.txt, Makefile, meson.build, pyproject.toml, pom.xml, *.f90, *.cpp) |
| Baseline Run Command | {baseline_run_command} |
Identify from README.md, CI workflows (.github/workflows/*.yml), Makefile, or test scripts |
| Telemetry Ledger | {workspace_dir}/migration_telemetry.json |
Initialized via scripts/telemetry.py init at the start of Stage 0 |
~/rust_migrations/{repo_name}, or inside the current workspace
if requested) and run git clone {github_url} ~/rust_migrations/{repo_name}.scripts/telemetry.py init --telemetry "{workspace_dir}/migration_telemetry.json" --project-name "{project_name}" --legacy-lang "{legacy_language}". Start the discovery
bucket and run scripts/telemetry.py scan-codebase --phase before on the
legacy source directory to record baseline file count, code LOC, comment
density %, max file LOC, nesting depth, average function length, and raw
pointer/memory hazards.{baseline_run_command}, and working directory for user
confirmation. Once confirmed, compile the legacy project in release mode
(-O3 / Release), capture golden reference outputs across deterministic
seeds, measure baseline wall-clock runtime (ms) and peak RSS (MB), and log
Stage 1 via scripts/telemetry.py log-benchmark --stage legacy_baseline.Start the blueprint timer bucket (scripts/telemetry.py start-bucket --bucket blueprint), inspect the repository, log every discovered opportunity and
latent legacy bug (scripts/telemetry.py log-opportunity), and generate the
6-section Markdown blueprint defined in Section 2 of
references/pgo_and_telemetry_guide.md.
Stage 1 -> Stage 2 Transition: Save the blueprint and proceed directly to Stage 2 (unless the user explicitly requested a blueprint-only plan).
Follow the command recipes and core engineering standards in references/pgo_and_telemetry_guide.md for each step:
rewrite Bucket)rewrite timer bucket (scripts/telemetry.py start-bucket --bucket rewrite).#![forbid(unsafe_code)] in src/lib.rs
and src/main.rs.<= 400 LOC per file target, complete //! and ///
rustdoc with runnable doc-tests).safe_rust) and Stage 3 (soa_simd) via
scripts/telemetry.py log-benchmark.test_heal Bucket)test_heal timer bucket (scripts/telemetry.py start-bucket --bucket test_heal).proptest boundary tests.cargo test --all-targets, cargo test --doc, and cargo clippy --all-targets.scripts/telemetry.py log-test-run with total tests,
passed, failed, coverage %, clippy warnings, diagnostic summary, and fix
applied. Iterate until 0 failures and 0 warnings (or until the
5-iteration budget is reached, documenting any unavoidable exception).parity Bucket)parity timer bucket (scripts/telemetry.py start-bucket --bucket parity).N deterministic seeds
comparing {baseline_run_command} and the Rust binary within the documented
epsilon tolerance.scripts/telemetry.py log-parity-run. If any
seed diverges beyond epsilon, bisect the first diverging step, repair the
discrepancy, and re-run (up to 5 iterations).pgo_bench Bucket)pgo_bench timer bucket (scripts/telemetry.py start-bucket --bucket pgo_bench).RUSTFLAGS="-Cprofile-generate=./pgo-data", run representative
workloads, merge profiles via llvm-profdata, and rebuild with
RUSTFLAGS="-Cprofile-use=./pgo-data/merged.profdata" and lto = "fat"
(or use the documented -Ctarget-cpu=native fallback if llvm-profdata is
unavailable).pgo_lto) via
scripts/telemetry.py log-benchmark --stage pgo_lto.Run scripts/telemetry.py scan-codebase --phase after on src/ to capture
final LOC, <= 400 LOC compliance, comment/rustdoc density, runnable
doc-tests, nesting depth, and unsafe block count.
Log a Before vs. After Code Spotlight (scripts/telemetry.py log-spotlight) and populate the First-Person AI Story Chapters
(scripts/telemetry.py set-story).
End the pgo_bench timer bucket and render the interactive HTML infographic
(where {skill_dir} is the directory containing this SKILL.md):
python3 "{skill_dir}/scripts/telemetry.py" render-infographic \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--out "{output_dir}/migration_infographic.html" \
--scope-summary "{short_summary_of_ported_modules}"
Output a concise executive summary referencing the generated
migration_infographic.html report and key measured before/after metrics.
scripts/telemetry.pyClaude Code and Codex keep each installed skill's name and description in context. When a request matches the description, the agent loads the full SKILL.md. You can also run it yourself: type /migrate-to-rust in Claude Code or $migrate-to-rust in Codex.
The description says when to use it:
Use when 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 (SoA) or SIMD Rust architectures, or optimizing Rust ports with LLVM…
Copy the migrate-to-rust folder into .claude/skills/ in your project. To use it in every project, copy it into ~/.claude/skills/ instead.
git clone --depth 1 https://github.com/google/skills.git /tmp/google-skills
mkdir -p .claude/skills
cp -r /tmp/google-skills/skills/developers/migrate-to-rust .claude/skills/
Codex reads skills from .agents/skills/ in your repository, and from ~/.agents/skills/ for every repository. It detects new skills on its own. Restart Codex if migrate-to-rust does not appear.
git clone --depth 1 https://github.com/google/skills.git /tmp/google-skills
mkdir -p .agents/skills
cp -r /tmp/google-skills/skills/developers/migrate-to-rust .agents/skills/
Open Settings and select the Skills tab. The tab appears when Skills installation is on under Settings → Feature Preview. Search for migrate-to-rust and choose Install….
Install for repository writes the skill under .treq/skills/ in the current repository. Install for application makes it available to every repository on this machine. Each new workspace gets a copy in .claude/skills/ and .agents/skills/, so Claude Code and Codex both find it. See Installing Skills from the Library.
migrate-to-rust ships 4 files, 132.5 KB in total. Select a file to load it from GitHub.