rust-best-practices
Skill1 starsChanged 3 months agoMITView on GitHub
Rust coding conventions and review guidance. Auto-invoke whenever working with .rs files or Rust code -- implementing features, reviewing changes, refactoring modules, designing public APIs, improving tests, or optimizing performance.
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
- massimodeluisa/rust-best-practices-skilltheir own version, first seen Sep 16, 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 repository4 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ai-industry-weeklySkill
- ai-pullback-dailySkill
- daily-risk-monitorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. 0 are common, 16 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 23 edited versions we read keep these.
16
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Use this skill when a task involves Rust code: implementing features, reviewing changes, refactoring modules, designing public APIs, …
- Distinctive: line 56
Keep solutions idiomatic, safe, and maintainable.
- Very specific: line 64
Prefer borrowing over cloning, Result over panics, and focused modules over large mixed-responsibility files.
- Very specific: line 66
When refactoring, preserve the public surface and use mod.rs re-exports or other facade patterns to hide internal changes.
- Distinctive: line 68
When optimizing, profile first and improve algorithms before micro-tuning allocations or concurrency.
- Distinctive: line 70
Document public APIs, cover edge cases with tests, and keep standard Rust tooling green if the project uses it.
- Distinctive: line 75
Write idiomatic Rust that compiles cleanly and avoids warnings.
- Very specific: line 76
Prefer &str over String for parameters when ownership is not required.
- Very specific: line 77
Avoid unwrap(), expect(), and panics in library code.
- Distinctive: line 78
Use meaningful error types and add context to failures.
- Distinctive: line 79
Avoid duplicated logic, unnecessary wrappers, and deep nesting.
- Distinctive: line 80
Keep modules cohesive and split large files by responsibility.
- Distinctive: line 81
Treat performance advice as opt-in for measured bottlenecks, not default complexity.
- Distinctive: line 86
When reviewing Rust code, prioritize:
- Distinctive: line 91
Test coverage and rustdoc quality
- Very specific: line 96
Keep main.rs and lib.rs thin.
- Distinctive: line 97
Prefer package-style modules for larger components.
- Distinctive: line 98
Use private helper modules and expose only an intentional public surface.
- Distinctive: line 99
Remove pass-through wrapper functions that add no value.
- Distinctive: line 104
Prefer iterator pipelines, pre-allocation, streaming, and lazy evaluation before more invasive rewrites.
- Distinctive: line 106
Consider memory layout and concurrency changes only when the workload justifies them.
“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
Auto-invoke this skill whenever a task touches a .rs file or any Rust
code. This applies to all agent implementations.
Use this skill when a task involves Rust code: implementing features, reviewing changes, refactoring modules, designing public APIs, improving tests, or optimizing performance.
Auto-Trigger Setup
All agents (description-based)
Agents that load skill descriptions at startup will auto-invoke this skill
whenever .rs files or Rust keywords appear in the task context. No extra
configuration is needed if your agent follows the Agent Skills specification.
Claude Code (hook-based enforcement)
For guaranteed invocation regardless of context, add this hook to
~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path // \"\"' | { read -r f; if printf '%s' \"$f\" | grep -qE '\\.rs$'; then printf '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"Rust (.rs) file detected. Invoke the rust-best-practices skill now if you have not already done so this session.\"}}'; fi; } 2>/dev/null || true",
"timeout": 10
}
]
}
]
}
}Merge into any existing hooks.PreToolUse array rather than replacing it.
Keep solutions idiomatic, safe, and maintainable. Favor strong typing, explicit error handling, public API stability, and borrowing-first designs.
Core Workflow
- Identify the task type: new implementation, review, refactor, API design, debugging, or optimization.
- Preserve correctness and readability before chasing cleverness.
- Prefer borrowing over cloning,
Resultover panics, and focused modules over large mixed-responsibility files. - When refactoring, preserve the public surface and use
mod.rsre-exports or other facade patterns to hide internal changes. - When optimizing, profile first and improve algorithms before micro-tuning allocations or concurrency.
- Document public APIs, cover edge cases with tests, and keep standard Rust tooling green if the project uses it.
Default Guidance
- Write idiomatic Rust that compiles cleanly and avoids warnings.
- Prefer
&stroverStringfor parameters when ownership is not required. - Avoid
unwrap(),expect(), and panics in library code. - Use meaningful error types and add context to failures.
- Avoid duplicated logic, unnecessary wrappers, and deep nesting.
- Keep modules cohesive and split large files by responsibility.
- Treat performance advice as opt-in for measured bottlenecks, not default complexity.
Review Priorities
When reviewing Rust code, prioritize:
- Safety and correctness
- Error handling and API clarity
- Ownership, borrowing, and allocation behavior
- Test coverage and rustdoc quality
- Performance issues backed by real workload needs
Refactoring Guidance
- Keep
main.rsandlib.rsthin. - Prefer package-style modules for larger components.
- Use private helper modules and expose only an intentional public surface.
- Remove pass-through wrapper functions that add no value.
Performance Guidance
- Optimize only after profiling identifies a real bottleneck.
- Prefer iterator pipelines, pre-allocation, streaming, and lazy evaluation before more invasive rewrites.
- Consider memory layout and concurrency changes only when the workload justifies them.
Detailed Reference
See references/REFERENCE.md for the full Rust guidance, including:
- ownership and lifetime rules
- patterns to follow and avoid
- API design guidelines
- testing and documentation expectations
- project organization rules
- performance techniques and optimization priorities
- a publish/review checklist
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.

