Migrate To Rust
GoogleOfficialPublished by Google
- Skill
- Workflow
- Software development
- Apache-2.0
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a comprehensive, multi-stage process for porting legacy codebases written in languages like C++, Fortran, Java, or Python into modern, memory-safe Rust. It emphasizes a rigorous engineering approach, requiring the use of specific telemetry scripts to track progress, performance benchmarks, and test coverage. The workflow includes architectural planning, iterative refactoring, A/B parity testing, and Profile-Guided Optimization (PGO) to ensure the resulting Rust implementation is both safe and performant. It concludes by generating a detailed, first-person engineering narrative and an interactive HTML infographic to visualize the migration journey.
What it does
- Analyzes legacy codebases to identify technical debt and architectural opportunities.
- Scaffolds a Rust workspace with strict memory safety requirements.
- Performs iterative refactoring with automated test-driven self-healing.
- Validates output parity between legacy and new implementations using deterministic seeds.
- Optimizes performance through data-oriented design and LLVM Profile-Guided Optimization.
- Generates telemetry reports and interactive infographics documenting the migration metrics.
When to use it
- When migrating a legacy GitHub repository or local codebase to Rust.
- When porting complex C++, Fortran, Python, or Java workloads to memory-safe Rust.
- When designing high-performance Struct-of-Arrays or SIMD architectures in Rust.
- When optimizing Rust ports using LLVM Profile-Guided Optimization.
Advantages
- Ensures 100% memory safety by forbidding unsafe code blocks.
- Provides quantified performance improvements across four distinct optimization stages.
- Maintains high code quality through strict file size and documentation standards.
- Delivers transparent, data-backed reporting on the migration process and outcomes.
Usage examples
- “Migrate the legacy C++ codebase located at /local/path/to/project to Rust.”
- The agent initializes the telemetry ledger, scans the legacy project, benchmarks the baseline, and begins the multi-stage migration process.
- “Port my Python data processing library to a high-performance Rust implementation.”
- The agent audits the Python code, scaffolds a Rust workspace, implements the core logic, and verifies parity before applying PGO.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/google/migrate-to-rust/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip migrate-to-rust.zip -d .agents/skills
Documentation by Google
Migrate Legacy Codebases to Safe Rust
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.
Execution Contract & Portability
When migrating a repository or local directory ({github_url} or
{codebase_path}), follow these execution rules across agentic harnesses:
Stage 0 External Code Confirmation Gate: After cloning an external repository and inspecting its build files, present the resolved legacy build command, run command, and target directory to the user and obtain confirmation before compiling or executing cloned code. (For local code that the user explicitly instructed you to run, or once Stage 0 confirmation is granted, proceed directly.)
Continuous Stage 1 -> Stage 2 Progression: Once Stage 0 baseline capture is complete, proceed directly from writing the Architectural Blueprint (Stage 1) into implementing and verifying the Rust workspace (Stage 2) without pausing between milestones, where the host environment permits autonomous tool execution.
Bounded Automated Self-Healing (Max 5 Iterations): When tests,
clippylints, or A/B parity checks fail, log the failure viascripts/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 inmigration_telemetry.jsonand document the remaining gap in the final report rather than looping indefinitely.Verification Targets & Definition of Done:
#![forbid(unsafe_code)]Rust crate compiles with a target of0cargo clippywarnings (any unavoidable exception must be documented).Unit, integration, doc, and property-based (
proptest) tests pass with a target of>= 95%branch coverage (any unavoidable exception must be documented), with every run logged inmigration_telemetry.json.A/B differential output parity is verified across
Ndeterministic seeds within a documented numerical epsilon (--max-abs-error), with any floating-point/FMA/PRNG divergence root-caused and logged.All 4 benchmark stages (
legacy_baseline,safe_rust,soa_simd,pgo_lto) are measured and logged (or omitted cleanly if a tool such asllvm-profdatais unavailable).The interactive HTML infographic (
migration_infographic.html) is rendered viascripts/telemetry.py render-infographic.
End-to-End Workflow Checklist
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`Stage 0: Repository Acquisition, Telemetry Init & Legacy Baseline
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 |
Stage 0 Execution Steps
Clone Repository (if GitHub URL): Choose a clean local directory (default to
~/rust_migrations/{repo_name}, or inside the current workspace if requested) and rungit clone {github_url} ~/rust_migrations/{repo_name}.Initialize Telemetry & Scan Legacy Codebase: Run
scripts/telemetry.py init --telemetry "{workspace_dir}/migration_telemetry.json" --project-name "{project_name}" --legacy-lang "{legacy_language}". Start thediscoverybucket and runscripts/telemetry.py scan-codebase --phase beforeon 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.Confirm & Benchmark Legacy Baseline: Before executing build or run commands from a cloned external repository, surface the resolved build command,
{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 viascripts/telemetry.py log-benchmark --stage legacy_baseline.
Stage 1: Deep Audit, Opportunity Discovery & Architectural Blueprint
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).
Stage 2: Phased Safe Rust Implementation, Self-Healing, PGO & Infographic
Follow the command recipes and core engineering standards in references/pgo_and_telemetry_guide.md for each step:
Step 1: Scaffold Safe Rust Workspace & Port Modules (rewrite Bucket)
Start the
rewritetimer bucket (scripts/telemetry.py start-bucket --bucket rewrite).Initialize the Rust workspace with
#![forbid(unsafe_code)]insrc/lib.rsandsrc/main.rs.Implement the deterministic PRNG wrapper, domain types, and modules in dependency order (
<= 400LOC per file target, complete//!and///rustdoc with runnable doc-tests).Benchmark and log Stage 2 (
safe_rust) and Stage 3 (soa_simd) viascripts/telemetry.py log-benchmark.
Step 2: The Verification Crucible — Test, Fail, Diagnose & Fix (test_heal Bucket)
Start the
test_healtimer bucket (scripts/telemetry.py start-bucket --bucket test_heal).Write unit tests, runnable doc-tests, and
proptestboundary tests.Run
cargo test --all-targets,cargo test --doc, andcargo clippy --all-targets.Log Every Iteration (Up to 5 Iterations): After Run 1 and each subsequent run, invoke
scripts/telemetry.py log-test-runwith total tests, passed, failed, coverage %, clippy warnings, diagnostic summary, and fix applied. Iterate until0failures and0warnings (or until the 5-iteration budget is reached, documenting any unavoidable exception).
Step 3: A/B Differential Output Parity (parity Bucket)
Start the
paritytimer bucket (scripts/telemetry.py start-bucket --bucket parity).Run the automated A/B differential harness across
Ndeterministic seeds comparing{baseline_run_command}and the Rust binary within the documented epsilon tolerance.Log each parity iteration via
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).
Step 4: Profile-Guided Optimization (PGO) & Final Benchmarks (pgo_bench Bucket)
Start the
pgo_benchtimer bucket (scripts/telemetry.py start-bucket --bucket pgo_bench).Execute the LLVM PGO workflow in references/pgo_and_telemetry_guide.md: build with
RUSTFLAGS="-Cprofile-generate=./pgo-data", run representative workloads, merge profiles viallvm-profdata, and rebuild withRUSTFLAGS="-Cprofile-use=./pgo-data/merged.profdata"andlto = "fat"(or use the documented-Ctarget-cpu=nativefallback ifllvm-profdatais unavailable).Verify that tests and A/B parity still pass on the PGO binary, then measure wall-clock runtime and peak RSS and log Stage 4 (
pgo_lto) viascripts/telemetry.py log-benchmark --stage pgo_lto.
Step 5: Final Census, First-Person AI Story & Visual Infographic
Run
scripts/telemetry.py scan-codebase --phase afteronsrc/to capture final LOC,<= 400LOC compliance, comment/rustdoc density, runnable doc-tests, nesting depth, andunsafeblock 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_benchtimer bucket and render the interactive HTML infographic (where{skill_dir}is the directory containing thisSKILL.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.htmlreport and key measured before/after metrics.
Bundled Resources
Telemetry & Infographic CLI:
scripts/telemetry.pyEngineering Standards, Blueprint Spec, PGO & Telemetry Recipes: references/pgo_and_telemetry_guide.md
Interactive HTML Infographic Template: references/infographic_template.html
Files
- ATTRIBUTION.mdAdded by AutoGineer853 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md12.2 KiB
- references/infographic_template.html61.6 KiB
- references/pgo_and_telemetry_guide.md17.3 KiB
- scripts/telemetry.pyScript41.4 KiB
references/pgo_and_telemetry_guide.md
Engineering Standards, Blueprint Spec, PGO Pipeline & Telemetry Reference
This reference provides the core engineering standards, 6-section Architectural
Blueprint specification, exact command recipes for recording continuous
migration telemetry via scripts/telemetry.py, and
the LLVM Profile-Guided Optimization (PGO) pipeline.
Table of Contents
1. Core Engineering & Verification Standards: Lines 33-102
2. Stage 1 Architectural Blueprint Specification (6 Sections): Lines 104-141
3. Continuous Telemetry Lifecycle (
scripts/telemetry.py): Lines 143-281Step A: Initialize Telemetry & Scan Legacy Codebase (
discoveryBucket): Lines 150-183Step B: Log Opportunities & Latent Legacy Bugs (
blueprintBucket): Lines 184-208Step C: Safe Rust Rewrite & Modularization (
rewriteBucket): Lines 209-224Step D: Log Every Test Run & Self-Healing Fix (
test_healBucket): Lines 225-251Step E: Log A/B Differential Parity Iterations (
parityBucket): Lines 252-281
4. Profile-Guided Optimization (PGO) Workflow (
pgo_benchBucket): Lines 283-3615. Final Census, First-Person Story & Infographic Generation: Lines 363-415
1. Core Engineering & Verification Standards
Every architectural decision in Stage 1 and every module implemented in Stage 2 should follow these seven engineering objectives:
1.1 100% Memory Safety (#![forbid(unsafe_code)])
Place
#![forbid(unsafe_code)]at the crate root (src/lib.rsandsrc/main.rs) so the compiler rejectsunsafeblocks, raw pointer dereferences, or unchecked indexing at compile time. Replace legacy raw pointers, manualmalloc/new/freecalls, and mutable globals with safe ownership, slices, and strong types (0unsafeblocks).
1.2 4-Stage Performance Staircase & PGO
Track and benchmark performance across four explicit checkpoints so the contribution of each optimization technique is isolated and quantified:
Legacy Baseline (
legacy_baseline): Original implementation (1.0x).Initial Safe Rust (
safe_rust): Idiomatic safe port with zero hot-loop heap allocations.Data-Oriented SoA & SIMD (
soa_simd): Struct-of-Arrays cache-aligned memory layouts, pre-allocated workspace arenas, and auto-vectorization.Profile-Guided Optimization (
pgo_lto): Instrumented binary profiled on representative workloads (-Cprofile-generate->llvm-profdata merge->-Cprofile-use+lto = "fat"+codegen-units = 1).
1.3 API, Call-Site & Cognitive Simplification
Audit legacy convoluted call trees, deep nesting, out-parameters, and global mutable state.
Reduce average function length and maximum nesting depth by decomposing complex imperative loops into composable iterators, builders, and strongly typed domain methods.
1.4 Modular Rebalancing & File Hygiene (<= 400 LOC)
Keep individual source files focused and readable: target <= 400 lines of code (LOC) per file (hard ceiling: 600 LOC) by decomposing monolithic legacy files into cohesive, single-responsibility sub-modules.
1.5 Comprehensive Documentation & Comment Expansion (+X% Docs)
Document every public module (
//!), struct, trait, and function (///) withrustdoccovering purpose, invariants, units/coordinate frames,# Errors, equations, and runnable doc-tests.
1.6 Bounded Verification Crucible & Self-Healing Telemetry
Target >= 95% branch coverage with unit, integration, doc, and property-based tests (
proptest).Log every test run transparently (up to 5 self-healing iterations): when initial test runs fail (
X%failed), record the failure count, root cause, and self-healing fix viascripts/telemetry.py log-test-runbefore rebuilding and re-testing. If any failures remain after 5 iterations, document the remaining failures honestly in telemetry rather than looping indefinitely.
1.7 Numerical / Epsilon Parity & Determinism
Execute both the legacy baseline and the Rust binary side-by-side across
Ndeterministic seeds. Log every parity check (scripts/telemetry.py log-parity-run), bisect and repair any algorithmic or PRNG discrepancy, and verify parity within a documented epsilon tolerance (--max-abs-error), accounting for hardware FMA or extended-precision differences where applicable.
2. Stage 1 Architectural Blueprint Specification (6 Sections)
Structure the Stage 1 Markdown blueprint into these six sections:
Codebase Audit, Legacy Census & Latent Bugs Discovered:
Present the automated baseline census from
migration_telemetry.json(total LOC, comment %, max file LOC, nesting depth, memory/state hazards).Highlight Latent Bugs & Undefined Behaviors uncovered in the original code (e.g., uninitialized memory, unchecked division by zero, float precision loss, off-by-one boundary reads) with exact file and line references.
Target Safe Rust Architecture & Module Graph:
Proposed Rust crate/module layout (
#![forbid(unsafe_code)], every file<= 400LOC target).Mapping Table showing where legacy files, classes, and functions relocate:
Legacy File & Symbol ( {legacy_language})Target Rust Module & Type/Fn Transformation & LOC Target path/to/legacy.cpp::SimEnginesrc/engine/stepper.rs::SimStepperAoS to SoA; #![forbid(unsafe_code)];<= 400LOC
API Ergonomics & Call-Site Modernization:
Concrete Before (
{legacy_language}) / After (Rust) code examples from actual repository call sites showing how legacy calls become clean, type-safe Rust APIs.
Test Harness, Property Fuzzing & Parity Strategy:
Plan for unit, doc, and
proptestproperty tests (>= 95%branch coverage target) and golden output comparison acrossNdeterministic seeds within a documented epsilon tolerance.
4-Stage Benchmarking & PGO Pipeline Plan:
Strategy for measuring the 4-stage speedup staircase:
legacy_baseline->safe_rust->soa_simd->pgo_lto(LLVM Profile-Guided Optimization + Fat LTO).
Phased Execution Roadmap:
Step-by-step milestones for Stage 2 execution plus any Open Questions.
3. Continuous Telemetry Lifecycle (scripts/telemetry.py)
Resolve {skill_dir} as the directory containing the SKILL.md file you
loaded. Invoke python3 {skill_dir}/scripts/telemetry.py at each stage
transition so every metric is grounded in real measurements rather than post-hoc
estimates.
Step A: Initialize Telemetry & Scan Legacy Codebase (discovery Bucket)
Immediately after cloning or locating the legacy repository:
python3 "{skill_dir}/scripts/telemetry.py" init \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--project-name "{project_name}" \
--legacy-lang "{legacy_language}"
python3 "{skill_dir}/scripts/telemetry.py" start-bucket \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--bucket discovery
python3 "{skill_dir}/scripts/telemetry.py" scan-codebase \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--phase before \
--dir "{legacy_src_dir}"After confirming and running the legacy baseline binary
({baseline_run_command}) under /usr/bin/time -v (or a Python
resource/time wrapper), log the baseline benchmark:
python3 "{skill_dir}/scripts/telemetry.py" log-benchmark \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--stage legacy_baseline \
--label "1. Legacy {legacy_language} Baseline" \
--wall-time-ms {legacy_ms} \
--peak-rss-mb {legacy_rss_mb} \
--notes "Original legacy implementation baseline."Step B: Log Opportunities & Latent Legacy Bugs (blueprint Bucket)
When transitioning to Stage 1 (Architectural Blueprint):
python3 "{skill_dir}/scripts/telemetry.py" start-bucket \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--bucket blueprintFor each architectural opportunity, performance bottleneck, memory hazard, or latent bug in the original code discovered during the audit, log it:
python3 "{skill_dir}/scripts/telemetry.py" log-opportunity \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--category latent_bug \
--title "Uninitialized boundary state on tick 0" \
--file "src/solver.cpp:142" \
--description "Edge cells read uninitialized memory when periodic wrapping is disabled."Valid --category values: latent_bug, performance, safety, hygiene,
architecture.
Step C: Safe Rust Rewrite & Modularization (rewrite Bucket)
At the start of Stage 2 implementation:
python3 "{skill_dir}/scripts/telemetry.py" start-bucket \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--bucket rewritePlace
#![forbid(unsafe_code)]at the top ofsrc/lib.rsandsrc/main.rsso memory safety is enforced by the compiler.Benchmark both the initial idiomatic Safe Rust port (
safe_rust) and the Struct-of-Arrays / SIMD / zero-allocation refactor (soa_simd) usinglog-benchmark.
Step D: Log Every Test Run & Self-Healing Fix (test_heal Bucket)
Initial test failures form the core of Chapter 3 ("The Verification Crucible").
Start the test_heal bucket and log every test execution iteration,
including Iteration 1 where X% of tests fail, what caused the failures, and
how you fixed them:
python3 "{skill_dir}/scripts/telemetry.py" start-bucket \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--bucket test_heal
python3 "{skill_dir}/scripts/telemetry.py" log-test-run \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--iteration 1 \
--total 42 \
--passed 34 \
--failed 8 \
--coverage-pct 83.5 \
--clippy-warnings 3 \
--failures-summary "19.0% failed (8/42): boundary reflection off-by-one and extreme seed NaN handling." \
--fix-applied "Corrected opposite-direction index LUT and added domain validation."Repeat log-test-run for each rebuild/re-test cycle (up to 5 iterations)
targeting --failed 0, --clippy-warnings 0, and --coverage-pct >= 95.0.
Step E: Log A/B Differential Parity Iterations (parity Bucket)
Start the parity bucket and record each side-by-side comparison run across N
seeds, including any initial seed divergence and the fix applied:
python3 "{skill_dir}/scripts/telemetry.py" start-bucket \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--bucket parity
python3 "{skill_dir}/scripts/telemetry.py" log-parity-run \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--iteration 1 \
--seeds-tested 100 \
--seeds-passed 96 \
--max-abs-error "4.2e-4" \
--divergence-cause "4 seeds drifted beyond 1e-12 epsilon at step 380 due to f32 accumulator rounding." \
--fix-applied "Promoted reduction accumulator to f64 to match legacy reference precision."
python3 "{skill_dir}/scripts/telemetry.py" log-parity-run \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--iteration 2 \
--seeds-tested 100 \
--seeds-passed 100 \
--max-abs-error "2.1e-14 (<= 1e-12 epsilon)" \
--divergence-cause "None — 100/100 seeds matched within 1e-12 epsilon." \
--fix-applied "Verified equivalence across all 100 deterministic seeds."4. Profile-Guided Optimization (PGO) Workflow (pgo_bench Bucket)
After completing the test and parity verification passes, start the pgo_bench
bucket and execute an LLVM Profile-Guided Optimization pass:
python3 "{skill_dir}/scripts/telemetry.py" start-bucket \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--bucket pgo_benchStep 1: Locate llvm-profdata
Run rustc --print sysroot first, then locate llvm-profdata inside that
toolchain path (or check which llvm-profdata):
rustc --print sysrootStep 2: Build Instrumented Binary (-Cprofile-generate)
Configure Cargo.toml with release LTO settings:
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
panic = "abort"Compile with profiling instrumentation enabled using a pgo-data directory
inside the project workspace:
RUSTFLAGS="-Cprofile-generate=./pgo-data" cargo build --releaseStep 3: Execute Representative Profiling Workload
Run the instrumented binary across 3–5 representative seeds/workloads so LLVM records accurate branch probabilities and hot-loop trip counts:
./target/release/{binary_name} {representative_workload_args}Step 4: Merge Profile Data & Compile Final PGO Binary (-Cprofile-use)
{llvm_profdata_binary} merge -o ./pgo-data/merged.profdata ./pgo-dataRUSTFLAGS="-Cprofile-use=./pgo-data/merged.profdata -Cllvm-args=-pgo-warn-missing-function" cargo build --releaseFallback if
llvm-profdatais not installed in the environment: Compile Step 4 withRUSTFLAGS="-C target-cpu=native -C opt-level=3 -C lto=fat -C codegen-units=1"and note the compiler target-cpu + fat-LTO optimization pass in--notes.
Step 5: Benchmark Final PGO Binary & Log Stage 4
Measure wall-clock time and peak RSS of the PGO binary on the exact baseline
workload and log pgo_lto:
python3 "{skill_dir}/scripts/telemetry.py" log-benchmark \
--telemetry "{workspace_dir}/migration_telemetry.json" \
--stage pgo_lto \
--label "4. Profile-Guided Optimization (PGO) + Fat LTO" \
--wall-time-ms {pgo_ms} \
--peak-rss-mb {pgo_rss_mb} \
--notes "Profiled on representative workload and recompiled with -Cprofile-use + Fat LTO."5. Final Census, First-Person Story & Infographic Generation
Once PGO benchmarking is complete:
Scan the final Rust codebase:
python3 "{skill_dir}/scripts/telemetry.py" scan-codebase \ --telemetry "{workspace_dir}/migration_telemetry.json" \ --phase after \ --dir "{rust_crate_dir}/src" \ --coverage-pct {final_coverage_pct} \ --clippy-warnings 0Record a Before/After Code Transformation Spotlight:
python3 "{skill_dir}/scripts/telemetry.py" log-spotlight \ --telemetry "{workspace_dir}/migration_telemetry.json" \ --explanation "How the legacy hot loop was transformed into a documented, zero-allocation Safe Rust kernel." \ --legacy-file "{legacy_file_path}" \ --legacy-code "{legacy_snippet}" \ --rust-file "{rust_file_path}" \ --rust-code "{rust_snippet}"Write the First-Person AI Narrative Chapters: Write from the AI's first-person perspective (
"I found...","I analyzed...","On my first test run, X% of tests failed...","I fixed...","At the end I ran PGO..."):python3 "{skill_dir}/scripts/telemetry.py" set-story \ --telemetry "{workspace_dir}/migration_telemetry.json" \ --headline "“I inherited a {legacy_lang} codebase, uncovered {N} latent bugs, self-healed through {X}% initial test failures, and delivered a {S}x faster PGO-tuned Safe Rust port.”" \ --intro "{2-3 sentence executive summary from AI POV}" \ --ch1-narrative "{Chapter 1: What I found in the legacy codebase & opportunities/bugs discovered}" \ --ch2-narrative "{Chapter 2: How I reorganized the architecture, capped files <=400 LOC, and added +X% docs}" \ --ch3-narrative "{Chapter 3: The test crucible — initial failure %, root causes diagnosed, and self-healing fixes}" \ --ch4-narrative "{Chapter 4: Proving output parity across N seeds}" \ --ch5-narrative "{Chapter 5: The 4-stage speedup staircase culminating in PGO}"End the final timer bucket and render the HTML Infographic:
python3 "{skill_dir}/scripts/telemetry.py" end-bucket \ --telemetry "{workspace_dir}/migration_telemetry.json" \ --bucket pgo_bench 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_scope}"
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/developers/migrate-to-rust · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google or Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download migrate-to-rust.zip