agentleFS
DankosikDankosik/cargo-modernize/skills/rust-modern-guidelines/SKILL.md

rust-modern-guidelines

Skill0 starsChanged 4 days agoApache-2.0View on GitHub

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.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this two-step progressive-disclosure workflow whenever writing new Rust code, refactoring existing modules, or raising a crate's …

    line 8
  2. Very specific:

    Run cargo modernize guidelines list inside the target workspace so cargo-modernize auto-detects the workspace MSRV and edition.

    line 14
  3. Very specific:

    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 …

    line 20
  4. Very specific:

    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 …

    line 36
  5. Very specific:

    When reviewing or modernizing a PR branch against a base branch, scope strictly to the branch diff with cargo modernize --diff <base> …

    line 42
  6. Very specific:

    If a site is intentionally kept in the older form, add a reasoned inline keep (// cargo-modernize: keep <rule-id> — <reason>) or record it …

    line 43
  7. Very specific:

    If a rule did not fire where expected, inspect the exact rejection gate with cargo modernize why <rule-id> <file>:<line>.

    line 44

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.