agentleFS
hdprajwalhdprajwal/agent-skills/skills/rust-review/SKILL.md

rust-review

Skill1 starsChanged 6 months agoMITView on GitHub

Review Rust code for correctness, safety, idioms, and performance — run clippy/fmt, audit unsafe and unwrap, check ownership/borrowing and error handling, spot async pitfalls, and confirm tests. Use when reviewing or hardening Rust before merge, or when asked to make Rust more idiomatic. Runs the toolchain first, then reads for what tools can't catch.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

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

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

    If cargo-audit / cargo-deny are installed, run them for advisories: cargo audit.

    line 21
  2. Very specific:

    Unsafe: Every unsafe block needs a comment stating the invariant that makes it sound, and a reason a safe alternative won't do.

    line 26
  3. Very specific:

    Prefer ?, ok_or, get, checked_*.

    line 32
  4. Very specific:

    Async (tokio): No blocking calls (std::fs, std::thread::sleep, heavy CPU) inside async tasks — use the async equivalents or spawn_blocking.

    line 48

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “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 Review

Let the toolchain do the mechanical pass first, then read for the things it can't see. Don't hand-review what clippy already flags.

1. Run the toolchain

cargo fmt --check                 # formatting
cargo clippy --all-targets --all-features -- -D warnings   # lints as errors
cargo test                        # tests pass
cargo build --release 2>&1 | tail # warnings

If cargo-audit / cargo-deny are installed, run them for advisories: cargo audit. Fix or justify every clippy finding — don't #[allow] silently.

2. Read for what clippy misses

Unsafe. Every unsafe block needs a comment stating the invariant that makes it sound, and a reason a safe alternative won't do. Unjustified unsafe is the highest-priority finding.

Panics in library code. unwrap() / expect() / panic! / indexing v[i] / integer division — fine in tests and main, suspect in library paths. Prefer ?, ok_or, get, checked_*. Flag each one: can this input make it panic?

Error handling. Libraries: typed errors (thiserror). Applications: anyhow/eyre with context (.with_context(...)). Errors should say what failed and why. No Result<_, String> in real code.

Ownership & borrowing. Needless .clone() to dodge the borrow checker; String where &str would do; Vec<T> args where &[T] works; returning owned data that could be borrowed. APIs should take the least-owning type that works.

Idioms. Iterator chains over manual index loops; if let / let else / matches! over verbose matches; impl Trait where it reads cleaner; derive (Debug, Clone, PartialEq) rather than hand-writing; From/TryFrom for conversions. Newtypes over bare primitives for domain types.

Async (tokio). No blocking calls (std::fs, std::thread::sleep, heavy CPU) inside async tasks — use the async equivalents or spawn_blocking. Watch for holding a std/parking_lot lock across .await (deadlock risk); don't .await while holding a Mutex guard. Check that spawned tasks are awaited or intentionally detached, and that cancellation is handled.

Concurrency. Arc<Mutex<…>> that could be a channel or RwLock; data shared without Send/Sync thought-through.

3. Tests

  • Meaningful coverage of behavior and failure paths, not just the happy path.
  • #[should_panic] / Result-returning tests where apt.
  • Property tests (proptest) for parsers/encoders.
  • Doc examples (cargo test --doc) compile and run.

Severity

  • Blocker: unjustified unsafe, a reachable panic on user input, a .await-across-lock deadlock, UB.
  • Important: missing error context, needless clones in hot paths, blocking in async, missing tests on a failure path.
  • Minor: non-idiomatic but correct; naming; style clippy didn't catch.

Report findings as file:line + the concrete fix. Only flag what's worth the author's time.

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.