rust-conventions
Installation
SKILL.md
Rust Conventions
Apply these conventions in Rust projects. These rules are written for any coding agent, including Claude Code, Codex, Cursor, and Copilot.
When driving an LLM to produce Rust that follows these conventions, also apply power-rust — prompt patterns (crate version pinning, cancel-safety annotation, // SAFETY: invariants, lifetime call-site examples, multi-design trait proposals) that statistically reduce LLM Rust bugs.
General
- Use Rust edition 2024 or later when the project allows it.
- After Rust code changes, run
cargo fmtandcargo clippywhen available and appropriate for the repository. - When introducing or tightening lint policy, prefer Cargo-level Clippy lint groups over ad hoc command-only flags so CI, IDEs, and local runs share one policy.
- Encode incompatible target, platform, and feature combinations with
compile_error!orcfggates so unsupported builds fail early with a clear message. - Prefer compile-time or debug-time invariant checks over relying on comments for safety-critical protocols.
Clippy Lint Policy
For strict Rust projects, add lint groups in Cargo.toml using Cargo's [lints.clippy] table: