rust-best-practices
Installation
SKILL.md
Contains Shell Commands
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
Rust Best Practices
Guidance for writing idiomatic, performant, and safe Rust code. This is a development skill, not a review skill -- use it when building, not reviewing.
Quick Reference
| Topic | Key Rule | Reference |
|---|---|---|
| Ownership | Borrow by default, clone only when you need a separate owned copy | references/coding-idioms.md |
| Clippy | Run cargo clippy -- -D warnings on every commit; configure workspace lints |
references/clippy-config.md |
| Performance | Don't guess, measure. Profile with --release first. Watch monomorphization + cache-line alignment at scale |
references/performance.md |
| Generics | Static dispatch by default, dynamic dispatch when you need mixed types | references/generics-dispatch.md |
| Type State | Encode state in the type system when invalid operations should be compile errors | references/type-state-pattern.md |
| Documentation | // for why, /// for what and how, //! for module/crate purpose |
references/documentation.md |
| Pointers | Choose pointer types based on ownership needs and threading model | references/pointer-types.md |
| API Design | Unsurprising, flexible, obvious, constrained — encode invariants in types; watch hidden contracts (re-exports, auto-traits) | references/api-design.md |
| Wild Patterns | Drop guards, extension traits, index pointers, crate preludes — battle-tested idioms from mature crates | references/coding-idioms.md |
| Ecosystem | Evaluate crates, pick error handling strategy, stay current | references/ecosystem-patterns.md |