Rust Review Workflow
Expert-level Rust code audits with focus on safety, correctness, and idiomatic patterns.
Quick Start
/rust-review
Verification: Run the command with --help flag to verify availability.
When To Use
- Reviewing Rust code changes
- Auditing unsafe blocks
- Analyzing concurrency patterns
- Dependency security review
- Performance optimization review
When NOT To Use
- General code review without Rust - use unified-review
- Performance profiling - use parseltongue:python-performance pattern
Required Progress Items
rust-review:ownership-analysis
rust-review:error-handling
rust-review:concurrency
rust-review:unsafe-audit
rust-review:cargo-deps
rust-review:native-modeling
rust-review:idiomatic-elision
rust-review:coercion-params
rust-review:conversion-traits
rust-review:numeric-cast-safety
rust-review:mutable-static-audit
rust-review:match-wildcard
rust-review:transmute-audit
rust-review:float-equality
rust-review:mem-forget-audit
rust-review:repr-packed-audit
rust-review:evidence-log
rust-review:findings-verified
Progressive Loading
Load modules as needed based on review scope:
Quick Review (ownership and errors):
- See
modules/ownership-analysis.md for borrowing and lifetime analysis
- See
modules/error-handling.md for Result/Option patterns
Concurrency Focus:
- See
modules/concurrency-patterns.md for async and sync primitives
Safety Audit:
- See
modules/unsafe-audit.md for unsafe block documentation
- See
modules/mutable-static-audit.md for static mut globals and
their thread-safe replacements
- See
modules/numeric-cast-safety.md for truncating and
precision-losing as casts
- See
modules/match-wildcard.md for catch-all arms that defeat enum
exhaustiveness
- See
modules/transmute-audit.md for mem::transmute/transmute_copy
calls that reinterpret bytes with no layout check
- See
modules/repr-packed-audit.md for #[repr(packed)] layouts whose
field borrows become unaligned references
Correctness Audit:
- See
modules/float-equality.md for ==/!= against float literals
- See
modules/mem-forget-audit.md for mem::forget leaks and no-op
drop(&x) reference drops
Dependency Review:
- See
modules/cargo-dependencies.md for vulnerability scanning
Idiomatic Patterns:
- See
modules/builtin-preference.md for conversion traits and builtin preference
- See
modules/native-type-modeling.md for enums-over-primitives,
newtype, type-state, and derived ordering
- See
modules/idiomatic-elision.md for lifetime elision,
expression-oriented returns, and explicit -> () unit returns
- See
modules/coercion-params.md for &String/&Vec<T>/&PathBuf
parameters that defeat deref coercion (prefer &str/&[T]/&Path)
- See
modules/conversion-traits.md for impl Into that should be
impl From, and discarded try_into().unwrap() conversion errors
Core Workflow
- Ownership Analysis: Check borrowing, lifetimes, clone patterns
- Error Handling: Verify Result/Option usage, propagation
- Concurrency: Review async patterns, sync primitives
- Unsafe Audit: Document invariants, FFI contracts
- Dependencies: Scan for vulnerabilities, updates
- Evidence Log: Record commands and findings
Rust Quality Checklist
Safety
Correctness
Performance
Idioms
Output Format
## Summary
Rust audit findings
## Ownership Analysis
[borrowing and lifetime issues]
## Error Handling
[error patterns and issues]
## Concurrency
[async and sync patterns]
## Unsafe Audit
### [U1] file:line
- Invariants: [documented]
- Anchor: `verbatim source text at file:line`
- Risk: [assessment]
- Recommendation: [action]
## Native Type Modeling
[stringly-typed comparisons, boolean blindness, newtype/type-state notes]
## Idiomatic Elision
[needless lifetimes, trailing returns, explicit `-> ()` unit returns]
## Coercion Params
[`&String`/`&Vec<T>`/`&PathBuf` params that should be borrowed slices]
## Conversion Traits
[`impl Into` over `impl From`; discarded `try_into().unwrap()` errors]
## Numeric Cast Safety
[length-truncating, byte-narrowing, and f32 precision-losing `as` casts]
## Mutable Static Audit
[`static mut` globals and their thread-safe replacements]
## Match Wildcard
[catch-all `_ =>` arms that defeat enum exhaustiveness]
## Transmute Audit
[`mem::transmute`/`transmute_copy` calls and their typed replacements]
## Float Equality
[exact `==`/`!=` comparisons against float literals]
## Mem Forget Audit
[`mem::forget` leaks and no-op `drop(&x)` reference drops]
## Repr Packed Audit
[`#[repr(packed)]` layouts whose field borrows become unaligned]
## Dependencies
[cargo audit results]
## Recommendation
Approve / Approve with actions / Block
Verification: Run the command with --help flag to verify availability.
Verify Findings Are Grounded (rust-review:findings-verified)
Write findings to .review/findings.json, run the citation verifier
(Skill(imbue:review-core) Step 5), and drop or label UNVERIFIED any
the verifier rejects.
Exit Criteria
1---2name: rust-review3description: Audits Rust code for unsafe blocks, ownership issues, and Cargo dependency risks. Use when reviewing Rust code or before merging Rust changes.4globs: "**/*.rs"5alwaysApply: false6category: code-review7tags:8- rust9- ownership10- concurrency11- unsafe12- traits13- cargo14tools: []15usage_patterns:16- rust-audit17- unsafe-review18- dependency-audit19- concurrency-analysis20complexity: advanced21estimated_tokens: 40022progressive_loading: true23dependencies:24- imbue:proof-of-work25- imbue:review-core26- imbue:structured-output27modules:28- ownership-analysis.md29- error-handling.md30- concurrency-patterns.md31- unsafe-audit.md32- cargo-dependencies.md33- silent-returns.md34- collection-types.md35- sql-injection.md36- cfg-test-misuse.md37- error-messages.md38- duplicate-validators.md39- builtin-preference.md40- native-type-modeling.md41- idiomatic-elision.md42- coercion-params.md43- conversion-traits.md44- numeric-cast-safety.md45- mutable-static-audit.md46- match-wildcard.md47- transmute-audit.md48- float-equality.md49- mem-forget-audit.md50- repr-packed-audit.md51- model-specific-tells.md52- iterator-and-allocation-slop.md53- test-slop.md54- async-slop.md55metadata:56 source: https://skillmd.com/skills/athola/rust-review57---5859# Rust Review Workflow6061Expert-level Rust code audits with focus on safety, correctness, and idiomatic patterns.6263## Quick Start6465```bash66/rust-review67```68**Verification:** Run the command with `--help` flag to verify availability.6970## When To Use7172- Reviewing Rust code changes73- Auditing unsafe blocks74- Analyzing concurrency patterns75- Dependency security review76- Performance optimization review7778## When NOT To Use7980- General code review without Rust - use unified-review81- Performance profiling - use parseltongue:python-performance pattern8283## Required Progress Items84851. `rust-review:ownership-analysis`862. `rust-review:error-handling`873. `rust-review:concurrency`884. `rust-review:unsafe-audit`895. `rust-review:cargo-deps`906. `rust-review:native-modeling`917. `rust-review:idiomatic-elision`928. `rust-review:coercion-params`939. `rust-review:conversion-traits`9410. `rust-review:numeric-cast-safety`9511. `rust-review:mutable-static-audit`9612. `rust-review:match-wildcard`9713. `rust-review:transmute-audit`9814. `rust-review:float-equality`9915. `rust-review:mem-forget-audit`10016. `rust-review:repr-packed-audit`10117. `rust-review:evidence-log`10218. `rust-review:findings-verified`103104## Progressive Loading105106Load modules as needed based on review scope:107108**Quick Review** (ownership and errors):109- See `modules/ownership-analysis.md` for borrowing and lifetime analysis110- See `modules/error-handling.md` for Result/Option patterns111112**Concurrency Focus**:113- See `modules/concurrency-patterns.md` for async and sync primitives114115**Safety Audit**:116- See `modules/unsafe-audit.md` for unsafe block documentation117- See `modules/mutable-static-audit.md` for `static mut` globals and118 their thread-safe replacements119- See `modules/numeric-cast-safety.md` for truncating and120 precision-losing `as` casts121- See `modules/match-wildcard.md` for catch-all arms that defeat enum122 exhaustiveness123- See `modules/transmute-audit.md` for `mem::transmute`/`transmute_copy`124 calls that reinterpret bytes with no layout check125- See `modules/repr-packed-audit.md` for `#[repr(packed)]` layouts whose126 field borrows become unaligned references127128**Correctness Audit**:129130- See `modules/float-equality.md` for `==`/`!=` against float literals131- See `modules/mem-forget-audit.md` for `mem::forget` leaks and no-op132 `drop(&x)` reference drops133134**Dependency Review**:135- See `modules/cargo-dependencies.md` for vulnerability scanning136137**Idiomatic Patterns**:138- See `modules/builtin-preference.md` for conversion traits and builtin preference139- See `modules/native-type-modeling.md` for enums-over-primitives,140 newtype, type-state, and derived ordering141- See `modules/idiomatic-elision.md` for lifetime elision,142 expression-oriented returns, and explicit `-> ()` unit returns143- See `modules/coercion-params.md` for `&String`/`&Vec<T>`/`&PathBuf`144 parameters that defeat deref coercion (prefer `&str`/`&[T]`/`&Path`)145- See `modules/conversion-traits.md` for `impl Into` that should be146 `impl From`, and discarded `try_into().unwrap()` conversion errors147148## Core Workflow1491501. **Ownership Analysis**: Check borrowing, lifetimes, clone patterns1512. **Error Handling**: Verify Result/Option usage, propagation1523. **Concurrency**: Review async patterns, sync primitives1534. **Unsafe Audit**: Document invariants, FFI contracts1545. **Dependencies**: Scan for vulnerabilities, updates1556. **Evidence Log**: Record commands and findings156157## Rust Quality Checklist158159### Safety160- [ ] All unsafe blocks documented with SAFETY comments161- [ ] FFI boundaries properly wrapped162- [ ] Memory safety invariants maintained163- [ ] No `static mut` globals; shared state uses `OnceLock`/`LazyLock`,164 atomics, or a `Mutex`/`RwLock`165- [ ] No `mem::transmute`/`transmute_copy`; bytes converted with166 `from_le_bytes`/`from_bits`/`bytemuck` or pointers with `.cast()`167- [ ] `#[repr(packed)]` fields copied out before borrowing (no unaligned168 references)169- [ ] No `mem::forget` leaks (use `ManuallyDrop`/scope) and no no-op170 `drop(&x)` reference drops171- [ ] `mlock`/`munlock` calls: RLIMIT verified, page-aligned,172 ENOMEM handled173174### Correctness175- [ ] Error handling complete176- [ ] Concurrency patterns sound177- [ ] Lossy `as` casts (length truncation, `as u8`/`i8`, `as f32`)178 replaced with `TryFrom`/`From`179- [ ] Enum matches exhaustive; no `_ => unreachable!()`/`panic!`/`{}`180 catch-alls181- [ ] Floats compared with a tolerance, not exact `==`/`!=` against a182 float literal183- [ ] Tests cover critical paths184185### Performance186- [ ] No unnecessary allocations187- [ ] Borrowing preferred over cloning188- [ ] Async properly non-blocking189190### Idioms191- [ ] Standard traits implemented192- [ ] Conversion traits preferred over helper functions193- [ ] Stringly-typed values and boolean flags modeled as enums194- [ ] Domain invariants encoded with newtypes (private field +195 validating constructor) or type-state where warranted196- [ ] Comparison/ordering traits derived, not hand-written197- [ ] Lifetimes elided where elision rules apply; `'_` in paths198- [ ] Trailing `return` dropped in favor of the tail expression199- [ ] Explicit `-> ()` unit returns dropped (default is elided)200- [ ] Parameters take `&str`/`&[T]`/`&Path`, not `&String`/`&Vec<T>`/201 `&PathBuf` (deref coercion accepts both, so the slice is more general)202- [ ] Conversions implement `From`/`TryFrom`, not `Into`/`TryInto`; a203 fallible conversion's error is propagated, not `unwrap()`ped204- [ ] Error types well-designed205- [ ] Documentation complete206207## Output Format208209```markdown210## Summary211Rust audit findings212213## Ownership Analysis214[borrowing and lifetime issues]215216## Error Handling217[error patterns and issues]218219## Concurrency220[async and sync patterns]221222## Unsafe Audit223### [U1] file:line224- Invariants: [documented]225- Anchor: `verbatim source text at file:line`226- Risk: [assessment]227- Recommendation: [action]228229## Native Type Modeling230[stringly-typed comparisons, boolean blindness, newtype/type-state notes]231232## Idiomatic Elision233[needless lifetimes, trailing returns, explicit `-> ()` unit returns]234235## Coercion Params236[`&String`/`&Vec<T>`/`&PathBuf` params that should be borrowed slices]237238## Conversion Traits239[`impl Into` over `impl From`; discarded `try_into().unwrap()` errors]240241## Numeric Cast Safety242[length-truncating, byte-narrowing, and f32 precision-losing `as` casts]243244## Mutable Static Audit245[`static mut` globals and their thread-safe replacements]246247## Match Wildcard248[catch-all `_ =>` arms that defeat enum exhaustiveness]249250## Transmute Audit251[`mem::transmute`/`transmute_copy` calls and their typed replacements]252253## Float Equality254[exact `==`/`!=` comparisons against float literals]255256## Mem Forget Audit257[`mem::forget` leaks and no-op `drop(&x)` reference drops]258259## Repr Packed Audit260[`#[repr(packed)]` layouts whose field borrows become unaligned]261262## Dependencies263[cargo audit results]264265## Recommendation266Approve / Approve with actions / Block267```268**Verification:** Run the command with `--help` flag to verify availability.269270## Verify Findings Are Grounded (`rust-review:findings-verified`)271272Write findings to `.review/findings.json`, run the citation verifier273(`Skill(imbue:review-core)` Step 5), and drop or label `UNVERIFIED` any274the verifier rejects.275276## Exit Criteria277278- [ ] All unsafe blocks audited279- [ ] Concurrency patterns verified280- [ ] Dependencies scanned281- [ ] Evidence logged282- [ ] Action items assigned283- [ ] Every reported finding carries a `Location` + verbatim `Anchor` confirmed284 by `citation_verifier.py` (exit `0`), or unverified findings were dropped285 or labeled `UNVERIFIED`