Claude-skill-registry code-review-rust
Rust-specific code review guidelines focusing on error handling, safety, and idiomatic patterns
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/code-review-rust" ~/.claude/skills/majiayu000-claude-skill-registry-code-review-rust && rm -rf "$T"
manifest:
skills/data/code-review-rust/SKILL.mdsource content
Rust Code Review
Includes all guidelines from code-review skill, plus Rust-specific rules.
No unwrap
in Non-test Code
unwrapThe reviewer MUST:
- Flag every
,unwrap()
, orunwrap_err()
outside tests.expect_err()
Preferred alternatives:
- Use
and propagate errors when the function returns?
.Result - Handle errors explicitly (map to a domain error, log and fallback, or early return).
- Use
only when failure is logically impossible or globally fatal, and the message explains why.expect()
Bad:
let cfg = read_config().unwrap();
Better:
let cfg = read_config()?;
Acceptable only with proof:
let cfg = read_config().expect( "config is validated and loaded at startup; reaching here means startup checks passed" );
The reviewer MUST reject vague
expect messages (e.g. "should not fail").
No panic!
in Non-test Code
panic!The reviewer MUST:
- Flag all
,panic!
, andtodo!
outside tests.unimplemented!
The reviewer SHOULD:
- Prefer returning and propagating proper errors.
- Fail early at startup via error returns instead of panics deep in logic.
- Encourage tests to use panics and unwraps only with clear messages (e.g.
).expect("reason")
unreachable!()
Usage
unreachable!()The reviewer MUST:
- Flag
unless a clear invariant explanation is provided.unreachable!()
It MAY be accepted if:
- The branch is genuinely impossible by construction.
- A comment documents the invariant (why this branch cannot be reached).
Otherwise, prefer returning a domain error instead of
unreachable!().
No Silently Ignored Errors (Non-test Code)
The reviewer MUST:
- Flag any ignored
orResult
unless the error is handled or logged, there is a clear comment explaining why ignoring is safe, or the error type isOption
and this is intentional.()
Bad:
let _ = do_something_fallible(); do_something_fallible().ok();
Acceptable:
if let Err(e) = do_something_fallible() { log::warn!("failed to do something: {}", e); } // Safe to ignore: telemetry failures do not affect correctness. let _ = send_telemetry(&metrics);
Tests MAY ignore errors, but explicit assertions are encouraged.
Idiomatic Rust and Built-ins
The reviewer SHOULD:
- Suggest
for simple error propagation instead of manual?
.match - Use iterator methods (
,map
,filter
, etc.) when they simplify logic.collect - Use
andOption
combinators (Result
,map
,and_then
, etc.) where they make code clearer.ok_or
The reviewer MUST NOT:
- Suggest overly clever refactors that hurt readability.
Performance
The reviewer SHOULD:
- Point out obvious waste such as repeated
orto_string
in hot loops, or missingclone
for growing collections.with_capacity
The reviewer MUST:
- Favor correctness and clarity over small micro-optimizations.
- Avoid speculative performance claims without a clear reason.
Documentation and Comments
The reviewer SHOULD:
- Ensure new or changed public APIs have basic
docs covering behavior, arguments, return values, and possible errors./// - Encourage comments where logic is non-obvious, especially around
code, concurrency and ordering assumptions, or invariants the type system does not enforce.unsafe
The reviewer SHOULD NOT:
- Request redundant "code-as-English" comments.