What does this skill do?

The Rust Idioms Skill provides a set of conventions and patterns for writing safe, efficient, and maintainable Rust code. It covers ownership and borrowing, error handling with `Result` and `?`, traits and generics, concurrency with `Arc`/`Mutex` and channels, and the structure of modules and crates by domain. Apply these guidelines when writing or reviewing code to ensure your Rust code compiles cleanly, without `unwrap()` in production, and with correctly typed errors.

New code written from scratch
Apply the idioms of ownership, borrowing, and Cow when writing new Rust code.
Team Code Review
Use this guide during code reviews to identify `unwrap()`, unjustified `unsafe`, and anti-patterns.
Idiomatic refactoring
Convert existing code to idiomatic Rust: use references instead of clones, and type-checked errors with `thiserror`.
Design of crates and modules
Organize your project by domain using a consistent and scalable folder structure.

Usage examples

🦀 Ownership and borrowing
Review this Rust function and make it more idiomatic by avoiding unnecessary clones and using the correct references.
❌ Error Handling
I have several `unwrap()` calls in my production code. Please help me replace them with `Result` using `anyhow` and `thiserror`.
⚙️ Secure Concurrency
Necesito compartir un estado mutable entre varios hilos. Muéstrame el patrón idiomático con Arc<Mutex<T>>.
🏗️ Crate Structure
I'm designing a new Rust project. Suggest a domain-based module structure that follows the language's conventions.

Features

Ownership and Cow Patterns for borrowing instead of cloning, and using Cow for flexible ownership without unnecessary costs.
Type errors with `thiserror` and `anyhow` Spreading with the ? operator, context with anyhow, and typing errors in libraries with thiserror.
Traits and generics Accepts generics with the `impl Trait` trait, returns concrete types, and uses `newtype` for type safety.
Concurrency and Async Patrones con Arc<Mutex<T>>, canales, y async con Tokio incluyendo timeouts y manejo de errores.
Crate Structure by Domain A consistent, scalable organization of modules and folders that aligns with the Rust community's conventions.

Frequently asked questions

It's not required to view the patterns, but to apply them and check your code, you'll need Rust, cargo clippy, and cargo fmt installed on your system.
Sí. Incluye patrones de concurrencia con Arc<Mutex<T>>, canales estándar y async con Tokio, incluyendo timeouts y propagación de errores.
The skill guides you to replace each `unwrap()` with spread syntax using `Result` and the `?` operator, adding context with `anyhow` or typed errors with `thiserror`.
Yes. One of the main use cases is code review: ask Claude to analyze a PR and identify anti-patterns, unjustified unsafe code, and deviations from coding conventions.
Rust Idiomatic Patterns — Safe and Efficient Code with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.