Skip to content
Development
Skill

/rust-review

Review existing Rust code for idiom, API design, error handling, safety, and maintainability, and produce a prioritized report where every finding cites the rule it breaks and gives a concrete fix. Use this whenever the user asks to review, audit, critique, grade, or "check"

From plugin
beautiful-rust
2k3 skills

Claude Code

$ npx -y skills add morganlinton/BeautifulRust --skill rust-review --agent claude-code

SKILL.md

rust-review.SKILL.md
name: rust-review
description: >-
  Review existing Rust code for idiom, API design, error handling, safety, and
  maintainability, and produce a prioritized report where every finding cites the rule it
  breaks and gives a concrete fix. Use this whenever the user asks to review, audit,
  critique, grade, or "check" Rust code, a crate, a module, a .rs file, a diff, or a pull
  request, or asks what is wrong with their Rust or how to make it more idiomatic, even if
  they don't say "review". Pairs with the rust-best-practices skill, which covers writing
  new code.

Rust review

Review Rust code against the same rules the `rust-best-practices` skill uses for writing it, and report what to change. The output is a review, not a rewrite: the reader decides what to fix. Only rewrite code when the user asks for that.

1. Decide the scope

  • **What to read.** Review exactly what the user pointed at: a file, a module, a crate,

or a diff. For a diff, review the changed lines and anything they break, not the whole file.

  • **Library or application.** Check for a `lib.rs`, `pub` items used by other crates, or

a published `Cargo.toml`. Library code is held to the API-design rules strictly. Application code gets the simplicity rules instead: concrete types, `anyhow`-style errors, and no speculative generality. Say which you assumed at the top of the report.

  • **The edition and MSRV**, from `Cargo.toml`, so you don't recommend features the

project can't use.

  • **Frameworks.** If the crate depends on `bevy` or `bevy_ecs`, read the Bevy digest

(`bevy.md`) in the `rust-best-practices` skill's references first. It lists the Bevy conventions to leave alone (by-value system parameters, the prelude, plain-data components) and the ECS bugs to look for.

2. Run the tools first, if you can

If a Rust toolchain is available, run these from the crate root and fold the results into the report. They catch the mechanical issues, which leaves you free for design.

cargo fmt --check
cargo clippy --all-targets --all-features -- -W clippy::pedantic
cargo test

Don't paste raw clippy output. Group repeated warnings into one finding, and skip pedantic lints that don't matter for this code. If the tools aren't available, say so in the report and review by reading.

3. What to look for, in priority order

Work through these in order. The first two categories are where real bugs live.

**Correctness and soundness**

  • Undefined behavior: an `unsafe` block without a `// SAFETY:` comment, `transmute` to

cast enums or extend lifetimes, `unsafe impl Send`/`Sync` used to silence the compiler, or a safe function that can cause UB through safe calls (unsound).

  • Panics on reachable paths: `unwrap()`, `expect()`, indexing, `as` casts that wrap, or

integer overflow, wherever input from outside can reach them.

  • Trait contracts: a hand-written `Ord` with a derived `PartialEq`, or `Hash` that

disagrees with `Eq`. These silently corrupt `BTreeMap`, `HashMap`, `sort`, and `dedup`.

  • Lock hazards: a `MutexGuard` held across `.await` or returned to a caller, user

closures called under a lock, or a poisoned lock recovered with `into_inner`.

  • ECS bugs in Bevy code: two queries that can reach the same component mutably (a

B0001 panic on the first frame), systems that read each other's results with no order between them, and deferred `Commands` read back before they apply.

  • Destructors that panic, block, or can fail.

**Error handling**

  • Errors that callers can't use: `()`, `String`, or `Box<dyn Error>` as a library's

public error type, an error enum without `Display` and `std::error::Error`, or `anyhow::Error` in a library's public API.

  • Errors that lose information: `map_err(|_| ...)`, no `source()`, or messages without

the path, line, or value that failed.

  • Panics used for expected failures, or `catch_unwind` used as control flow.

**API design** (strict for libraries)

  • Parameters: `&String`, `&Vec<T>`, or `&Box<T>` instead of `&str`, `&[T]`, or `&T`; a

`bool` parameter in a public signature; ownership taken and then cloned, or a borrow cloned internally to get ownership; `impl Into<T>` in application code, or on a library function too rarely called to justify a copy per argument type.

  • Return types: a library function that collects into a `Vec` only to return it, when an

iterator would do. Owned results are fine when callers need ownership or random access, or when building the collection is the function's job.

  • Visibility: public fields that should be private, `Rc`, `RefCell`, or `Arc` in public

signatures, or third-party types leaking into the API.

  • Missing standard traits: `Debug` on public types, `Display` on errors, `Default` next to

a zero-argument `new()`, and `FromStr` instead of an ad-hoc `from_str` method.

  • Naming: `get_` prefixes on getters, `as_`/`to_`/`into_` that don't match their cost and

ownership, and `Manager`/`Service`/`Util` names.

  • Evolution: public enums or structs that should be `#[non_exhaustive]`, or traits that

should be sealed.

**Idiom and clarity**

  • Clones that exist only to satisfy the borrow checker.
  • Check-then-unwrap (`if x.is_some() { x.unwrap() }`), and `match` where a combinator is

clearer, or the reverse.

  • String building with `+`, hand loops that are clearer as iterators, or iterator chains

long enough to need a loop.

  • `HashMap` iteration order leaking into output or tests.
  • `#![deny(warnings)]` in source, `#[allow]` without a reason, and glob imports of

external crates (a framework's documented prelude, such as `bevy::prelude`, is fine).

**Documentation and tests**

  • Public items without docs, and docs that restate the name.
  • Missing `# Errors`, `# Panics`, or `# Safety` sections where they apply.
  • Doc examples that use `unwrap()` instead of `?`.
  • Logic with no tests, or tests that only restate constants.

The `rust-best-practices` skill and its `references/` folder hold the full rules a

Read more
@morganlinton
Ships withbeautiful-rust

Three standard Agent Skills and a lints config that teach coding agents to write, review, port, and enforce idiomatic Rust: rust-best-practices loads whenever an agent writes or changes Rust, and steers it toward idiomatic, robust, maintainable code.

Stars on GitHub

Momentum

stars in total
2.0k
Star history of morganlinton/BeautifulRust on GitHub, a chart by star-history.com

Other skills on beautiful-rust.

rust-port

rust-port

Port code from C, C++, Python, Go, JavaScript, or TypeScript into idiomatic Rust that keeps the original behavior: ownership…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react9d252k
@facebook@facebookInstall Skill

Questions about rust-review.

Which coding agents can use rust-review?
rust-review installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.