This specialized Claude skill provides expert-level code reviews for Rust web API projects built with Axum, Actix-web, or Rocket. It focuses on optimizing asynchronous patterns, state management, and middleware implementation to ensure high-performance, safe, and maintainable backend services.
Use Cases
Refactoring Route Architecture: Identifying monolithic route files and suggesting modular organization using Router nesting and scoped services for better project scalability.
Async Performance Optimization: Detecting the use of blocking synchronous Mutexes or long-running operations in async contexts and recommending non-blocking Tokio alternatives.
Standardizing Error Handling: Implementing robust error management by converting internal failures into consistent, structured HTTP responses using the IntoResponse trait.
Extractor and Validation Audits: Ensuring request extractors are correctly ordered and integrated with validation crates to prevent runtime panics and security vulnerabilities.
State Management Review: Auditing dependency injection and shared state patterns to ensure thread safety and efficient resource pooling (e.g., database connections).
name
rust-api-reviewer
description
|
WHEN
Rust API review with Actix-web/Axum/Rocket, async patterns, extractors, middleware
"Which areas to review?"
Options:
- Full API review (recommended)
- Async handlers and patterns
- Extractors and validation
- State and dependency injection
- Error handling and responses
multiSelect: true
Detection Rules
Axum Patterns
Handler Organization
Check
Recommendation
Severity
All routes in main
Use Router::nest
MEDIUM
No route grouping
Group by resource
MEDIUM
Missing method routing
Use method_router
LOW
// BAD: All routes in main
#[tokio::main]
async fn main() {
let app = Router::new()
.route("/users", get(list_users).post(create_user))
.route("/users/:id", get(get_user).put(update_user))
.route("/products", get(list_products))
// ... 50 more routes
.with_state(state);
}
// GOOD: Organized with nest
fn user_routes() -> Router<AppState> {
Router::new()
.route("/", get(list_users).post(create_user))
.route("/:id", get(get_user).put(update_user).delete(delete_user))
}
fn product_routes() -> Router<AppState> {
Router::new()
.route("/", get(list_products).post(create_product))
.route("/:id", get(get_product))
}
fn api_routes() -> Router<AppState> {
Router::new()
.nest("/users", user_routes())
.nest("/products", product_routes())
}
#[tokio::main]
async fn main() {
let state = AppState::new().await;
let app = Router::new()
.nest("/api/v1", api_routes())
.layer(TraceLayer::new_for_http())
.with_state(state);
// ...
}