PluginBench
Skill
Pass
Audit score 90

coding-guidelines

zhanghandong/rust-skills

How to install coding-guidelines

npx skills add https://github.com/zhanghandong/rust-skills --skill coding-guidelines
Claude Code
Cursor
Windsurf
Cline
Full instructions (SKILL.md)

Source of truth, from zhanghandong/rust-skills.


name: coding-guidelines description: "Use when asking about Rust code style or best practices. Keywords: naming, formatting, comment, clippy, rustfmt, lint, code style, best practice, P.NAM, G.FMT, code review, naming convention, variable naming, function naming, type naming, 命名规范, 代码风格, 格式化, 最佳实践, 代码审查, 怎么命名" source: https://rust-coding-guidelines.github.io/rust-coding-guidelines-zh/ user-invocable: false

Rust Coding Guidelines (50 Core Rules)

Naming (Rust-Specific)

RuleGuideline
No get_ prefixfn name() not fn get_name()
Iterator conventioniter() / iter_mut() / into_iter()
Conversion namingas_ (cheap &), to_ (expensive), into_ (ownership)
Static var prefixG_CONFIG for static, no prefix for const

Data Types

RuleGuideline
Use newtypesstruct Email(String) for domain semantics
Prefer slice patternsif let [first, .., last] = slice
Pre-allocateVec::with_capacity(), String::with_capacity()
Avoid Vec abuseUse arrays for fixed sizes

Strings

RuleGuideline
Prefer bytess.bytes() over s.chars() when ASCII
Use Cow<str>When might modify borrowed data
Use format!Over string concatenation with +
Avoid nested iterationcontains() on string is O(n*m)

Error Handling

RuleGuideline
Use ? propagationNot try!() macro
expect() over unwrap()When value guaranteed
Assertions for invariantsassert! at function entry

Memory

RuleGuideline
Meaningful lifetimes'src, 'ctx not just 'a
try_borrow() for RefCellAvoid panic
Shadowing for transformationlet x = x.parse()?

Concurrency

RuleGuideline
Identify lock orderingPrevent deadlocks
Atomics for primitivesNot Mutex for bool/usize
Choose memory order carefullyRelaxed/Acquire/Release/SeqCst

Async

RuleGuideline
Sync for CPU-boundAsync is for I/O
Don't hold locks across awaitUse scoped guards

Macros

RuleGuideline
Avoid unless necessaryPrefer functions/generics
Follow Rust syntaxMacro input should look like Rust

Deprecated → Better

DeprecatedBetterSince
lazy_static!std::sync::OnceLock1.70
once_cell::Lazystd::sync::LazyLock1.80
std::sync::mpsccrossbeam::channel-
std::sync::Mutexparking_lot::Mutex-
failure/error-chainthiserror/anyhow-
try!()? operator2018

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.

Related skills

More from zhanghandong/rust-skills and the wider catalog.

M1

m15-anti-pattern

zhanghandong/rust-skills

Use when reviewing code for anti-patterns. Keywords: anti-pattern, common mistake, pitfall, code smell, bad practice, code review, is this an anti-pattern, better way to do this, common mistake to avoid, why is this bad, idiomatic way, beginner mistake, fighting borrow checker, clone everywhere, unwrap in production, should I refactor, 反模式, 常见错误, 代码异味, 最佳实践, 地道写法

5.6k installsAudited
M1

m10-performance

zhanghandong/rust-skills

CRITICAL: Use for performance optimization. Triggers: performance, optimization, benchmark, profiling, flamegraph, criterion, slow, fast, allocation, cache, SIMD, make it faster, 性能优化, 基准测试

881 installs
M0

m07-concurrency

zhanghandong/rust-skills

CRITICAL: Use for concurrency/async. Triggers: E0277 Send Sync, cannot be sent between threads, thread, spawn, channel, mpsc, Mutex, RwLock, Atomic, async, await, Future, tokio, deadlock, race condition, 并发, 线程, 异步, 死锁

831 installs
M0

m06-error-handling

zhanghandong/rust-skills

CRITICAL: Use for error handling. Triggers: Result, Option, Error, ?, unwrap, expect, panic, anyhow, thiserror, when to panic vs return Result, custom error, error propagation, 错误处理, Result 用法, 什么时候用 panic

810 installs
RU

rust-refactor-helper

zhanghandong/rust-skills

Safe Rust refactoring with LSP analysis. Triggers on: /refactor, rename symbol, move function, extract, 重构, 重命名, 提取函数, 安全重构

806 installs
M0

m01-ownership

zhanghandong/rust-skills

CRITICAL: Use for ownership/borrow/lifetime issues. Triggers: E0382, E0597, E0506, E0507, E0515, E0716, E0106, value moved, borrowed value does not live long enough, cannot move out of, use of moved value, ownership, borrow, lifetime, 'a, 'static, move, clone, Copy, 所有权, 借用, 生命周期

792 installs