rust-best-practices
Skill1 starsChanged 3 months agoMITView on GitHub
Write and review production Rust using the official API Guidelines, Style Guide, and this engineering standard: allocation contracts, ownership, Result vs panic, debug_assert, Clippy, tests, rustdoc, unsafe, and Cargo CI. Use when writing, reviewing, or refactoring Rust; choosing borrow vs clone; designing crate APIs; handling errors; bounding heap use; configuring clippy or rustfmt; or when the user runs /rust-best-practices. Do not use for other languages. Triggers: rust, rustc, cargo, clippy, rustfmt, ownership, clone, borrow, Result, unwrap, expect, panic, thiserror, anyhow, heapless, no_std, allocation, debug_assert, type-state, Send, Sync, unsafe, FFI, rustdoc, MSRV, rust-best-practices, rust style, rust guidelines
24 other projects use a version of this.
Adopted by
Most recently taken up by
- crbnos/carbontheir own version, first seen Oct 4, 2026
- baekenough/oh-my-customcodetheir own version, first seen Oct 3, 2026
- microsoft/scopetheir own version, first seen Sep 23, 2026
- meowdiocre/meowpitheir own version, first seen Sep 19, 2026
- BigtoC/my-skillstheir own version, first seen Sep 15, 2026
- KalarisLabs/Skill-Doctortheir own version, first seen Sep 13, 2026
Used with
Projects with it also use inngest, go-best-practices and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
xfstudioSkillinngest
Inngest expert for serverless-first background jobs, event-driven workflows, and durable execution without managing queues or workers. Use when: inngest, serverless background job, event-driven workflow, step function, durable execution.
Also in 3 projects that use this
mduongvandinhSkillgo-best-practices
Also in 3 projects that use this
rohitg00Skilltypescript-advanced
Advanced TypeScript patterns including generics, conditional types, mapped types, template literals, and type guards
Also in 3 projects that use this
xfstudioSkillrust-async-patterns
Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code.
Also in 3 projects that use this
dbDev-codeSkilltauri-v2
Tauri v2+ cross-platform app development with Rust backend. Use when configuring tauri.conf.json, implementing Rust commands (#[tauri::command]), setting up IPC patterns (invoke, emit, channels), configuring permissions/capabilities, troubleshooting build issues, or deploying desktop/mobile apps. Triggers on Tauri, src-tauri, invoke, emit, capabilities.json.
Also in 3 projects that use this
VercelSkillvercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
Also in 6 projects that use this
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- crbnos/carbon★ 2.7ksame name
- pedronauck/skills★ 633same name
- apollographql/skills★ 116same name
- baekenough/oh-my-customcode★ 43same name
- ryo-ebata/cc-audit★ 25same name
- mduongvandinh/ai-best-practices-skills★ 18same name
- idexal/idexal-skills★ 13same name
- KalarisLabs/Skill-Doctor★ 13same name
- Harmeet10000/skills★ 7same name
- microsoft/scope★ 7same name
14 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this skill into the rules it gives an agent
25 rules. 0 are common, 9 are distinctive, and 16 are very specific to this project.
0
Common
Most of the 23 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
MUST / MUST NOT: required unless an approved architecture decision documents an exception.
- Distinctive: line 21
SHOULD / SHOULD NOT: default.
- Very specific: line 51
MUST make invalid states hard to represent: newtypes, enums, Option, Result, type-state where lifecycle matters.
- Distinctive: line 52
MUST keep fields private unless direct access is the contract (C-STRUCT-PRIVATE).
- Very specific: line 53
MUST follow official as_ / to_ / into_ conversion naming (C-CONV).
- Distinctive: line 54
SHOULD return values from general library APIs (C-NO-OUT).
- Very specific: line 55
NEVER use a raw u32 for every identifier merely because the representation matches.
- Distinctive: line 59
MUST declare a memory profile for each crate and performance-sensitive public operation: strict heapless, allocation-free steady state, or …
- Distinctive: line 60
MUST keep runtime work bounded (iterations, recursion, queues, retries, output, concurrency).
- Distinctive: line 61
MUST report capacity exhaustion as a typed error.
- Very specific: line 62
NEVER treat Cow::into_owned(), format!(), or a spill-capable small-vector as heapless.
- Very specific: line 66
SHOULD take &T, &str, &[T], &Path unless ownership transfer is required.
- Very specific: line 67
SHOULD pass small Copy values by value.
- Distinctive: line 68
NEVER clone to silence the borrow checker.
- Very specific: line 72
MUST return Result<T, E> for recoverable failure.
- Distinctive: line 73
MUST use checked arithmetic at trust boundaries before indexing or allocating.
- Very specific: line 74
MUST validate external input in all builds.
- Very specific: line 75
SHOULD use thiserror in libraries, anyhow only at binary boundaries.
- Very specific: line 79
MUST #![forbid(unsafe_code)] in crates that do not need unsafe.
- Very specific: line 80
MUST document every unsafe block with SAFETY:.
- Very specific: line 81
MUST NOT add unsafe Send/Sync impls without a written proof.
- Very specific: line 82
SHOULD prefer a single owner or bounded message passing over Arc<Mutex<T>> as an ownership escape hatch.
- Very specific: line 86
MUST run cargo fmt --all -- --check and cargo clippy --workspace --all-targets --all-features --locked -- -D warnings in CI (explicit …
- Very specific: line 87
SHOULD prefer #[expect(...)] over #[allow(...)], local and justified.
- Very specific: line 88
MUST link every committed TODO to an issue: // TODO(#123): ....
“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Best Practices
Apply this standard when writing or reviewing Rust. Engineering guide, not a tutorial.
Authority
- Live official docs for language, naming, formatting, and public API shape. Start with the Style Guide and the API Guidelines. Map: references/official.md.
- This skill for allocation contracts, bounds,
debug_assert!, heapless cores, determinism, and CI. Load the matching reference; do not invent a rule that lives there.
MUST / MUST NOT: required unless an approved architecture decision documents an exception. SHOULD / SHOULD NOT: default; a deviation needs a concrete reason in review. MAY: optional and context-dependent.
Correctness, safety, determinism, and maintainability outrank cleverness. Measure performance. Design allocation and bounds into the API before profiling.
Fetch current official docs for library or toolchain syntax. Do not invent APIs from memory.
How to use
/rust-best-practices: apply the standard to the current Rust work./rust-best-practices <path>: review that crate or file. For each finding: quote the line, name the rule (officialC-*id or a heading in this skill), give the fix.
Load only what the task needs, same turn, in parallel:
| Task | Read |
| Naming, rustdoc sections, official checklist | official.md |
| Memory profile, heapless, output buffers, hidden alloc | allocation.md |
Borrow vs clone, Copy, into_/to_/as_ | ownership.md |
Result, panic, thiserror/anyhow, checked math, debug_assert! | errors.md |
| Functions, iterators, dispatch, type-state, boolean blindness | design.md |
Pointers, Send/Sync, unsafe, FFI | unsafe.md |
| Measure, layout, clones, flamegraph | performance.md |
| rustfmt, Clippy, tests, docs, deps, MSRV, CI | quality.md |
| Review pass, anti-patterns | review.md |
Always-on rules
Types and APIs
- MUST make invalid states hard to represent: newtypes, enums,
Option,Result, type-state where lifecycle matters. - MUST keep fields private unless direct access is the contract (C-STRUCT-PRIVATE).
- MUST follow official
as_/to_/into_conversion naming (C-CONV). - SHOULD return values from general library APIs (C-NO-OUT). MUST use caller-owned buffers when the declared memory profile is heapless or allocation-free (C-CALLER-CONTROL).
- NEVER use a raw
u32for every identifier merely because the representation matches.
Memory
- MUST declare a memory profile for each crate and performance-sensitive public operation: strict heapless, allocation-free steady state, or allocation-conscious. Details: allocation.md.
- MUST keep runtime work bounded (iterations, recursion, queues, retries, output, concurrency).
- MUST report capacity exhaustion as a typed error. MUST NOT spill to the heap, drop entries, or switch to an unbounded fallback in silence.
- NEVER treat
Cow::into_owned(),format!(), or a spill-capable small-vector as heapless.
Ownership
- SHOULD take
&T,&str,&[T],&Pathunless ownership transfer is required. - SHOULD pass small
Copyvalues by value. Measure ABI and target when size is in question; do not apply a universal byte cutoff. - NEVER clone to silence the borrow checker.
Errors and asserts
- MUST return
Result<T, E>for recoverable failure. MUST NOTunwrap()/expect()on production paths. - MUST use checked arithmetic at trust boundaries before indexing or allocating.
- MUST validate external input in all builds. NEVER use
debug_assert!as caller validation or as the onlyunsafeprecondition. - SHOULD use
thiserrorin libraries,anyhowonly at binary boundaries.
Unsafe and concurrency
- MUST
#![forbid(unsafe_code)]in crates that do not need unsafe. - MUST document every unsafe block with
SAFETY:. - MUST NOT add unsafe
Send/Syncimpls without a written proof. - SHOULD prefer a single owner or bounded message passing over
Arc<Mutex<T>>as an ownership escape hatch.
Quality
- MUST run
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --all-features --locked -- -D warningsin CI (explicit feature matrix if--all-featuresis invalid). - SHOULD prefer
#[expect(...)]over#[allow(...)], local and justified. - MUST link every committed TODO to an issue:
// TODO(#123): ....
Official docs
Cite the live page. Do not restate official rules as if they originated here. Minimum set: Style Guide, API Guidelines checklist, debug_assert!, no_std, alloc, Clippy configuration, Cargo profiles. Full list: official.md.
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
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.

