/beautiful-rust:rust-reviewfrom beautiful-rust
Reviews Rust code for idiom, API design, error handling, safety, and maintainability, producing a prioritized report with rule citations and concrete fixes. Activates on review, audit, critique, or check requests.
Ships in beautiful-rust. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
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.Cargo.toml, so you don't recommend features the
project can't use.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.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.
Work through these in order. The first two categories are where real bugs live.
Correctness and soundness
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).unwrap(), expect(), indexing, as casts that wrap, or
integer overflow, wherever input from outside can reach them.Ord with a derived PartialEq, or Hash that
disagrees with Eq. These silently corrupt BTreeMap, HashMap, sort, and dedup.MutexGuard held across .await or returned to a caller, user
closures called under a lock, or a poisoned lock recovered with into_inner.Commands read back before they apply.Error handling
(), 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.map_err(|_| ...), no source(), or messages without
the path, line, or value that failed.catch_unwind used as control flow.API design (strict for libraries)
&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.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.Rc, RefCell, or Arc in public
signatures, or third-party types leaking into the API.Debug on public types, Display on errors, Default next to
a zero-argument new(), and FromStr instead of an ad-hoc from_str method.get_ prefixes on getters, as_/to_/into_ that don't match their cost and
ownership, and Manager/Service/Util names.#[non_exhaustive], or traits that
should be sealed.Idiom and clarity
if x.is_some() { x.unwrap() }), and match where a combinator is
clearer, or the reverse.+, 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
# Errors, # Panics, or # Safety sections where they apply.unwrap() instead of ?.The rust-best-practices skill and its references/ folder hold the full rules and their
reasoning. If it is installed, read the relevant reference when a finding needs a rule
you're unsure of. Otherwise, rely on the summary above.
Use this structure:
# Rust review: <what was reviewed>
<One paragraph: what the code does, library or application, overall verdict, and the
single most important thing to fix. Say whether clippy and tests were run.>
## Must fix
### 1. <Short title> (`src/file.rs:42`)
**Rule:** <rule name and source, e.g. "Errors implement std::error::Error (C-GOOD-ERR,
Rust API Guidelines)">
**Problem:** <what is wrong and the concrete consequence, one or two sentences>
**Fix:**
```rust
<the smallest code change that fixes it>
```
## Should fix
### 2. ...
## Consider
### 3. ...
## What's already good
- <2 to 4 specific things the code does well>
How to sort findings:
Rules for each finding:
file:line for every finding (write whole file for a finding
that has no single location, such as missing tests), and cite the rule with its source:
an API Guidelines code such as C-GETTER, an Effective Rust item number, a Microsoft
guideline code such as M-PANIC-ON-BUG, a clippy lint name, or "Google Rust Style
Guide". A reader should be able to look the rule up.unwrap() calls on parse results", listing
the lines, rather than eight findings.If the project lacks a [lints] table, end the report by suggesting the BeautifulRust
lints config (lints/lints.toml and lints/clippy.toml in the BeautifulRust repo,
https://github.com/morganlinton/BeautifulRust). It makes clippy catch most of the
mechanical findings above automatically. Name two or three findings from this review that
it would have caught.
evals/review-bevy-arena/case.yaml (opens in a new tab)evals/review-bevy-arena/files/Cargo.lock (opens in a new tab)evals/review-bevy-arena/files/Cargo.toml (opens in a new tab)evals/review-bevy-arena/files/src/lib.rs (opens in a new tab)evals/review-bevy-arena/files/tests/arena.rs (opens in a new tab)evals/review-bevy-arena/graders/01-flags-query-conflict.md (opens in a new tab)evals/review-bevy-arena/graders/02-flags-deferred-wave-ordering.md (opens in a new tab)evals/review-bevy-arena/graders/03-flags-single-unwrap.md (opens in a new tab)evals/review-bevy-arena/graders/04-flags-bool-parameter.md (opens in a new tab)evals/review-bevy-arena/graders/05-keeps-system-params-by-value.md (opens in a new tab)evals/review-bevy-arena/graders/06-accepts-bevy-prelude.md (opens in a new tab)evals/review-bevy-arena/graders/07-passive-components-keep-pub-fields.md (opens in a new tab)evals/review-bevy-arena/graders/08-type-complexity-handled-as-ecs.md (opens in a new tab)evals/review-bevy-arena/graders/09-findings-cite-locations-and-rules.md (opens in a new tab)evals/review-bevy-arena/graders/10-fixes-shown-as-code.md (opens in a new tab)evals/review-bevy-arena/graders/11-code-left-unchanged.md (opens in a new tab)evals/review-bevy-arena/place-files.sh (opens in a new tab)evals/review-bevy-arena/prompt.md (opens in a new tab)evals/review-inventory-module/case.yaml (opens in a new tab)evals/review-inventory-module/files/inventory.rs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub morganlinton/beautifulrust --plugin beautiful-rust3 skills in this plugin
/rust-best-practicesWrite idiomatic, robust, maintainable Rust. Use this skill whenever you write, review, refactor, debug, or explain Rust code: new crates, modules, functions, structs, traits, error types, async code, unsafe or FFI code, Cargo.toml, tests, or rustdoc. Trigger on any mention of Rust, cargo, crates, .rs files, the borrow checker, lifetimes, traits, clippy, or rustfmt, even when the user does not ask for "best practices" or "idiomatic" code. Synthesized from the Google Rust Style Guide, the Rust API Guidelines, Effective Rust, Rust Design Patterns, and Microsoft's Pragmatic Rust Guidelines./rust-portPort code from C, C++, Python, Go, JavaScript, or TypeScript into idiomatic Rust that keeps the original behavior: ownership instead of manual memory, Result instead of error codes and exceptions, enums instead of flag ints and magic strings, and tests that prove the port matches. Use this whenever the user asks to port, translate, convert, migrate, or rewrite code in Rust ("rewrite this in Rust", "what would this look like in Rust", "move this module to Rust"), even if they don't say "port". Pairs with the rust-best-practices skill, which covers the target code's style.Other plugins' skills for the same job