rust-best-practices · pedronauck — skill for Claude Code: Rust, ownership, async
rust-best-practices — a skill for writing, refactoring, and optimizing Rust code with ownership, error handling, Tokio, traits, and testing. Use it for systems programming or async workloads where correctness matters.
MIT 298 installs ★ 655 updated 2026-10-20
npx skills add pedronauck/skills --skill rust-best-practices -a claude-codeWhat rust-best-practices does
This skill guides Rust development through language idioms. It includes references on coding style, ownership and borrowing, error handling (Result, Option, thiserror, anyhow), async code and Tokio, traits and generics, thread synchronization, testing, and profiling. The agent knows Cargo, runs Clippy lints, formats with rustfmt, and writes benchmarks.
It respects your project's existing configuration: edition, rust-toolchain.toml, and MSRV from Cargo.toml. Does not push new dependencies or upgrade the toolchain just to match an example. Does not require a full workspace audit—it edits the file or test that matters.
Scope: Rust idioms and language-specific concerns only. Does not handle APIs, microservices, or architecture outside Rust specifics.
What it helps with
- refactor code to respect ownership and lifetimes
- add error handling with Result and custom error types
- optimize async code on Tokio
- write unit, integration, and property tests with benchmarks
- apply Clippy lints and fix code style
Example prompts for the agent
- Rewrite this function to avoid cloning when not needed
- Add error handling here using
thiserrorand preserve context - Write an integration test and a benchmark for this module
How to install rust-best-practices
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill rust-best-practices -a claude-code2Manually: put the files in place
~/.claude/skills/rust-best-practices/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/rust-best-practices/
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill rust-best-practices -a codex2Manually: put the files in place
.agents/skills/rust-best-practices/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill rust-best-practices -a cursor2Manually: put the files in place
.cursor/skills/rust-best-practices/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install pedronauck/skills skills/mine/rust-best-practices2Manually: put the files in place
.github/skills/rust-best-practices/SKILL.md1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill rust-best-practices -a gemini-cli2Platform CLI
gemini skills install https://github.com/pedronauck/skills --path skills/mine/rust-best-practicesManually: put the files in place
.devin/skills/rust-best-practices/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add pedronauck/skills --skill rust-best-practices -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about rust-best-practices
How do I install rust-best-practices in Claude Code?
Run npx skills add pedronauck/skills --skill rust-best-practices -a claude-code, then read ~/.claude/skills/rust-best-practices/SKILL.md. The skill is ready to use.
What does rust-best-practices do?
It helps you write and refactor Rust code following language idioms: memory management, error handling, async, testing. It understands Cargo, Clippy, rustfmt, and can read references for specific topics like traits, Tokio, or benchmarking.
Does it require a newer Rust version or new dependencies?
No. The skill works with your project's existing configuration—edition, MSRV, and rust-toolchain.toml. It does not upgrade the toolchain or add crates just to follow an example.
Source text
SKILL.md · MIT
--- name: rust-best-practices description: "Write, review, refactor, or optimize Rust, including ownership, errors, Tokio, traits, tests, benchmarks, Clippy, and documentation. Excludes other languages and architecture unrelated to Rust idioms." license: MIT compatibility: Cargo; honor the repository edition, pinned toolchain, and minimum supported Rust version metadata: version: "2.1.0" domain: language triggers: Rust, Cargo, ownership, borrowing, lifetimes, async Rust, tokio, zero-cost abstractions, memory safety, systems programming, traits, generics, error handling, thiserror, anyhow, clippy, rustfmt, testing, benchmarks author: Pedro Nauck github: https://github.com/pedronauck repository: https://github.com/pedronauck/skills allowed-tools: Bash(cargo:*) Bash(rustc:*) Bash(rustfmt:*) Bash(clippy:*) Read Write Edit Glob Grep --- # Rust Best Practices Use the existing crate design, edition, `rust-toolchain.toml`, and `Cargo.toml` `rust-version` (MSRV). Reference examples may use newer features: confirm support before adopting them; do not upgrade the toolchain or add a crate just to follow an example. Read the reference for the Rust concern being changed. A local edit does not require every category, a new test framework, or a workspace-wide audit. | Topic | Reference | Load When | |-------|-----------|-----------| | Coding Style | `references/coding-style.md` | Naming, imports, iterators, comments, string handling, macros | | Error Handling | `references/error-handling.md` | Result, Option, ?, thiserror, anyhow, custom errors, async errors | | Ownership & Pointers | `references/ownership-and-pointers.md` | Lifetimes, borrowing, smart pointers, Pin, Cow, interior mutability | | Traits & Generics | `references/traits-and-generics.md` | Trait design, dispatch, GATs, sealed traits, type state pattern | | Async & Concurrency | `references/async-and-concurrency.md` | Tokio, channels, streams, shutdown, runtime config, async traits | | Sync Concurrency | `references/concurrency-sync.md` | Atomics, Mutex, RwLock, lock ordering, Send/Sync, memory ordering | | Testing | `references/testing.md` | Unit/integration/doc tests, snapshot, proptest, mockall, benchmarks, fuzz | | Performance | `references/performance.md` | Profiling, flamegraph, cloning, stack vs heap, iterators, allocation | | Clippy & Linting | `references/clippy-and-linting.md` | Clippy config, key lints, workspace setup, #[expect] vs #[allow] | | Documentation | `references/documentation.md` | Doc comments, rustdoc, doc lints, coverage checklist | ## Engineering floor - Borrow or transfer ownership deliberately; clone when independent ownership is needed. Prefer clear ownership over numeric size rules or avoiding every allocation. - Handle fallible operations with `Result` and preserve useful error context. Reserve panic/assertions for violated programmer invariants; validate external input with recoverable errors. - Match error types, dispatch, and dependencies to the existing public contract. `thiserror`, `anyhow`, Tokio, and third-party synchronization crates are options, not mandatory additions. - Keep lock lifetimes short, maintain lock order, and reason about cancellation, shutdown, and spawned-task ownership. Do not hold a synchronous lock across `.await`. - Treat `Send`/`Sync` bounds and atomic orderings as correctness properties. Choose weaker ordering only with a valid synchronization argument; benchmark before performance-driven rewrites. - Put behavior tests in the suite that owns the invariant. Add type-level, property, fuzz, snapshot, or benchmark tests when that contract or risk warrants them. - Run the repository's required scoped format, lint, and test commands; reuse valid evidence. Full workspace/all-feature runs and documentation coverage rules follow project policy. Check feature combinations actually supported by the crate.
© Pedro Nauck · MIT · pedronauck/skills
Similar skills
All skills for Code review and refactoring →rust-best-practices by other authors comes first.