Automatically review Rust code after edits to .rs files, providing pragmatic suggestions for idiomatic patterns, performance, safety, and code organization...
Pragmatic code review skill for Rust projects that provides actionable improvement suggestions.
Review the modified code against the Pragmatic Rust Guidelines in @/Users/ccustine/Downloads/pragmatic_rust.md
Provide feedback as an actionable checklist with this structure:
## 🦀 Rust Code Review
### ✅ What's Good
- [Specific positive patterns observed]
### 🔧 Suggested Improvements
**[Category: Universal, Libraries, Interoperability, UX, Resilience, Building, Applications, FFI, Safety, Performance, Documentation, AI]**
- [ ] **[File:Line]** - [Issue description]
- **Current**: `[problematic code snippet]`
- **Suggested**: `[improved code snippet]`
- **Why**: [Brief explanation of the benefit]
[Repeat for each issue found]
### 📊 Summary
- Issues found: [count by category]
- Priority: [High/Medium/Low issues]
Use this severity guide:
Current:
fn process_data(data: String) -> usize {
data.len()
}
// Called with: process_data(my_string.clone())
Suggested:
fn process_data(data: &str) -> usize {
data.len()
}
// Called with: process_data(&my_string)
Why: Avoids allocation; function doesn't need ownership.
Current:
let mut results = Vec::new();
for item in items.iter() {
if item.is_valid() {
results.push(item.process());
}
}
Suggested:
let results: Vec<_> = items.iter()
.filter(|item| item.is_valid())
.map(|item| item.process())
.collect();
Why: More idiomatic, potentially more efficient through iterator fusion.
Current:
let file = File::open("config.txt").unwrap();
Suggested:
let file = File::open("config.txt")
.map_err(|e| format!("Failed to open config: {}", e))?;
Why: Graceful error propagation instead of panicking.
.clone() used to satisfy borrow checker without understanding ownershipunwrap() in production code without explicit panic documentation+ instead of collecting into a bufferArc<Mutex<T>> when &T or channels would suffice#[derive(Debug)] on public typesCow<str> when sometimes cloning, sometimes borrowingSmallVec or ArrayVec for small, bounded collectionsBox<str> instead of String for immutable stringsstd::mem::replace or std::mem::take to avoid clonesOnceCell or lazy_static for one-time initializationThis skill activates when:
.rs files (auto-trigger after modifications)Do not activate for:
.unwrap() calls)Note: Present suggestions but let the user decide whether to apply them unless they explicitly ask you to make the changes.