ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

rust-best-practices

Development guidance for writing idiomatic Rust. Use when: (1) writing new Rust functions or modules, (2) choosing between borrowing, cloning, or ownership patterns, (3) implementing error handling with Result types, (4) optimizing Rust code for performance, (5) configuring clippy and linting for a project, (6) deciding between static and dynamic dispatch, (7) writing documentation or doc tests.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/anderskev/rust-best-practices
Or

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

TopicKey RuleReference
OwnershipBorrow by default, clone only when you need a separate owned copyreferences/coding-idioms.md
ClippyRun cargo clippy -- -D warnings on every commit; configure workspace lintsreferences/clippy-config.md
PerformanceDon't guess, measure. Profile with --release firstreferences/performance.md
GenericsStatic dispatch by default, dynamic dispatch when you need mixed typesreferences/generics-dispatch.md
Type StateEncode state in the type system when invalid operations should be compile errorsreferences/type-state-pattern.md
Documentation// for why, /// for what and how, //! for module/crate purposereferences/documentation.md
PointersChoose pointer types based on ownership needs and threading modelreferences/pointer-types.md
API DesignUnsurprising, flexible, obvious, constrained -- encode invariants in typesreferences/api-design.md
EcosystemEvaluate crates, pick error handling strategy, stay currentreferences/ecosystem-patterns.md

Gates

Short sequences with pass conditions before claiming outcomes that need evidence (not an internal “I checked”).

Clippy clean

  1. From the workspace root (or with -p <crate>), run: cargo clippy --all-targets --all-features -- -D warnings.
  2. Pass: exit status is 0 and the invocation finishes without Clippy-deny failures.

Performance claim

  1. Build with cargo build --release (or your benchmark harness) under the same profile you ship or measure.
  2. Capture a before and after number from the same tool and metric (name both), e.g. Criterion ns/iter, heaptrack allocations, or a flamegraph path on disk.
  3. Pass: you can cite both measurements, or you explicitly state that only correctness or readability changed and you are not claiming a performance delta.

Docs for symbols you changed

  1. Run cargo doc --no-deps for the crate you edited (add -p <crate> in workspaces).
  2. Pass: the doc build succeeds; if #![deny(missing_docs)] (or crate policy) applies, there are no new missing-doc errors for those symbols.

Coding Idioms

Metadata

Author@anderskev
Stars4473
Views0
Updated2026-05-01
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-anderskev-rust-best-practices": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.