Back to skills
extension
Category: Development & EngineeringNo API key required

rust-idioms

Rust refactoring and idiomatic patterns guidelines from the Rust Community (formerly rust-refactor). This skill should be used when writing, reviewing, or refactoring Rust code to ensure idiomatic patterns and clean architecture. Triggers on tasks involving Rust types, ownership, error handling, traits, modules, conversions, or iterator patterns.

personAuthor: jakexiaohubgithub

Rust Community Rust Refactoring Best Practices

Comprehensive refactoring and idiomatic patterns guide for Rust applications, maintained by the Rust Community. Contains 44 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new Rust code with strong type guarantees
  • Refactoring ownership and borrowing patterns
  • Designing error handling strategies
  • Creating public APIs with traits and generics
  • Organizing modules and controlling visibility

Rule Categories by Priority

| Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Type Safety & Newtype Patterns | CRITICAL | type- | | 2 | Ownership & Borrowing | CRITICAL | own- | | 3 | Error Handling Patterns | HIGH | err- | | 4 | API Design & Traits | HIGH | api- | | 5 | Module & Visibility | MEDIUM-HIGH | mod- | | 6 | Conversion Traits | MEDIUM | conv- | | 7 | Idiomatic Patterns | MEDIUM | idiom- | | 8 | Iterator & Collections | LOW-MEDIUM | iter- |

Quick Reference

1. Type Safety & Newtype Patterns (CRITICAL)

2. Ownership & Borrowing (CRITICAL)

3. Error Handling Patterns (HIGH)

4. API Design & Traits (HIGH)

5. Module & Visibility (MEDIUM-HIGH)

6. Conversion Traits (MEDIUM)

7. Idiomatic Patterns (MEDIUM)

8. Iterator & Collections (LOW-MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Full Compiled Document

For a single-file comprehensive guide, see AGENTS.md.