Claude Skill

rust-modern-guidelines

Consults the version-accurate Rust modernization catalog (`cargo modernize guidelines` + `explain`) before writing or refactoring Rust code and verifies changed lines with `cargo modernize --diff` after editing.

LLM Mart · 0 points · 0 views 1 listing impressions 0 install-command copies
Download dankosik-cargo-modernize-skills_rust-modern-guidelines-6f540c3.zip · 1 KB

Install

skills CLI npx skills add https://github.com/Dankosik/cargo-modernize/tree/main/skills/rust-modern-guidelines
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install dankosik-cargo-modernize@llmmart
Git git clone https://github.com/Dankosik/cargo-modernize.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole dankosik/cargo-modernize collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Rust Modern Guidelines (cargo-modernize)

Use this two-step progressive-disclosure workflow whenever writing new Rust code, refactoring existing modules, or raising a crate's rust-version / edition. It keeps context small while covering 100% of modernization knowledge — including both CST-detectable idioms (C1, C3) and type-dependent idioms (C4) that syntax-only scanners cannot auto-detect.

Requires the cargo-modernize CLI (cargo modernize --version). If it is not installed yet, suggest installing the prebuilt binary via cargo binstall cargo-modernize (works on any local Rust toolchain) or from GitHub Releases.

Step 1 — Load the Compact Index (Before Writing Code)

Run cargo modernize guidelines list inside the target workspace so cargo-modernize auto-detects the workspace MSRV and edition. Start with --impact high --format compact (or --since <1.NN>) to stay compact and avoid extra tool turns; omit --impact high only for full crate-wide modernization audits:

cargo modernize guidelines list --impact high --format compact
  • When migrating from an older MSRV or auditing recent releases, filter by release window (e.g., --since 1.80 or --since 1.88) instead of loading all 1.64–1.100 entries.
  • For high-leverage architectural / type-wall idioms (! (never-type), Allocator, core::range, #[expect], trait upcasting, extract_if, as_chunks, strict provenance, async fn in traits, core::error::Error), inspect --class c4 --impact high --format compact.
  • Machine-readable output is available via --format json.

Step 2 — Pull Full Details in One Batched Call

Select the 3–8 guideline IDs relevant to the code you are about to write or review, then fetch all of their before/after examples, behavioral edge cases, const availability, SemVer notes, and upstream rustdoc links in a single batched call (avoid calling explain one ID at a time):

cargo modernize explain strip-circumfix map-or-default assert-matches drop-guard

Apply the modern forms directly while respecting each rule's When to keep old form and Behavioral differences notes.

Step 3 — Verify Changed Lines Once After Editing

After making edits, run the fast read-only scanner on your diff (never touches the working tree or .git/index) — batch it in the same verification shell command as cargo test / cargo clippy to minimize round-trips:

cargo modernize --diff --format compact
  • When reviewing or modernizing a PR branch against a base branch, scope strictly to the branch diff with cargo modernize --diff <base> --format compact (e.g., --diff main).
  • If a site is intentionally kept in the older form, add a reasoned inline keep (// cargo-modernize: keep <rule-id> — <reason>) or record it in .cargo-modernize.toml.
  • If a rule did not fire where expected, inspect the exact rejection gate with cargo modernize why <rule-id> <file>:<line>.
  • For CI enforcement, run cargo modernize --diff origin/main --check (exits 0 clean, 1 findings, 2 error).
Files (cargo-modernize)
  • SKILL.md 3.3 KB
    ---
    name: rust-modern-guidelines
    description: Consults the version-accurate Rust modernization catalog (`cargo modernize guidelines` + `explain`) before writing or refactoring Rust code and verifies changed lines with `cargo modernize --diff` after editing.
    ---
    
    # Rust Modern Guidelines (`cargo-modernize`)
    
    Use this two-step progressive-disclosure workflow whenever writing new Rust code, refactoring existing modules, or raising a crate's `rust-version` / `edition`. It keeps context small while covering **100% of modernization knowledge** — including both CST-detectable idioms (`C1`, `C3`) and type-dependent idioms (`C4`) that syntax-only scanners cannot auto-detect.
    
    Requires the `cargo-modernize` CLI (`cargo modernize --version`). If it is not installed yet, suggest installing the prebuilt binary via `cargo binstall cargo-modernize` (works on any local Rust toolchain) or from [GitHub Releases](https://github.com/Dankosik/cargo-modernize/releases).
    
    ## Step 1 — Load the Compact Index (Before Writing Code)
    
    Run `cargo modernize guidelines list` inside the target workspace so `cargo-modernize` auto-detects the workspace MSRV and edition. Start with `--impact high --format compact` (or `--since <1.NN>`) to stay compact and avoid extra tool turns; omit `--impact high` only for full crate-wide modernization audits:
    
    ```sh
    cargo modernize guidelines list --impact high --format compact
    ```
    
    - When migrating from an older MSRV or auditing recent releases, filter by release window (e.g., `--since 1.80` or `--since 1.88`) instead of loading all 1.64–1.100 entries.
    - For high-leverage architectural / type-wall idioms (`!` (`never-type`), `Allocator`, `core::range`, `#[expect]`, trait upcasting, `extract_if`, `as_chunks`, strict provenance, `async fn` in traits, `core::error::Error`), inspect `--class c4 --impact high --format compact`.
    - Machine-readable output is available via `--format json`.
    
    ## Step 2 — Pull Full Details in One Batched Call
    
    Select the 3–8 guideline IDs relevant to the code you are about to write or review, then fetch **all** of their before/after examples, behavioral edge cases, `const` availability, SemVer notes, and upstream rustdoc links in **a single batched call** (avoid calling `explain` one ID at a time):
    
    ```sh
    cargo modernize explain strip-circumfix map-or-default assert-matches drop-guard
    ```
    
    Apply the modern forms directly while respecting each rule's `When to keep old form` and `Behavioral differences` notes.
    
    ## Step 3 — Verify Changed Lines Once After Editing
    
    After making edits, run the fast read-only scanner on your diff (never touches the working tree or `.git/index`) — batch it in the same verification shell command as `cargo test` / `cargo clippy` to minimize round-trips:
    
    ```sh
    cargo modernize --diff --format compact
    ```
    
    - When reviewing or modernizing a PR branch against a base branch, scope strictly to the branch diff with `cargo modernize --diff <base> --format compact` (e.g., `--diff main`).
    - If a site is intentionally kept in the older form, add a reasoned inline keep (`// cargo-modernize: keep <rule-id> — <reason>`) or record it in `.cargo-modernize.toml`.
    - If a rule did not fire where expected, inspect the exact rejection gate with `cargo modernize why <rule-id> <file>:<line>`.
    - For CI enforcement, run `cargo modernize --diff origin/main --check` (exits `0` clean, `1` findings, `2` error).
    

Comments

Sign in to join the conversation.

No comments yet. Start the conversation.

Reviews (0)

No reviews yet.