BeClaude

rust-design-review

New
GitHub TrendingGeneralby nikhil-salgaonkar

Conduct a thorough Rust design review of code, functions, modules, or entire crates, covering idioms, design patterns, and anti-patterns. Use this skill whenever the user pastes Rust code and asks for a review, design critique, pattern audit, or says things like "is this idiomatic?", "how would a Rust expert write this?", "review my Rust code", "what patterns am I missing?", "is this good Rust?", "do a design review", or "what am I doing wrong in Rust?". Also trigger for any request to refactor Rust code to be more idiomatic or better structured. Produces a structured review grounded in the rust-unofficial/patterns book (https://rust-unofficial.github.io/patterns/).

Community PluginView Source

Overview

Rust Design Review

A structured review skill grounded in the Rust Design Patterns book (rust-unofficial/patterns), covering idioms, design patterns, and anti-patterns.


Review Process

Work through these four phases in order. Skip any phase for which there is nothing to report.

Phase 1 — Understand context

Before reviewing, briefly note:

  • Scope: Is this a library crate, binary, module, or function snippet?
  • Audience: Public API (crate users) or internal code?
  • Rust edition if visible.

Library APIs get stricter scrutiny on ergonomics and trait implementations. Internal / binary code gets lighter scrutiny on those axes.

Phase 2 — Idiom scan

Work through the Idioms Checklist (see references/idioms.md). Flag every violation with a severity: 🔴 Must Fix, 🟡 Should Fix, 🔵 Consider.

Quick summary of what to scan for:

AreaCommon slip
Function arguments&String / &Vec<T> / &Box<T> instead of &str / &[T] / &T
String building+ operator chains instead of format!
ConstructorsMissing new associated fn; Default not derived when it could be
Ownership in enumsCloning to satisfy borrow checker instead of mem::take / mem::replace
Options / ResultsManual if let Some loops instead of iterator combinators
ClosuresCapturing whole env with move when only some vars are needed
Mutabilitymut persisting beyond the point where mutation is needed
Error returnConsuming an arg without returning it inside the error
Public API structsNot using #[non_exhaustive] when forward compatibility matters

Phase 3 — Pattern & anti-pattern audit

Work through the Patterns & Anti-patterns Checklist (see references/patterns.md).

Anti-patterns default to 🔴 Must Fix unless the surrounding context clearly justifies them (e.g. a deliberate clone in throwaway prototype code). Pattern opportunities are 🔵 Consider.

Key things to flag:

SmellLikely pattern to suggest
Long builder-like new(a, b, c, d, e...)Builder pattern
Mutex/resource accessed without guard typeRAII with guards
f32/u32/String used for domain values without newtypeNewtype pattern
Box<dyn Trait> list with manual dispatchCommand pattern or strategy via traits
Enum variants with complex logic duplicatedVisitor pattern
State machine logic scattered across methodsTypestate pattern
Clone called only to appease the borrow checkermem::take / restructure
Inheriting from base structs via DerefDeref polymorphism anti-pattern
#[deny(warnings)] in library codeReplace with #[warn] in CI
unsafe blocks spanning many linesContain unsafety in small modules

Phase 4 — Write the review

Use the Output Format below. Be specific: quote the offending code (short snippets), name the pattern from the book, and show the corrected version.


Output Format

code
## Rust Design Review

### Summary
<2–3 sentence overall assessment. Note the biggest wins and the most critical issues.>

### 🔴 Must Fix
<numbered list — each item: what, why, fixed version>

### 🟡 Should Fix
<numbered list — each item: what, why, improved version>

### 🔵 Consider
<numbered list — each item: pattern name, where it applies, brief sketch>

### ✅ What's Done Well
<bullet list — call out idioms and patterns already used correctly>

Omit any section that has no entries. Do not pad with generic praise.


Reference Files

  • references/idioms.md — Full idioms checklist with examples (read when doing the idiom scan)
  • references/patterns.md — Full patterns & anti-patterns catalogue (read when doing the audit)

The summary tables in Phases 2 and 3 are a quick index only; the reference files are authoritative. Always read the relevant reference file before writing your first comment for that phase, including for short snippets — relying on memory risks inventing rules that aren't in the book.


Tone & Scope

  • Be specific, not generic. "Use &str instead of &String on line 12" beats "prefer slices".
  • Quote brief code fragments. Show corrected code for every 🔴 item.
  • Prioritise by impact. A single 🔴 anti-pattern matters more than five 🔵 style notes.
  • Acknowledge trade-offs. Some patterns add boilerplate; say so.
  • Stay grounded in the patterns book; do not invent new rules.

Install & Usage

1
Create the skills directory
mkdir -p .claude/skills
2
Download the skill file
mkdir -p .claude/skills && curl -o .claude/skills/rust-design-review.md https://raw.githubusercontent.com/nikhil-salgaonkar/rust-design-review/main/SKILL.md
3
Invoke in Claude Code
/rust-design-review
View source on GitHub
code-reviewrefactoringdesignrust

Frequently Asked Questions

What is rust-design-review?

Conduct a thorough Rust design review of code, functions, modules, or entire crates, covering idioms, design patterns, and anti-patterns. Use this skill whenever the user pastes Rust code and asks for a review, design critique, pattern audit, or says things like "is this idiomatic?", "how would a Rust expert write this?", "review my Rust code", "what patterns am I missing?", "is this good Rust?", "do a design review", or "what am I doing wrong in Rust?". Also trigger for any request to refactor Rust code to be more idiomatic or better structured. Produces a structured review grounded in the rust-unofficial/patterns book (https://rust-unofficial.github.io/patterns/).

How to install rust-design-review?

To install rust-design-review, create the .claude/skills directory in your project, then run the curl command to download the skill file. Once installed, invoke it in Claude Code with /rust-design-review.

What is rust-design-review best for?

rust-design-review is a community categorized under General. It is designed for: code-review, refactoring, design, rust. Created by nikhil-salgaonkar.