rust-patterns
Skill96 starsChanged 7 months agoMITView on GitHub
Analyze Rust codebase for design patterns, idioms, and anti-patterns. Provides detection, suggestion, and evaluation modes for Rust code quality. Keywords: rust, patterns, analysis, idioms, anti-patterns, code-quality
14 other projects use a version of this.
Adopted by
Most recently taken up by
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- MortuisVMain/ai-agent-superpowerstheir own version, first seen Sep 15, 2026
- talayash/agentriumtheir own version, first seen Sep 11, 2026
- lukemurraynz/hve-agent-skillstheir own version, first seen Aug 27, 2026
- idexal/idexal-skillstheir own version, first seen Aug 26, 2026
- SamuelNDCE/claude-super-skill-librarytheir own version, first seen Aug 1, 2026
Used with
Projects with it also use kotlin-testing, carrier-relationship-management and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
tpavanipradeepSkillkotlin-testing
Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.
Also in 4 projects that use this
InfopibeSkillcarrier-relationship-management
Codified expertise for managing carrier portfolios, negotiating freight rates, tracking carrier performance, allocating freight, and maintaining strategic carrier relationships. Informed by transportation managers with 15+ years experience. Includes scorecarding frameworks, RFP processes, market intelligence, and compliance vetting. Use when managing carriers, negotiating rates, evaluating carrier performance, or building freight strategies.
Also in 5 projects that use this
InfopibeSkillralphinho-rfc-pipeline
RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.
Also in 5 projects that use this
mryeastcodeSkillsanta-method
Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.
Also in 4 projects that use this
tpavanipradeepSkillbun-runtime
Bun as runtime, package manager, bundler, and test runner. When to choose Bun vs Node, migration notes, and Vercel support.
Also in 5 projects that use this
saxon-ySkillconfigure-ecc
Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.
Also in 5 projects that use this
- +1 more from Infopibe
- +1 more from tpavanipradeep
Other versions14 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 14
- loulanyue/awesome-claude-notes★ 272same name
- tpavanipradeep/everything-claude-code★ 134same name
- templetongroup/radiant★ 113same name
- Jamkris/everything-gemini-code★ 87same name
- talayash/agentrium★ 42same name
- idexal/idexal-skills★ 13same name
- Jonathan0823/opencode-config★ 8same name
- peopleforrester/claude-dotfiles★ 3same name
- JunMystery/Agent-Guidance-Python★ 2same name
- lukemurraynz/hve-agent-skills★ 2same name
4 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- backend-architectSkill
- ccboard-rememberSkill
- code-simplifierSkill
- cybersecSkill
- design-patternsSkill
- issue-triageSkill
- performanceSkill
- pr-triageSkill
- ratatuiSkill
- rust-expertSkill
- security-guardianSkill
- shipSkill
- tdd-rustSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 324
All errors have context?
- Distinctive: line 325
No unwrap/panic in library code?
- Distinctive: line 329
No allocations in hot paths?
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
rust-patterns Skill
Comprehensive Rust pattern analysis tool for detecting, suggesting, and evaluating design patterns in Rust codebases.
Overview
This skill provides three complementary modes for Rust pattern analysis:
- Detection Mode: Scan codebase to identify existing patterns and anti-patterns
- Suggestion Mode: Recommend patterns to address code smells and improve design
- Evaluation Mode: Score pattern implementation quality against best practices
Complementary to: @RUST_PATTERNS.md (always-active rules) - this skill provides optional deep analysis.
Invocation
# Detection - scan codebase for patterns
/rust-patterns detect [path]
# Suggestion - recommend patterns for code smells
/rust-patterns suggest [path]
# Evaluation - score pattern implementation quality
/rust-patterns evaluate [path] [--pattern=<name>]
# Help
/rust-patterns --helpMode 1: Detection
Purpose: Identify patterns and anti-patterns currently in the codebase.
Workflow:
1. Scan → Glob for *.rs files in target path
2. Search → Grep for pattern signatures (ownership, newtype, builder, etc.)
3. Detect Anti-patterns → Grep for .clone(), .unwrap(), Arc<Mutex>, blocking ops
4. Classify → Categorize as idiom/pattern/anti-pattern
5. Score Confidence → 0.0-1.0 based on signature strength
6. Report → JSON output with file locations and recommendationsExample:
/rust-patterns detect src/Output Format:
{
"scan_summary": {
"files_scanned": 42,
"patterns_found": 15,
"anti_patterns_found": 8,
"confidence_avg": 0.87
},
"patterns": {
"newtype": [
{
"file": "src/models/stats.rs",
"lines": "12-15",
"confidence": 0.92,
"code": "struct SessionId(String);",
"note": "✅ Good: Zero-cost type safety"
}
],
"builder": [
{
"file": "src/store.rs",
"lines": "45-78",
"confidence": 0.88,
"code": "impl DataStoreBuilder { ... }",
"note": "✅ Good: Type-state builder pattern"
}
],
"raii": [
{
"file": "src/guard.rs",
"lines": "23-35",
"confidence": 0.95,
"code": "impl Drop for FileGuard { ... }",
"note": "✅ Good: Automatic cleanup"
}
]
},
"anti_patterns": {
"excessive_clone": [
{
"file": "src/app.rs",
"lines": "45",
"severity": "high",
"code": ".clone().process().clone()",
"suggestion": "Use &DataStore instead of cloning",
"impact": "Performance: Multiple heap allocations"
}
],
"unwrap_in_production": [
{
"file": "src/parsers/session.rs",
"lines": "89",
"severity": "critical",
"code": "serde_json::from_str(&content).unwrap()",
"suggestion": "Use ? operator with .context()",
"impact": "Safety: Will panic on malformed input"
}
],
"blocking_in_async": [
{
"file": "src/api/handlers.rs",
"lines": "123",
"severity": "high",
"code": "std::fs::read(path)",
"suggestion": "Use tokio::fs::read() or spawn_blocking",
"impact": "Performance: Blocks async executor"
}
]
},
"recommendations": [
"Fix 3 critical anti-patterns before merge",
"Consider extracting builder pattern in src/config.rs",
"Review clone usage in src/app.rs (8 occurrences)"
]
}Detection Signatures: See signatures/detection-rules.yaml
Mode 2: Suggestion
Purpose: Recommend specific patterns to address identified code smells.
Workflow:
1. Code Smell Detection → Identify problems (long functions, switch on type, global state)
2. Pattern Matching → Map smells to applicable Rust patterns
3. Crate-Specific Analysis → tokio/serde/anyhow-specific suggestions
4. Priority Ranking → Score by (impact × feasibility)
5. Report → Markdown with examples and implementation stepsExample:
/rust-patterns suggest src/parsers/Output Format:
# Pattern Suggestions for src/parsers/
## High Priority
### 1. Newtype Pattern for SessionId (Impact: High, Effort: Low)
**Location**: `src/parsers/session.rs:45-89`
**Problem**: Using raw `String` for session IDs allows mixing with other strings
**Current Code**:
```rust
fn get_session(id: String) -> Option<Session> {
sessions.get(&id)
}Suggested Pattern: Newtype
Refactored Code:
struct SessionId(String);
impl SessionId {
fn new(id: String) -> Self {
Self(id)
}
}
fn get_session(id: SessionId) -> Option<Session> {
sessions.get(&id.0)
}Benefits:
- ✅ Type safety: Can't accidentally pass ProjectId
- ✅ Zero-cost: No runtime overhead
- ✅ Self-documenting: Clear what type of ID is expected
2. Builder Pattern for Config (Impact: High, Effort: Medium)
Location: src/config.rs:12-45
Problem: Constructor with 8 parameters, many optional
Current Code:
Config::new(host, port, timeout, retries, ssl, verbose, log_level, buffer_size)Suggested Pattern: Type-State Builder
Implementation Steps:
- Create
ConfigBuilderstruct withOption<T>fields - Add fluent setter methods returning
Self - Implement
build()with validation - Consider type-state pattern for required fields
Benefits:
- ✅ Readable: Clear what each value is
- ✅ Flexible: Optional params with defaults
- ✅ Safe: Compile-time validation with type-state
Medium Priority
3. RAII for Resource Cleanup (Impact: Medium, Effort: Low)
Location: src/temp_file.rs:23-56
Problem: Manual cleanup with defer! macro, easy to forget
Suggested Pattern: RAII with Drop trait
Benefits:
- ✅ Automatic: Cleanup guaranteed on scope exit
- ✅ Exception-safe: Works even on panic
- ✅ Idiomatic: Standard Rust pattern
Crate-Specific Suggestions
tokio Patterns
Location: src/api/server.rs
Observations:
- ❌ Using
std::thread::sleepin async context (line 89) - ❌ Blocking I/O with
std::fs::read(line 123)
Suggestions:
- Replace
std::thread::sleep→tokio::time::sleep - Replace
std::fs::read→tokio::fs::readorspawn_blocking - Add timeouts to all network operations
- Consider using
tokio::select!for concurrent operations
anyhow/thiserror Patterns
Location: src/parsers/
Observations:
- ⚠️ Using
anyhowin library code (should usethiserror) - ❌ Missing
.context()on 12?operators
Suggestions:
- Create custom error types with
thiserror::Errorfor lib - Add
.context()to all?operators for better error messages - Consider error chaining for root cause tracking
Summary
Total Suggestions: 8
- High Priority: 2
- Medium Priority: 3
- Low Priority: 3
Estimated Effort: 4-6 hours for high priority items
Impact: Improved type safety, better error handling, cleaner APIs
**Suggestion Rules**: See `signatures/anti-patterns.yaml`
---
## Mode 3: Evaluation
**Purpose**: Score the quality of pattern implementations against best practices.
**Workflow**:- Pattern Identification → Locate target pattern in code
- Criteria Assessment → Score against 5 quality dimensions
- Best Practice Check → Compare to reference implementations
- Report → Detailed scoring with improvement recommendations
**Example**:
```bash
/rust-patterns evaluate src/store.rs --pattern=newtypeScoring Criteria (0-10 each):
- Correctness (0-10)
- Pattern structure matches Rust idiom?
- Proper trait implementations?
- Follows language conventions?
- Ownership Safety (0-10)
- Proper borrowing patterns?
- No unnecessary clones?
- Optimal reference usage?
- Error Handling (0-10)
- Uses
Result<T, E>appropriately? - All errors have context?
- No unwrap/panic in library code?
- Uses
- Performance (0-10)
- Zero-copy where possible?
- No allocations in hot paths?
- Optimal algorithm choices?
- Documentation (0-10)
- Clear intent and usage?
- Lifetimes explained?
- Examples provided?
Output Format:
# Pattern Evaluation: Newtype (SessionId)
**File**: `src/models/stats.rs`
**Lines**: 12-25
**Overall Score**: 8.4/10 ⭐⭐⭐⭐
---
## Scoring Breakdown
### 1. Correctness: 9/10 ⭐⭐⭐⭐⭐
✅ **Strengths**:
- Proper tuple struct syntax
- Implements `From<String>` for conversion
- Implements `Display` for formatting
⚠️ **Areas for Improvement**:
- Missing `AsRef<str>` implementation for string access
**Recommendation**: Add `impl AsRef<str> for SessionId`
---
### 2. Ownership Safety: 10/10 ⭐⭐⭐⭐⭐
✅ **Strengths**:
- Zero-cost abstraction (no runtime overhead)
- No unnecessary clones
- Properly borrows in methods
**Excellent**: Optimal ownership patterns
---
### 3. Error Handling: 7/10 ⭐⭐⭐⭐
✅ **Strengths**:
- Returns `Result` from validation
⚠️ **Areas for Improvement**:
- Error messages could be more specific
- Consider using custom error type
**Recommendation**: Add validation with descriptive errors
---
### 4. Performance: 9/10 ⭐⭐⭐⭐⭐
✅ **Strengths**:
- Zero-cost newtype pattern
- No hidden allocations
- Efficient implementation
⚠️ **Minor Note**:
- Could add `#[repr(transparent)]` for guaranteed ABI compatibility
---
### 5. Documentation: 7/10 ⭐⭐⭐⭐
✅ **Strengths**:
- Basic doc comments present
- Usage examples in tests
⚠️ **Areas for Improvement**:
- Missing module-level documentation
- No examples in doc comments
- Type purpose not explained
**Recommendation**: Add comprehensive doc comments with examples
---
## Overall Assessment
**Verdict**: ⭐⭐⭐⭐ Very Good Implementation
This newtype implementation is solid and follows Rust best practices. It provides zero-cost type safety and has proper trait implementations. With minor documentation improvements and additional trait implementations, it would be excellent.
**Priority Improvements**:
1. Add comprehensive documentation with examples
2. Implement `AsRef<str>` for easier string access
3. Consider adding validation in constructor
**Code Example** (Improved):
```rust
/// Unique identifier for a session.
///
/// # Examples
///
/// ```
/// let id = SessionId::new("abc-123".to_string())?;
/// println!("Session: {}", id);
/// ```
#[repr(transparent)]
struct SessionId(String);
impl SessionId {
/// Creates a new SessionId after validation.
pub fn new(id: String) -> Result<Self, ValidationError> {
if id.is_empty() {
return Err(ValidationError::EmptyId);
}
Ok(Self(id))
}
}
impl AsRef<str> for SessionId {
fn as_ref(&self) -> &str {
&self.0
}
}Summary
Overall Score: 8.4/10 (Very Good) Strengths: Correctness, ownership safety, performance Improvement Areas: Documentation, additional trait implementations Effort to Improve: Low (1-2 hours)
**Evaluation Criteria**: See `checklists/pattern-evaluation.md`
---
## Integration with RUST_PATTERNS.md
This skill **complements** the always-active `@RUST_PATTERNS.md` rules:
| Component | Purpose | When to Use |
|-----------|---------|-------------|
| **RUST_PATTERNS.md** | Always-active rules and guidelines | Every Rust development session |
| **rust-patterns skill** | Optional deep analysis | Code review, refactoring, pattern audits |
**Workflow**:
1. `@RUST_PATTERNS.md` guides daily development (always active)
2. `/rust-patterns detect` for codebase health check
3. `/rust-patterns suggest` when refactoring or improving code
4. `/rust-patterns evaluate` before PR or major release
---
## Reference Files
- `reference/idioms.md` - Core Rust idioms reference
- `reference/creational.md` - Creational patterns (Builder, Factory)
- `reference/structural.md` - Structural patterns (Newtype, Trait Objects)
- `reference/behavioral.md` - Behavioral patterns (Strategy, Observer)
- `reference/rust-specific.md` - Rust-specific patterns (Sealed Traits, PhantomData)
## Detection Signatures
- `signatures/detection-rules.yaml` - Pattern detection rules
- `signatures/anti-patterns.yaml` - Anti-pattern detection and mapping
- `signatures/crate-patterns.yaml` - Crate-specific idioms (tokio, serde, anyhow)
## Checklists
- `checklists/pattern-evaluation.md` - Quality scoring criteria
---
**Version**: 1.0.0
**Maintained by**: SuperClaude FrameworkDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

