rust-best-practices
Write idiomatic, robust, maintainable Rust. Use this skill whenever you write, review, refactor, debug, or explain Rust code: new…
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"
Claude Code
$ npx -y skills add morganlinton/BeautifulRust --skill rust-review --agent claude-code
Codex
$ npx skills add morganlinton/BeautifulRust --skill rust-review -a codex -y
Cursor
$ npx skills add morganlinton/BeautifulRust --skill rust-review -a cursor -y
Gemini CLI
$ npx skills add morganlinton/BeautifulRust --skill rust-review -a gemini-cli -y
GitHub Copilot
$ npx skills add morganlinton/BeautifulRust --skill rust-review -a github-copilot -y
OpenCode
$ npx skills add morganlinton/BeautifulRust --skill rust-review -a opencode -y
Windsurf
$ npx skills add morganlinton/BeautifulRust --skill rust-review -a windsurf -y
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.
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.
or a diff. For a diff, review the changed lines and anything they break, not the whole file.
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.
project can't use.
(`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**
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).
integer overflow, wherever input from outside can reach them.
disagrees with `Eq`. These silently corrupt `BTreeMap`, `HashMap`, `sort`, and `dedup`.
closures called under a lock, or a poisoned lock recovered with `into_inner`.
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.
**Error handling**
public error type, an error enum without `Display` and `std::error::Error`, or `anyhow::Error` in a library's public API.
the path, line, or value that failed.
**API design** (strict for libraries)
`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.
iterator would do. Owned results are fine when callers need ownership or random access, or when building the collection is the function's job.
signatures, or third-party types leaking into the API.
a zero-argument `new()`, and `FromStr` instead of an ad-hoc `from_str` method.
ownership, and `Manager`/`Service`/`Util` names.
should be sealed.
**Idiom and clarity**
clearer, or the reverse.
long enough to need a loop.
external crates (a framework's documented prelude, such as `bevy::prelude`, is fine).
**Documentation and tests**
The `rust-best-practices` skill and its `references/` folder hold the full rules a
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.
Write idiomatic, robust, maintainable Rust. Use this skill whenever you write, review, refactor, debug, or explain Rust code: new…
Port code from C, C++, Python, Go, JavaScript, or TypeScript into idiomatic Rust that keeps the original behavior: ownership…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.