| name | rust-development |
| description | Expert Rust development guidance covering naming conventions, type safety, error handling, documentation, and best practices based on official Rust guidelines. Use this skill when writing new Rust code, reviewing or modifying existing Rust code, designing Rust APIs or libraries, refactoring Rust codebases, or whenever the user mentions Rust, Cargo, clippy, rustfmt, traits, lifetimes, or `.rs` files. |
| license | Apache-2.0 |
Rust Development
This skill enforces new code or code changes to conform to proper Rust guidelines.
When to Use
Activate this skill when:
- Writing new Rust code
- Reviewing or modifying existing Rust code
- Designing Rust APIs, libraries, or applications
- Refactoring Rust codebases
Required Gates (Before Submitting Code)
All code must pass these checks:
cargo +nightly fmt
cargo clippy -- -D warnings
cargo test
cargo doc --no-deps
Code that fails clippy or is not properly formatted should not be committed. See project-and-tooling.md for required lints and rustfmt.toml config.
Reference Files
Load the relevant file when working on the matching topic:
| Topic | File |
|---|
Naming conventions (RFC 430), case rules, conversion methods (as_/to_/into_), getter/iterator method conventions | naming.md |
Type safety (newtypes, primitive obsession, bitflags, builders) and trait implementations (Clone, Debug, From/TryFrom, Deref rules, object safety, Serde behind feature flags) | types.md |
Error type requirements, thiserror for libraries, anyhow for applications, propagating with ?, let ... else for early returns | error-handling.md |
Public-item docs, # Arguments/# Errors/# Panics/# Safety/# Examples sections, #[doc(hidden)] for implementation details | documentation.md |
Minimizing unsafe, thread safety, Drop must not fail, avoiding allocations, iterators over indexing, &str over String, Cow | safety-and-performance.md |
| API design (no out-parameters, intermediate results, constructors as static methods, generics over concrete types, input validation) and forward compatibility (private fields, sealed traits) | api-design.md |
Cargo.toml metadata, module organization, feature flags, test organization, property-based testing, required clippy lints, rustfmt.toml, pre-commit checks | project-and-tooling.md |
Guidelines Sources
These guidelines are based on:
Code Review Checklist
Required