К основному содержанию
скилл Claude Code Gemini CLI CX Codex официальный · Google

migrate-to-rust — скилл для Claude Code: что делает и как установить

Скилл переносит кодовые базы C++, Fortran, Java, Python и C на безопасный Rust с замерами производительности.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add google/skills --skill migrate-to-rust -a claude-code
Открыть на GitHub

Что делает migrate-to-rust

Скилл клонирует репозиторий или открывает локальную папку и переписывает код на Rust с директивой #![forbid(unsafe_code)]. Перед запуском стороннего кода агент обязательно запрашивает подтверждение команд сборки. Архитектура формируется с расчетом на структуры SoA и векторные SIMD-инструкции.

Каждый этап работы фиксирует метрики через scripts/telemetry.py в файл migration_telemetry.json. При сбоях тестов или замечаниях cargo clippy запускается автоматическое исправление с лимитом до пяти итераций. Корректность вычислений проверяется через дифференциальные A/B-тесты с контролем погрешности чисел с плавающей точкой.

Финальный шаг измеряет профильную оптимизацию LLVM PGO и генерирует отчёт migration_infographic.html. Ставьте этот скилл, если нужно переписать вычислительный модуль на надёжный системный стек. Для одиночных правок синтаксиса запускать его не стоит.

Какие задачи решает

  • переписать легаси-код с C++ или Fortran на безопасный Rust
  • оптимизировать структуры данных под SoA и векторные SIMD-инструкции
  • провести профильную оптимизацию крейта с помощью LLVM PGO
  • подтвердить точность вычислений через дифференциальные A/B-тесты

Примеры запросов агенту

  • Сделай миграцию проекта из папки ./legacy-sim на безопасный Rust с замером метрик.
  • Перенеси вычисления C++ на Rust с запретом unsafe_code и настрой сборку с PGO.
  • Сформируй интерактивный отчёт migration_infographic.html по итогам переноса кода.

Как установить migrate-to-rust

1Через Skills CLI (Vercel)

npx skills add google/skills --skill migrate-to-rust -a claude-code

2Вручную: положить файлы

~/.claude/skills/migrate-to-rust/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/migrate-to-rust/

Из того же набора172

Весь набор →
bigquery-basics официальный google Управляет ресурсами BigQuery и запускает SQL-запросы. Подходит для создания датасетов, таблиц, представлений и базовой загрузки данных. Claude Code Gemini CLI CX Codex 17 678установок cloud-run-basics официальный google Скилл помогает управлять Cloud Run: разворачивать HTTP-сервисы, запускать задачи по событию или расписанию и вести фоновые worker pools. Claude Code Gemini CLI CX Codex 17 532установок gemini-api официальный google Подключает Gemini API из Agent Platform Google Cloud к агенту. Даёт доступ к моделям Gemini, мультимодальному вводу, вызову функций и кешированию контекста. Claude Code Gemini CLI CX Codex 17 116установок google-cloud-recipe-auth официальный Google LLC Скилл объясняет аутентификацию и права доступа в Google Cloud. Пригодится для настройки IAM, ADC и сервисных аккаунтов в разработке и продакшене. Claude Code Gemini CLI CX Codex 15 450установок google-cloud-recipe-onboarding официальный Google LLC Проводит разработчика через старт в Google Cloud: проверяет CLI, вход, проект и биллинг. Подходит для первого личного проекта. Claude Code Gemini CLI CX Codex 15 390установок cloud-sql-basics официальный google Скилл помогает создавать и объяснять Cloud SQL для MySQL, PostgreSQL и SQL Server. Пригодится при настройке базы в Google Cloud. Claude Code Gemini CLI CX Codex 14 679установок google-cloud-waf-security официальный google Скилл оценивает безопасность рабочих нагрузок в Google Cloud и предлагает меры для IAM, сетевой защиты, данных и операционной безопасности. Claude Code Gemini CLI CX Codex 14 620установок google-cloud-waf-cost-optimization официальный google Проверяет расходы Google Cloud по pillar Cost Optimization из Well-Architected Framework. Нужен для поиска простаивающих ресурсов, выбора скидок и правки размеров сервисов. Claude Code Gemini CLI CX Codex 14 266установок

Похожие

freecad-scripts официальный github Помогает писать Python-скрипты и макросы для FreeCAD: 3D-геометрию, параметрические объекты, GUI на PySide. Пригодится, если вы автоматизируете CAD. GitHub Copilot 1 200установок lsp-setup официальный github Скилл устанавливает языковой сервер и настраивает LSP для Copilot CLI. Подойдёт, когда нужны переход к определению и просмотр ссылок на символ. GitHub Copilot 1 100установок react19-source-patterns официальный github Справочник для миграции React-исходников на React 19: API, ref, контекст и пропсы. Пригодится при обновлении существующего проекта. GitHub Copilot 967установок minecraft-plugin-development официальный github Помогает создавать и отлаживать серверные плагины для Paper, Spigot и Bukkit. Настраивает команды, слушатели событий, конфиги и игровые механики. GitHub Copilot 485установок batch-files официальный github Добавляет в GitHub Copilot знание синтаксиса cmd.exe для написания, отладки и поддержки файлов .bat и .cmd. Пригодится для автоматизации задач в Windows и скриптов планировщика. GitHub Copilot 206установок dotnet-mcp-builder официальный github Скилл помогает создавать MCP-серверы и базовые клиенты на C#/.NET с пакетами ModelContextProtocol 2.x. Подключайте его, когда добавляете MCP-инструменты в .NET-проект. GitHub Copilot 152установок migrate-to-shoehorn Matt Pocock Переводит type assertions с as в тестах на функции из @total-typescript/shoehorn. Нужен для частичных объектов и намеренно неверных данных в проверках. Claude Code 475 388установок write-swift emilkowalski Скилл помогает писать, проверять и переносить код на Swift с учётом модели языка. Подойдёт, когда нужно разобраться с конкурентностью, ошибкой или циклом удержания объектов. Claude Code CX Codex Cursor +1 117 500установок

Вопросы о migrate-to-rust

Как установить migrate-to-rust в Claude Code?

Выполните команду npx skills add google/skills --skill migrate-to-rust -a claude-code в терминале.

Что делает migrate-to-rust?

Он переносит кодовую базу с C, C++, Java, Python или Fortran на Rust без небезопасных блоков памяти. Процесс сопровождается замерами скорости и созданием HTML-отчёта.

Как скилл обрабатывает ошибки сборки и тестов?

Агент запускает цикл автоисправления с лимитом до пяти попыток или 15 минут на фазу. Если починить проблему не удается, он заносит остаточный статус в migration_telemetry.json.

Исходный текст

SKILL.md · Apache-2.0
---
name: migrate-to-rust
metadata:
  version: "1.0.0"
  category: ApplicationDevelopment
description: >-
  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.
---

# 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`](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:

1.  **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.)
2.  **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.
3.  **Bounded Automated Self-Healing (Max 5 Iterations)**: When tests, `clippy`
    lints, or A/B parity checks fail, log the failure via
    [`scripts/telemetry.py`](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.
4.  **Verification Targets & Definition of Done**:
    -   `#![forbid(unsafe_code)]` Rust crate compiles with a target of `0`
        `cargo clippy` warnings (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 in `migration_telemetry.json`.
    -   A/B differential output parity is verified across `N` deterministic
        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 as
        `llvm-profdata` is unavailable).
    -   The interactive HTML infographic (`migration_infographic.html`) is
        rendered via `scripts/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](references/pgo_and_telemetry_guide.md)):

```markdown
- [ ] 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

1.  **Clone Repository (if GitHub URL)**: Choose a clean local directory
    (default to `~/rust_migrations/{repo_name}`, or inside the current workspace
    if requested) and run `git clone {github_url}
    ~/rust_migrations/{repo_name}`.
2.  **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 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.
3.  **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 via `scripts/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](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](references/pgo_and_telemetry_guide.md)
for each step:

### Step 1: Scaffold Safe Rust Workspace & Port Modules (`rewrite` Bucket)

1.  Start the `rewrite` timer bucket (`scripts/telemetry.py start-bucket
    --bucket rewrite`).
2.  Initialize the Rust workspace with `#![forbid(unsafe_code)]` in `src/lib.rs`
    and `src/main.rs`.
3.  Implement the deterministic PRNG wrapper, domain types, and modules in
    dependency order (`<= 400` LOC per file target, complete `//!` and `///`
    rustdoc with runnable doc-tests).
4.  Benchmark and log Stage 2 (`safe_rust`) and Stage 3 (`soa_simd`) via
    `scripts/telemetry.py log-benchmark`.

### Step 2: The Verification Crucible — Test, Fail, Diagnose & Fix (`test_heal` Bucket)

1.  Start the `test_heal` timer bucket (`scripts/telemetry.py start-bucket
    --bucket test_heal`).
2.  Write unit tests, runnable doc-tests, and `proptest` boundary tests.
3.  Run `cargo test --all-targets`, `cargo test --doc`, and `cargo clippy
    --all-targets`.
4.  **Log Every Iteration (Up to 5 Iterations)**: After Run 1 and each
    subsequent run, invoke `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).

### Step 3: A/B Differential Output Parity (`parity` Bucket)

1.  Start the `parity` timer bucket (`scripts/telemetry.py start-bucket --bucket
    parity`).
2.  Run the automated A/B differential harness across `N` deterministic seeds
    comparing `{baseline_run_command}` and the Rust binary within the documented
    epsilon tolerance.
3.  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)

1.  Start the `pgo_bench` timer bucket (`scripts/telemetry.py start-bucket
    --bucket pgo_bench`).
2.  Execute the LLVM PGO workflow in
    [references/pgo_and_telemetry_guide.md](references/pgo_and_telemetry_guide.md):
    build with `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).
3.  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`) via
    `scripts/telemetry.py log-benchmark --stage pgo_lto`.

### Step 5: Final Census, First-Person AI Story & Visual Infographic

1.  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.
2.  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`).
3.  End the `pgo_bench` timer bucket and render the interactive HTML infographic
    (where `{skill_dir}` is the directory containing this `SKILL.md`):

    ```bash
    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}"
    ```
4.  Output a concise executive summary referencing the generated
    `migration_infographic.html` report and key measured before/after metrics.

--------------------------------------------------------------------------------

## Bundled Resources

-   **Telemetry & Infographic CLI**:
    [`scripts/telemetry.py`](scripts/telemetry.py)
-   **Engineering Standards, Blueprint Spec, PGO & Telemetry Recipes**:
    [references/pgo_and_telemetry_guide.md](references/pgo_and_telemetry_guide.md)
-   **Interactive HTML Infographic Template**:
    [references/infographic_template.html](references/infographic_template.html)

© google · Apache-2.0 · google/skills

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой