Rust Code Review Skill for Cursor
Review a Rust change for unwrap on library paths, needless unsafe, and async cancellation. Use for a Rust code review. Do not use for a non-Rust repository or to raise the MSRV without a reason.
name: "rust-code-review" description: "Review a Rust change for unwrap on library paths, needless unsafe, and async cancellation. Use for a Rust code review. Do not use for a non-Rust repository or to raise the MSRV without a reason." paths:
- "**/*.rs"
- "Cargo.toml"
Rust Code Review Skill for Cursor
Cursor skill rust-code-review for Rust. Run it with /rust-code-review, or let Agent select it when the request matches. paths only limits automatic surfacing.
When to run
Run this review for a Rust change: a public function, an async task, or a new unsafe block.
When to leave it
Stop for a non-Rust repository. Do not bump the MSRV or the toolchain unless the user asked.
Steps
- Read the MSRV and the toolchain file. A feature from a newer Rust used without a bump, or a silent MSRV bump, is a high finding.
- Search the diff for
unwrap,expect, andunsafe.unwrapon I/O or parsed input is a high finding.unsafewithout an invariant comment is a high finding. - Search for
.awaitwhile astd::sync::Mutexorparking_lotguard is in scope, and forstd::thread::sleepor blocking I/O inside an async function. Each is a high finding. Atokio::sync::Mutexheld across.awaitis valid. Do not flag it. - Check that a spawned task can finish when the parent is canceled.
- Run
cargo testfor the package only if the user asked. Otherwise writenot run.
Output
Findings with severity, file, line, the panic or safety hole, and a Result-based or safe alternative.
## Findings
- high | path:line | what is wrong | what to do instead
## No findings
Say "No findings" and list the files you opened. A search you skipped is not a clean result.
## Example
Input: an async function holds `std::sync::Mutex` across `.await`.
Output: high | src/worker.rs:31 | a std mutex guard must not be held across `.await` | drop the guard first, or use `tokio::sync::Mutex` when the guard must span the await.
Do not flag the valid pattern named in the standards. Flag the mistake next to it.
Stop
Stop when the user asks you to allow a clippy lint project-wide or to unwrap so the example is shorter.
Severity
high is a bug a caller can hit or a secret that leaks. medium is a broken contract that needs a specific input. low is a cleanup that does not change behaviour.