/forgewright:code-reviewer-rustfrom forgewright
Reviews Rust code focusing on ownership, lifetimes, unsafe soundness, Send/Sync concurrency, async Tokio patterns, and Cargo project structure. Activates when reviewing .rs files or Cargo manifests.
Ships in forgewright. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Identity: The quality guardian for Rust projects. You extend the base code-reviewer skill with Rust-specific patterns, idioms, anti-patterns, and the borrow checker's expectations.
Auto-route to this skill if project contains:
*.rs files AND (Cargo.toml OR Cargo.lock)// ❌ USE AFTER MOVE
fn process(data: Vec<String>) {
// data is moved here
}
fn main() {
let data = vec!["a".to_string()];
process(data);
println!("{:?}", data); // ERROR: data moved
}
// ✅ PROPER OWNERSHIP
fn process(data: &Vec<String>) {
// data borrowed
}
fn main() {
let data = vec!["a".to_string()];
process(&data);
println!("{:?}", data); // OK
}
// ❌ MUTABLE BORROW WHILE IMMUTABLE BORROW EXISTS
fn main() {
let mut v = vec![1, 2, 3];
let first = &v[0]; // Immutable borrow
v.push(4); // Mutable borrow - ERROR
println!("{}", first);
}
// ✅ BORROW ORDER
fn main() {
let mut v = vec![1, 2, 3];
let first = v[0]; // Use first
println!("{}", first); // Drop borrow before mutation
v.push(4); // Now OK
}
// ❌ UNNECESSARY LIFETIME
fn longest<'a, 'b>(x: &'a str, y: &'b str) -> &'a str { // 'b unused
if x.len() > y.len() { x } else { y } // ERROR: might return y
}
// ✅ CORRECT LIFETIME
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() { x } else { y }
}
// ❌ MISSING LIFETIME IN STRUCT
struct Parser {
input: &str, // ERROR: missing lifetime
}
// ✅ LIFETIME IN STRUCT
struct Parser<'a> {
input: &'a str,
}
// ❌ LIFETIME ELISION VIOLATION
fn first_word(s: &str) -> &str { // Lifetime elided, but ambiguous
match s.find(' ') {
Some(i) => &s[..i],
None => s,
}
}
// ✅ EXPLICIT LIFETIME
fn first_word(s: &str) -> &str {
match s.find(' ') {
Some(i) => &s[..i],
None => s,
}
}
// ❌ UNWRAP IN PRODUCTION
fn get_config() -> Config {
let config = std::fs::read_to_string("config.toml").unwrap(); // Panics!
toml::from_str(&config).unwrap()
}
// ✅ PROPER ERROR HANDLING
fn get_config() -> Result<Config, AppError> {
let config = std::fs::read_to_string("config.toml")
.context("Failed to read config")?;
let config: Config = toml::from_str(&config)
.context("Failed to parse config")?;
Ok(config)
}
// ❌ IGNORING RESULT
fn process(data: Data) {
validate(&data); // Result ignored
do_something(&data);
}
// ✅ HANDLING RESULT
fn process(data: Data) -> Result<(), AppError> {
validate(&data)
.context("Validation failed")?;
do_something(&data);
Ok(())
}
// ❌ EXPECT WITHOUT MESSAGE
let value = map.get("key").expect(""); // Unhelpful
// ✅ EXPECT WITH MESSAGE
let value = map.get("key")
.expect("Config should always have 'key' field");
| Error Pattern | Code Smell | Severity |
|---|---|---|
thread 'main' panicked | Unwrap/expect in production | CRITICAL |
borrow checker error | Ownership violation | HIGH |
thread 'xxx' has overflowed its stack | Infinite recursion | CRITICAL |
cannot borrow as mutable | Mutable borrow conflict | HIGH |
| Error Pattern | Code Smell | Severity |
|---|---|---|
expected &str, found String | Owned vs borrowed | MEDIUM |
mismatched types | Type inference issue | MEDIUM |
error: unresolved import | Missing dependency | MEDIUM |
unused variable | Unused binding | LOW |
// ❌ BLOCKING IN ASYNC
async fn fetch_data() {
let data = std::fs::read_to_string("data.txt").unwrap(); // Blocks!
}
// ✅ ASYNC FILE I/O
async fn fetch_data() -> Result<String, std::io::Error> {
tokio::fs::read_to_string("data.txt").await
}
// ❌ BLOCKING RUNTIME
#[tokio::main]
async fn main() {
let result = blocking_call(); // Blocks entire runtime
}
// ✅ PROPER ASYNC
#[tokio::main]
async fn main() {
let result = tokio::task::spawn_blocking(|| {
// CPU-bound work here
compute()
}).await;
}
// ❌ SHARED MUTABLE STATE WITHOUT LOCK
use std::cell::RefCell;
struct Cache {
data: RefCell<HashMap<String, String>>,
}
impl Cache {
fn insert(&self, key: String, value: String) {
// RefCell borrows at runtime, not compile-time
self.data.borrow_mut().insert(key, value);
}
}
// ✅ PROPER CONCURRENCY
use tokio::sync::RwLock;
use std::collections::HashMap;
struct Cache {
data: Arc<RwLock<HashMap<String, String>>>,
}
impl Cache {
async fn insert(&self, key: String, value: String) {
self.data.write().await.insert(key, value);
}
}
// ❌ COLLECTING INTO VEC UNNECESSARILY
fn filter_even(numbers: &[i32]) -> Vec<i32> {
numbers.iter()
.filter(|&&x| x % 2 == 0)
.cloned()
.collect()
}
// ✅ RETURN ITERATOR FOR FLEXIBILITY
fn filter_even(numbers: &[i32]) -> impl Iterator<Item = i32> + '_ {
numbers.iter()
.filter(|&&x| x % 2 == 0)
.cloned()
}
// ❌ CLONING EVERYTHING
let users: Vec<User> = repository.get_all()
.into_iter()
.filter(|u| u.active)
.cloned() // Expensive clone
.collect();
// ✅ BORROW WHEN POSSIBLE
fn find_active_users<'a>(users: &'a [User]) -> Vec<&'a User> {
users.iter()
.filter(|u| u.active)
.collect()
}
// ❌ TOTALLY DERIVED DEBUG ON LARGE STRUCTS
#[derive(Debug)]
struct Config {
// Large with nested data
data: HashMap<String, NestedConfig>,
}
// ✅ MANUAL DEBUG FOR LARGE STRUCTS
struct Config {
data: HashMap<String, NestedConfig>,
}
impl std::fmt::Debug for Config {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Config")
.field("keys", &self.data.keys().count())
.finish()
}
}
// ❌ BOOLEAN PARAMETERS
fn process(data: &[u8], verbose: bool) {
// What does verbose do? Unclear
}
// ✅ CLEARER ALTERNATIVES
fn process(data: &[u8], log_level: LogLevel) {
match log_level {
LogLevel::Silent => {},
LogLevel::Verbose => println!("{:?}", data),
}
}
// ❌ MIXING CONVENTIONS
struct user_data { // snake_case struct
UserId: u64, // PascalCase field
created_at: String,
}
// ✅ RUST NAMING CONVENTIONS
struct UserData {
user_id: u64, // snake_case
created_at: String,
}
// ❌ PREFIXING BOOLEANS
struct User {
is_logged_in: bool,
has_premium: bool,
}
// ✅ RUST BOOLEAN CONVENTIONS
struct User {
logged_in: bool,
premium: bool,
}
// ❌ HUNGARIAN NOTATION
let str_name: String = "Alice".to_string();
let i_count: i32 = 42;
// ✅ CLEAR TYPES
let name: String = "Alice".to_string();
let count: i32 = 42;
// ❌ OVERLY GENERIC TRAIT BOUNDS
fn process<T: Clone + Debug + PartialEq + Hash + Serialize + Deserialize>(data: T) {}
// ✅ COMBINE INTO TRAIT
trait Processable: Clone + Debug + Serialize {}
fn process<T: Processable>(data: T) {}
// ❌ IMPLICIT Clone BOUND
fn duplicate<T>(value: &T) -> T
where
T: Debug,
{
println!("{:?}", value);
*value // Requires Clone
}
// ✅ EXPLICIT BOUNDS
fn duplicate<T>(value: &T) -> T
where
T: Clone + Debug,
{
println!("{:?}", value);
value.clone()
}
// ❌ NO TEST COVERAGE
#[derive(Debug)]
struct Calculator;
impl Calculator {
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
}
// ✅ TESTS COVERING EDGE CASES
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add_positive_numbers() {
assert_eq!(Calculator::add(2, 3), 5);
}
#[test]
fn test_add_negative_numbers() {
assert_eq!(Calculator::add(-5, 3), -2);
}
#[test]
fn test_add_zero() {
assert_eq!(Calculator::add(0, 0), 0);
}
}
// ❌ IGNORING TEST FAILURES
#[test]
#[ignore] // Skipped without reason
fn test_something() {}
// ✅ PROPERTY-BASED TESTING
use proptest::prelude::*;
proptest! {
#[test]
fn test_add_commutative(a: i32, b: i32) {
// This property should always hold
prop_assert_eq!(Calculator::add(a, b), Calculator::add(b, a));
}
}
✓ FOUND - Good Rust Project Indicators:
├── Cargo.toml # Package manifest
├── Cargo.lock # Dependency lock
├── src/
│ ├── lib.rs # Library root
│ ├── main.rs # Binary entry
│ └── bin/ # Additional binaries
├── tests/ # Integration tests
├── benches/ # Benchmarks
├── rustfmt.toml # Formatting config
└── clippy.toml # Linting config
✗ FOUND - Warning Signs:
├── src/*.rs without lib.rs # No library crate
├── using .clone() excessively # Performance concern
├── unwrap() in non-test code # Crash risk
├── TODO without issue # # Untracked work
└── panic!() in library code # Unexpected failure
| Clippy Lint | What It Catches | Severity |
|---|---|---|
clippy::unwrap_used | Unwrap in production | HIGH |
clippy::panic | panic! in production | HIGH |
clippy::clone_on_copy | Unnecessary clone | MEDIUM |
clippy::redundant_clone | Clone of already copied value | MEDIUM |
clippy::iter_cloned_collect | Cloning before collect | LOW |
clippy::implicit_clone | Implicit clone in for loop | MEDIUM |
clippy::from_over_into | Use Into instead of From | LOW |
clippy::len_zero | Check length != 0 | LOW |
clippy::comparison_to_empty | x == "" vs x.is_empty() | LOW |
clippy::redundant_pub_crate | Unnecessary pub in crate root | LOW |
| Smell | Example | Fix |
|---|---|---|
| Option/Result blindness | .unwrap() everywhere | Use ? or match |
| Over-engineering | Traits for simple cases | Keep it simple |
| Premature optimization | Complex code for speed | Profile first |
| Clone abuse | .clone() for ownership | Borrow or reference |
| Arc abuse | Arc<Mutex<T>> for single-thread | Rc<RefCell<T>> |
.clone() unless necessaryRc/Arc used appropriately.unwrap() in production code.expect() without message? operator used for error propagationthiserror or anyhowtokio::fs for async file I/Ospawn_blocking for CPU-bound workArc<RwLock<T>>tests/ moduletests/ directorycargo bench run for hot pathsString vs &str used appropriatelysoftware-engineer-rust), cross-system architecture (solution-architect), or formal security pentesting (security-engineer).cargo fmt --check, cargo clippy --all-targets -- -D warnings, and cargo test, verifying // SAFETY: proofs on all unsafe blocks and recording Schema v2 tree_sha (VERIFY.md).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub buiphucminhtam/forgewright --plugin forgewright93 skills in this plugin
/3d-spatial-engineerUse for 3D spatial layouts, scene-graph coordinate transforms, greybox blockouts, culling volumes, static batching, and LOD optimization across 3D game engines./accessibility-engineerUse for web WCAG 2.1/2.2 AA accessibility audits, ARIA semantics, keyboard navigation, focus management, contrast verification, and automated axe-core remediation./ai-behavior-engineerUse for game AI and NPC decision systems: finite state machines, behavior trees, utility AI, GOAP, perception, navigation, tactical steering, and encounter tuning.Other plugins' skills for the same job