agentleFS
nurmdrafinurmdrafi/pi-native/skills/rust-skills/SKILL.md

rust-skills

Skill4 starsChanged 5 days agoMITView on GitHub

Comprehensive Rust coding guidelines with 269 rules across 26 categories. Use when writing, reviewing, or refactoring Rust code. Covers ownership, error handling, async patterns, concurrency, unsafe code, API design, memory optimization, performance, numeric safety, conversions, serde, pattern matching, macros, closures, observability, testing, and common anti-patterns. Invoke with /rust-skills.

15 other projects use a version of this, 8 of them edited.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Rust Best Practices

Comprehensive guide for writing high-quality, idiomatic, and highly optimized Rust code. Contains 269 rules across 26 categories, prioritized by impact to guide LLMs in code generation and refactoring. Current for Rust 1.96 (2024 edition).

When to Apply

Reference these guidelines when:

  • Writing new Rust functions, structs, or modules
  • Implementing error handling or async code
  • Writing concurrent, parallel, or unsafe code
  • Designing public APIs for libraries
  • Reviewing code for ownership/borrowing issues
  • Optimizing memory usage or reducing allocations
  • Tuning performance for hot paths
  • Refactoring existing Rust code

Rule Categories by Priority

PriorityCategoryImpactPrefixRules
1Ownership & BorrowingCRITICALown-12
2Error HandlingCRITICALerr-12
3Memory OptimizationCRITICALmem-17
4Unsafe CodeCRITICALunsafe-7
5API DesignHIGHapi-17
6Async/AwaitHIGHasync-18
7ConcurrencyHIGHconc-4
8Compiler OptimizationHIGHopt-16
9Numeric & Arithmetic SafetyHIGHnum-5
10Type SafetyMEDIUMtype-13
11Trait & Generics DesignMEDIUMtrait-6
12ConversionsMEDIUMconv-3
13Const & Compile-TimeMEDIUMconst-4
14SerdeMEDIUMserde-8
15Pattern MatchingMEDIUMpat-5
16MacrosMEDIUMmacro-8
17ClosuresMEDIUMclosure-5
18CollectionsMEDIUMcoll-4
19Naming ConventionsMEDIUMname-16
20TestingMEDIUMtest-15
21DocumentationMEDIUMdoc-12
22ObservabilityMEDIUMobs-7
23Performance PatternsMEDIUMperf-13
24Project StructureLOWproj-14
25Clippy & LintingLOWlint-13
26Anti-patternsREFERENCEanti-15

Quick Reference

See references/quick-reference.md for the full list of 269 rules across 26 categories, linked to individual rule files.


Recommended Cargo.toml Settings

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
panic = "abort"
strip = true

[profile.bench]
inherits = "release"
debug = true
strip = false

[profile.dev]
opt-level = 0
debug = true

[profile.dev.package."*"]
opt-level = 3  # Optimize dependencies in dev

How to Use

This skill provides rule identifiers for quick reference. When generating or reviewing Rust code:

  1. Check relevant category based on task type
  2. Apply rules with matching prefix
  3. Prioritize CRITICAL > HIGH > MEDIUM > LOW
  4. Read rule files in references/ for detailed examples

Rule Application by Task

TaskPrimary Categories
New functionown-, err-, name-, pat-
New struct/APIapi-, type-, conv-, doc-
Async codeasync-, own-
Concurrency / parallelismconc-, async-, own-
Unsafe codeunsafe-, type-, test-
Error handlingerr-, api-, pat-
Type conversionsconv-, api-
Serialization (serde)serde-, type-, api-
Numeric / arithmeticnum-, type-
Macros / code generationmacro-, anti-
Closures / callbacksclosure-, type-
Logging / observabilityobs-, err-
Memory optimizationmem-, own-, perf-
Performance tuningopt-, mem-, perf-
Code reviewanti-, lint-

Sources & Attribution

This skill is an independent synthesis of official Rust guidance, well-known books, and patterns from widely-used crates. It is not affiliated with or endorsed by the Rust project or any crate author; the text and code examples are original.

Official Rust documentation

Books & guides

Tooling

Real-world codebases studied for idioms

  • ripgrep, tokio, serde, clap, polars, axum, cargo, hyper, bevy, rayon, and dtolnay's crates (thiserror, anyhow, syn)

This project is MIT-licensed. Referenced upstream materials remain under their own licenses (the official Rust docs and API Guidelines are dual MIT / Apache-2.0).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.