
rust-code-review
Review Rust changes for correctness, memory and thread safety, error semantics, unnecessary allocation or cloning, lock scope, API compatibility, test gaps, documentation, and dependency risk, applying the Rust API Guidelines checklist (C-PANIC, C-UNWRAP, C-TRANSMUTE, C-BOOL, C-NEWTYPE, C-COMMON-TRAITS, C-CONVERT, C-SEALED, C-NON-EXHAUSTIVE). Use when reviewing Rust diffs, pull requests, libraries, unsafe boundaries, or production incidents; report actionable findings by severity before summaries, route automated formatting or lint policy to rust-style-clippy, and route API shape decisions (trait sealing, error taxonomy, newtype design, builder patterns) to rust-api-design.
- Installs
- 126
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/full-stack-skills/rust-skills --skill rust-code-review- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads rust-code-review automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Rust Code Review
Review the actual diff and its callers, not an isolated snippet or a generic checklist. Prioritize defects that can change behavior, violate invariants, expose data, deadlock, panic unexpectedly, or break public APIs.
Scope and Routing
Use this skill to review:
- ownership, borrowing, lifetime, and drop behavior;
unsafepreconditions and safe-wrapper soundness;- error propagation, panic paths, partial updates, and rollback;
- concurrency, cancellation, lock ordering, and task lifecycle;
- public API, semver, feature, target, and MSRV compatibility;
- allocation, cloning, blocking, serialization, and hot-path costs;
- tests, documentation, dependencies, and operational failure paths.
Route format and lint configuration to rust-style-clippy, deep unsafe or ABI analysis to rust-unsafe-ffi, concurrency design to rust-concurrency, dependency resolution to rust-cargo-build, test implementation to rust-testing, and API shape decisions (trait sealing, newtype design, error taxonomy, builder patterns) to rust-api-design.
Workflow
1. Establish the review contract
Inspect the repository instructions, changed files, surrounding symbols, callers, tests, manifests, lockfile, declared MSRV, enabled features, and supported targets. Determine whether the change affects a private implementation, public library API, persistent data, wire format, database schema, or security boundary.
Use the narrowest relevant commands:
git diff --check
cargo metadata --format-version 1
cargo check --workspace --all-targets --all-features
cargo test --workspace --all-targets --all-features
cargo clippy --workspace --all-targets --all-features -- -D warnings
Do not claim a command passed unless it ran. Do not treat successful compilation as proof of behavioral correctness.
2. Trace behavior through boundaries
For each changed path, follow input, state transitions, side effects, errors, cleanup, and observable output. Check:
- whether references outlive their owners or guards;
- whether moves, clones, or allocations change cost or semantics;
- whether
OptionandResultpreserve absence and failure information; - whether resources are released on early return, cancellation, panic, and shutdown;
- whether transactions and multi-step mutations are atomic where required;
- whether retries are bounded and safe for the operation;
- whether logs, Debug output, metrics, or errors expose secrets.
3. Review Rust-specific hazards
Unsafe and FFI
- Require a documented safety invariant for every unsafe API and implementation.
- Keep unsafe blocks minimal and enable
unsafe_op_in_unsafe_fnexplicitly. - Verify provenance, validity, alignment, initialization, aliasing, layout, unwinding, ownership transfer, and deallocation symmetry.
- Treat manual
SendorSyncimplementations as unsafe contracts, not marker boilerplate.
Concurrency
- Check lock ordering and whether guards cross
.await, callbacks, blocking I/O, or user code. - Require bounded queues, overload behavior, cancellation ownership, supervised tasks, and deterministic shutdown.
- Distinguish I/O concurrency from CPU parallelism; adding tasks or workers is not automatically a performance fix.
Error handling
- Flag
unwrap,expect, indexing, assertions, integer overflow assumptions, and unreachable branches when user or external input can reach them. - Preserve structured library errors; add context at application boundaries without leaking internals.
- Verify that cleanup or rollback failures are not silently discarded.
API and compatibility
- Check visibility, trait bounds, auto traits, object safety,
#[non_exhaustive], feature combinations, target-specific code, and MSRV. - Treat generated methods, serialization shapes, error variants, and public feature names as API surface.
- Require explicit migration for persisted or transmitted formats.
3a. API Guidelines Review Lens
For every touched public item, scan the diff against the four chapters of the Rust API Guidelines checklist. Confirm each match with a concrete caller before raising it, and route design-level fixes to rust-api-design. The full table per chapter, severities, and suggested comments live in API Guidelines Checklist.
- Dependability — flag
panic!,unwrap,expect,unreachable!, slice indexing, andtransmuteinside public methods that accept caller input (C-PANIC, C-UNWRAP, C-TRANSMUTE). - Type safety — flag functions taking multiple
boolparameters or interchangeable bare primitives where enums or newtypes would prevent argument-order bugs (C-BOOL, C-NEWTYPE). - Interoperability — flag public types missing
Debug/Clone/PartialEq, and non-smart-pointer types implementingDerefto borrow methods (C-COMMON-TRAITS, C-CONVERT). - Future-proofing — flag extensible public traits that are not sealed and library error or config enums without
#[non_exhaustive](C-SEALED, C-NON-EXHAUSTIVE).
Do not flag unwrap/expect in #[cfg(test)] modules, idiomatic infallible unsafe in FFI shims with documented invariants, or single-purpose bool setters; see the false-positives list in the checklist.
4. Review performance with evidence
Report an allocation, clone, lock, or algorithm as a performance finding only when it is plausibly material on the changed path. Prefer measurements over aesthetic rewrites. Check blocking work on async executors, accidental quadratic behavior, repeated parsing, oversized enum variants, unnecessary buffering, and unbounded growth.
5. Verify tests and documentation
Require tests at the boundary where regressions are observable. Cover success, invalid input, failure after partial progress, cancellation, concurrency, feature and platform variants, and public examples. Ensure public safety requirements, errors, panics, and compatibility constraints are documented and doctests remain executable.
Read Review Tools and Checklist when choosing additional analysis tools. Read Review Scenarios for expected finding shape. Read API Guidelines Checklist when applying the C-PANIC / C-UNWRAP / C-TRANSMUTE / C-BOOL / C-NEWTYPE / C-COMMON-TRAITS / C-CONVERT / C-SEALED / C-NON-EXHAUSTIVE rules to a public API surface.
Finding Format
Return findings before any summary. Each finding must contain:
- severity and concise title;
- the tightest file and line range;
- the concrete failing condition or caller path;
- user, security, compatibility, or operational impact;
- a minimal correction or test that proves the fix.
Do not report style-only preferences as correctness findings. If no actionable finding remains, say so and state the residual verification gaps.
Completion Criteria
- Review the diff, callers, tests, manifests, and relevant feature or target boundaries.
- Report reproducible findings in severity order with tight locations.
- Separate confirmed defects from risks that still require evidence.
- Run or explicitly account for relevant checks.
- Avoid silently broadening the change or implementing fixes unless requested.
Upstream Sources
Data Privacy
This skill does not collect, store, or transmit user data. Confirm authorization before querying private registries or external review systems.
FAQ
What does the rust-code-review skill do?
Review Rust changes for correctness, memory and thread safety, error semantics, unnecessary allocation or cloning, lock scope, API compatibility, test gaps, documentation, and dependency risk, applying the Rust API Guidelines checklist (C-PANIC, C-UNWRAP, C-TRANSMUTE, C-BOOL, C-NEWTYPE, C-COMMON-TRAITS, C-CONVERT, C-SEALED, C-NON-EXHAUSTIVE). Use when reviewing Rust diffs, pull requests, libraries, unsafe boundaries, or production incidents; report actionable findings by severity before summaries, route automated formatting or lint policy to rust-style-clippy, and route API shape decisions (trait sealing, error taxonomy, newtype design, builder patterns) to rust-api-design.
How do I install rust-code-review?
Run npx skills add https://github.com/full-stack-skills/rust-skills --skill rust-code-review in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/rust-code-review/ (personal) or .claude/skills/rust-code-review/ (project).
Which AI agents can use rust-code-review?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is rust-code-review safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains rust-code-review?
It is published by full-stack-skills in full-stack-skills/rust-skills. It has 126 recorded installs.
More from full-stack-skills/rust-skills
rust-testing
full-stack-skills/rust-skills
Design, implement, and validate Rust tests, including unit, integration, doctest, compile-fail, property, fuzz, benchmark, coverage, async, concurrency, process, daemon, IPC, terminal, platform, and hardware-facing test strategies. Use when users ask for Rust test architecture, flaky-test diagnosis, coverage gates, benchmarks, trybuild, cargo-nextest, real-process tests, or failure-path verification.
rust-concurrency
full-stack-skills/rust-skills
Open the skill to read its SKILL.md instructions.
rust-style-clippy
full-stack-skills/rust-skills
Open the skill to read its SKILL.md instructions.
rust-performance
full-stack-skills/rust-skills
Open the skill to read its SKILL.md instructions.
rust-cargo-build
full-stack-skills/rust-skills
Open the skill to read its SKILL.md instructions.
rust-workspace
full-stack-skills/rust-skills
Open the skill to read its SKILL.md instructions.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.