Skip to main content
skill CX Codex

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

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add pedronauck/skills --skill rust-best-practices -a claude-code
Open on GitHub

What 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 thiserror and 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-code

2Manually: put the files in place

~/.claude/skills/rust-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/rust-best-practices/

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.

rust-best-practices apollographql rust-best-practices — a skill that feeds your agent Apollo GraphQL's Rust handbook: borrowing vs cloning, Result-based errors, Clippy lints, tests. CX Codex +1 23,400installs rust-best-practices morganlinton rust-best-practices — a Claude Code skill for writing, reviewing, refactoring, and explaining Rust code. It activates on Rust, Cargo, .rs files, borrow checker issues, clippy, or rustfmt. CX Codex +1 1,100installs rust-engineer https://github.com/Jeffallan rust-engineer guides the agent to write and review idiomatic Rust 2021 code. Useful when designing traits, resolving borrow checker errors, and building async tokio services. CX Codex +1 6,900installs rust Mindrally Tells the agent how to write Rust: ownership for memory safety, async on tokio, errors via Result and Option. CX Codex +1 832installs openai-codex-rust-patterns pproenca openai-codex-rust-patterns applies 63 production Rust patterns distilled from the OpenAI Codex codebase. Helps build resilient async workflows, process sandboxes, and panic-free error architectures. CX Codex +1 219installs rust-stinger Legion Code Inc. rust-stinger guides bounded Rust development across Cargo workspaces, Tokio runtimes, SQLx persistence, and test validation before release. CX Codex +1 ★ 96repo stars rust-pro davila7 rust-pro guides Rust work on services, libraries, and systems tools, from ownership and async design to tests and performance profiling. CX Codex +1 57installs rust-wasp-drone Legion Code Inc. rust-wasp-drone is a Claude Code, Codex, and Cursor subagent for Rust implementation and code review. It activates on Rust files, Cargo workspaces, or tasks involving Tokio and SQLx. CX Codex ★ 96repo stars

From the same set52

The whole set →
ui-craft ui-craft — a skill for designing and building visible interfaces: pages, components, forms, loading and error states, AI chat surfaces with streaming. Works within your project's design system and validates accessibility. CX Codex +1 314installs electron-dev electron-dev guides agents through building Electron apps with Electron Vite and Electron Builder. It focuses on process separation, IPC safety, and native dependencies. CX Codex +1 311installs writing-agents-md writing-agents-md is a Claude Code skill for writing and reviewing AGENTS.md and CLAUDE.md files. It covers projects with rules agents cannot infer from code or tooling alone. CX Codex +1 305installs app-renderer-systems The app-renderer-systems skill structures frontend modules in systems/ directories with clear layers: adapters, Query hooks, local state, and public exports. CX Codex +1 299installs es-toolkit Guides your AI assistant to use es-toolkit utility functions for arrays, objects, and strings instead of custom helpers. CX Codex +1 293installs extreme-software-optimization The extreme-software-optimization skill locates performance hot spots with measurements, then checks that changes preserve behavior. Use it for slow code, latency, throughput, or algorithm work. CX Codex +1 286installs electron-release electron-release guides Electron production builds, signing, notarization, updates, and delivery. Use it when a desktop app is moving from local builds to a release pipeline. CX Codex +1 282installs bubbletea Guides coding agents in building Go terminal interfaces with Bubble Tea and Lip Gloss under the Elm architecture. CX Codex +1 276installs

Project sponsors

Companies that keep this analytics open