rust

Apply Rust conventions to write idiomatic, safe, and maintainable .rs code.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/erichugy/agentic.skills --skill rust-erichugy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust
Source: https://github.com/erichugy/agentic.skills/tree/main/rust
Command: npx skills add https://github.com/erichugy/agentic.skills --skill rust-erichugy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ensures Rust code is idiomatic, consistent, and safe by reducing bugs from ownership mistakes, inconsistent error handling, and style divergence across a codebase.

Core Features & Use Cases

  • Naming & Style: Enforces snake_case for functions and modules, PascalCase for types, and UPPER_SNAKE_CASE for constants.
  • Error Handling & Options: Recommends Result-based error propagation, avoids unwrap/expect in production, and prefers thiserror/anyhow patterns.
  • Modules, Concurrency & Performance: Guides module layout, ownership and borrowing practices, concurrency best practices, and performance idioms like iterator usage and preallocation.
  • Use Cases: Use when authoring new crates, performing code reviews, or refactoring to improve safety and maintainability.

Quick Start

Review src/lib.rs and suggest changes to naming, error handling, ownership, formatting, and clippy warnings to make the code idiomatic and safe.

Frequently Asked Questions about rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write idiomatic Rust code that follows standard naming and style conventions?

Idiomatic Rust code enforces snake_case for functions and modules, PascalCase for types, and UPPER_SNAKE_CASE for constants. It requires running cargo fmt and clippy checks to ensure consistent formatting and maintainable .rs source files across libraries and applications.

What's the best way to handle errors in Rust without using unwrap or expect?

Error handling in Rust should use Result-based error propagation instead of unwrap or expect in production code. For idiomatic error management, apply thiserror or anyhow patterns to safely propagate errors through your application without panicking.

How do I avoid unnecessary clones and lock contention when managing Rust ownership and borrowing?

Managing Rust ownership and borrowing requires following guidance on module layout and concurrency best practices to avoid unnecessary clones and lock contention. Optimizing performance idioms like iterator usage and preallocation helps maintain safe, efficient memory management.

Can I use this approach to review and refactor existing Rust source files for safety?

Yes, you can review and refactor existing .rs source files for safety by checking naming conventions, error handling, ownership, formatting, and clippy warnings. This process improves code maintainability and reduces bugs from ownership mistakes across your codebase.

Why does my Rust code fail clippy checks and cargo fmt formatting standards?

Rust code fails clippy checks and cargo fmt standards when it diverges from idiomatic style rules like improper naming conventions, missing trait derivations, or suboptimal iterator usage. Enforcing required cargo fmt and clippy checks resolves these style divergences.