
Coding Guidelines
- 1.3k installs
- 1.3k repo stars
- Updated May 24, 2026
- zhanghandong/rust-skills
This is a copy of coding-guidelines by actionbook - installs and ranking accrue to the original listing.
coding-guidelines is a Rust agent skill that enforces idiomatic, Clippy-aligned patterns and safety documentation for developers using Claude or Cursor on Rust codebases.
About
coding-guidelines is a Rust-focused skill from zhanghandong/rust-skills that maps common Clippy lints to concrete fixes agents should apply while authoring code. The reference table covers error handling (unwrap_used), performance (needless_clone, linkedlist, large_stack_arrays), async pitfalls (await_holding_lock), style (wildcard_imports, too_many_arguments), and unsafe requirements (missing_safety_doc, undocumented_unsafe_blocks, transmute_ptr_to_ptr). Developers reach for it when they want generated Rust to match community norms instead of fighting Clippy in review. It pairs with the unsafe-checker skill for deeper unsafe audits.
- 50 core Rust coding rules covering naming, formatting, comments, safety and performance
- Direct Clippy lint → rule mapping with recommended fixes for 10 frequent lints
- Explicit guidance on unsafe blocks, iterator conventions, and avoiding get_ prefixes
- Links to full 500+ rule reference for deeper Rust style decisions
- Designed as a hard reference before code review or agent code generation
Coding Guidelines by the numbers
- 1,260 all-time installs (skills.sh)
- +9 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Security screen: LOW risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/zhanghandong/rust-skills --skill coding-guidelinesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.3k |
|---|---|
| repo stars | ★ 1.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | May 24, 2026 |
| Repository | zhanghandong/rust-skills ↗ |
How do you write idiomatic Rust with Claude?
Get consistent, idiomatic Rust code that follows community standards and avoids common pitfalls when working with Claude or Cursor.
Who is it for?
Developers using AI assistants on Rust services or CLIs who want Clippy-clean, idiomatic output on the first pass.
Skip if: Teams working only in non-Rust stacks or projects that already enforce identical rules through custom rustfmt/clippy.toml automation.
When should I use this skill?
The user asks for Rust code, Clippy fixes, idiomatic patterns, or unsafe documentation in a Rust crate.
What you get
Clippy-aligned Rust patches, documented unsafe blocks, and consistent import and API shapes
- idiomatic Rust source
- documented unsafe blocks
- Clippy-aligned refactors
By the numbers
- Documents fixes for at least 10 named Clippy lints in the reference table
Files
Rust Coding Guidelines (50 Core Rules)
Naming (Rust-Specific)
| Rule | Guideline |
|---|---|
No get_ prefix | fn name() not fn get_name() |
| Iterator convention | iter() / iter_mut() / into_iter() |
| Conversion naming | as_ (cheap &), to_ (expensive), into_ (ownership) |
| Static var prefix | G_CONFIG for static, no prefix for const |
Data Types
| Rule | Guideline |
|---|---|
| Use newtypes | struct Email(String) for domain semantics |
| Prefer slice patterns | if let [first, .., last] = slice |
| Pre-allocate | Vec::with_capacity(), String::with_capacity() |
| Avoid Vec abuse | Use arrays for fixed sizes |
Strings
| Rule | Guideline |
|---|---|
| Prefer bytes | s.bytes() over s.chars() when ASCII |
Use Cow<str> | When might modify borrowed data |
Use format! | Over string concatenation with + |
| Avoid nested iteration | contains() on string is O(n*m) |
Error Handling
| Rule | Guideline |
|---|---|
Use ? propagation | Not try!() macro |
expect() over unwrap() | When value guaranteed |
| Assertions for invariants | assert! at function entry |
Memory
| Rule | Guideline |
|---|---|
| Meaningful lifetimes | 'src, 'ctx not just 'a |
try_borrow() for RefCell | Avoid panic |
| Shadowing for transformation | let x = x.parse()? |
Concurrency
| Rule | Guideline |
|---|---|
| Identify lock ordering | Prevent deadlocks |
| Atomics for primitives | Not Mutex for bool/usize |
| Choose memory order carefully | Relaxed/Acquire/Release/SeqCst |
Async
| Rule | Guideline |
|---|---|
| Sync for CPU-bound | Async is for I/O |
| Don't hold locks across await | Use scoped guards |
Macros
| Rule | Guideline |
|---|---|
| Avoid unless necessary | Prefer functions/generics |
| Follow Rust syntax | Macro input should look like Rust |
Deprecated → Better
| Deprecated | Better | Since |
|---|---|---|
lazy_static! | std::sync::OnceLock | 1.70 |
once_cell::Lazy | std::sync::LazyLock | 1.80 |
std::sync::mpsc | crossbeam::channel | - |
std::sync::Mutex | parking_lot::Mutex | - |
failure/error-chain | thiserror/anyhow | - |
try!() | ? operator | 2018 |
Quick Reference
Naming: snake_case (fn/var), CamelCase (type), SCREAMING_CASE (const)
Format: rustfmt (just use it)
Docs: /// for public items, //! for module docs
Lint: #![warn(clippy::all)]Claude knows Rust conventions well. These are the non-obvious Rust-specific rules.
Clippy Lint → Rule Mapping
| Clippy Lint | Category | Fix |
|---|---|---|
unwrap_used | Error | Use ? or expect() |
needless_clone | Perf | Use reference |
await_holding_lock | Async | Scope guard before await |
linkedlist | Perf | Use Vec/VecDeque |
wildcard_imports | Style | Explicit imports |
missing_safety_doc | Safety | Add # Safety doc |
undocumented_unsafe_blocks | Safety | Add // SAFETY: |
transmute_ptr_to_ptr | Safety | Use pointer::cast() |
large_stack_arrays | Mem | Use Vec or Box |
too_many_arguments | Design | Use struct params |
For unsafe-related lints → see unsafe-checker skill.
Complete Rules Reference
For the full 500+ rules, see:
- Source: https://rust-coding-guidelines.github.io/rust-coding-guidelines-zh/
Core rules are in ../SKILL.md.
Related skills
How it compares
Use coding-guidelines for day-to-day idiomatic generation; pair unsafe-checker when changes touch unsafe or FFI-heavy code.
FAQ
Which Clippy lints does coding-guidelines cover?
coding-guidelines maps lints including unwrap_used, needless_clone, await_holding_lock, linkedlist, wildcard_imports, missing_safety_doc, undocumented_unsafe_blocks, transmute_ptr_to_ptr, large_stack_arrays, and too_many_arguments to concrete Rust fixes.
Does coding-guidelines handle unsafe Rust?
coding-guidelines requires # Safety docs and // SAFETY: comments for unsafe blocks and points unsafe-heavy reviews to the companion unsafe-checker skill for deeper checks.