/rewrite-rs-skills:rust-code-reviewfrom rewrite-rs-skills
Reviews Rust code on two axes: standards (idioms, ownership, errors, API surface, unsafe) and spec (correctness against requirements). Runs separate passes, respects repo lint config, and defers to clippy.
Ships in rewrite-rs-skills. 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.
A review is a statement about what a change owes — to the request that asked
for it, and to the standards the repo already lives by. This skill runs both
statements as separate passes and merges them into one report led by a
verdict. It never restates a rule a smell maps to: the craft skills and
/rust-testing own the standards, and the review routes to them.
A single reviewer reading for both correctness-against-the-request and craft
does neither well: spec drift hides behind clean-looking code, and style nits
crowd out the missing edge case. Run a standards pass and a spec pass
as separate passes — as parallel sub-agents when the harness supports it,
sequentially when it does not — then merge. The prompts for both, the merge
rules, and the report shape are in REVIEW-PASSES.md.
Settle three things and print them at the head of the report, so the author can correct a wrong assumption before reaching a finding:
lib.rs, pub items other crates use, or a
published manifest means library. A library is held to the API bar strictly;
an application gets the simplicity bar instead — concrete types, a catch-all
error type, no speculative generality. Say which one was assumed.Cargo.toml, so that no recommendation
depends on a toolchain newer than the one the project builds with.Before either pass reads a line, run the verification step below and read the output. Anything clippy already reports is not a review finding; it is a build failure someone forgot to run. Put the tool output in the report grouped by cause — eight hits of one lint make one line, not eight — and say what ran and what could not. Reviewer attention is for what the tools cannot see: the judgment call, the missing edge case, the scope that crept in.
[lints.clippy] in Cargo.toml, a clippy.toml, a rustfmt.toml,
#![deny(...)] in the crate root. A finding that contradicts a level the repo
deliberately set is not a finding — it is a proposal, and it says so
explicitly. Never override the configured level, and never re-run at a
stricter one and report the extra hits as defects. Pedantic output is
proposals only, and only the ones that matter for this code, unless the repo
itself opted into pedantic. The smell baseline layers on top of this
configuration, never in place of it — a finding that the repo lint config
already permits is a finding about the config, raised separately.
Spend attention in this order, and never let a lower tier crowd out a higher one:
The concrete smells for each tier, with the owning skill, are in SMELLS.md.
What this skill adds beyond clippy: the judgment calls no lint can make. The
full table — the smell, how it shows up in a diff, why it is a defect, and the
owning skill — is SMELLS.md. The top ones:
clone at the call site — /ownership-not-cloneunwrap or expect on a path a caller controls — /rust-errorspub on an item with no external caller — /rust-api-design/type-driven-design/async-rustunsafe block with no // SAFETY: comment — /unsafe-rust/rust-testingAn #[allow(lint)] that outlived its reason is invisible and permanent.
#[expect(lint, reason = "...")] fails once the situation it was written for
goes away, which turns a silenced lint into one that reports itself when it
becomes stale. In review, an #[allow] with no reason is a finding; with a
reason it is a conversation. #[expect] and the reason key need Rust 1.81
or later; in a crate with an earlier MSRV, use #[allow] with a // comment
explaining why.
Three levels only: blocking (wrong behaviour, unsound, a reachable panic on
outside input, breaks the public API without a version bump, or an API choice
that turns into a semver break after release), should-fix (a real defect the
author would want to know about), note (a genuine improvement the author may decline).
Anything below that threshold is dropped rather than written down — a review
of forty nits and one soundness bug buries the soundness bug. No
praise-padding, and no restating the diff back to the author. The one
exception is the short keep list in the long report form, described in
REPORT-FORMAT.md.
Two shapes. The default, for a diff or a short review, is one line each, most
severe first: path:line — severity: what is wrong. What to do instead.
src/cache.rs:41 — blocking: guard held across .await; drop it before the fetch.
src/parse.rs:8 — should-fix: unwrap on caller input; return the ParseError instead.
src/lib.rs:102 — note: this fn takes String where &str would do.
A finding with no concrete fix is a question, and is phrased as one.
For a file, crate, or audit-style review, or when the user asks for a report,
use the long block instead: location, standard, consequence, and the
minimal edit that fixes it. Both shapes, the report skeleton, and the
closing are in REPORT-FORMAT.md.
Rules that hold in both shapes:
path:line, or "whole file" when there is no single line.It does not rewrite the code — findings, not patches, unless the author asks —
and it never runs cargo fmt on reviewed code; --check only.
It does not review a diff it cannot build: a check that cannot run is named in
the report, not papered over. It does not decide the parity contract of a
port; that is /port-to-rust.
Run before reporting, and quote the results in the report:
cargo fmt --check
cargo clippy --all-targets --all-features # at the repo configured level; add -- -D warnings only if there is no lint config
cargo test --all-features
If any of the three cannot run — no network for dependencies, no nightly for a required component, a file with no manifest around it — the report says which check did not run rather than implying a clean bill. For a loose file, copying it into a scratch crate to run the tools is fine; the original stays untouched.
If the repo has no lint configuration at all, end the report by suggesting
/setup-rust-skills, and cite two or three items in this report that the
lints it installs would have flagged.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub rewrite-rs/skills --plugin rewrite-rs-skills28 skills in this plugin
/async-rustWrite correct async Rust — runtime choice, Send and Sync bounds, cancellation safety, blocking work inside async contexts, and shared state across tasks. Use when writing or reviewing async code, when a future is held across an await point, when the user hits a Send bound error on a spawned task, when a runtime stalls or deadlocks, or when the user asks about tokio, select!, or spawn_blocking./idiomatic-rustWrite Rust that reads like Rust — iterator pipelines over index loops, From/Into over ad-hoc converters, derives over hand-written impls, newtypes over bare primitives. Use when writing new Rust, when reviewing Rust that reads like a translation from another language, when reaching for a classic design pattern (strategy, command, visitor) or a try/finally cleanup in Rust, when naming a constructor, accessor, iterator, or error type, or when the user asks how to make Rust code more idiomatic or less repetitive./ownership-not-cloneOther plugins' skills for the same job