rust-design-patterns
Skill62 starsChanged 2 months agoMITView on GitHub
Resolve Rust ownership and lifetime problems or design Rust APIs, resource lifecycles, and FFI boundaries.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- nledford/engineering-review-boardtheir own version, first seen Nov 3, 2026
- adxptived/Rust-Skillstheir own version, first seen Oct 17, 2026
- botirkhaltaev/botir-skillstheir own version, first seen Jul 24, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- nledford/engineering-review-board★ 11same name
- botirkhaltaev/botir-skills★ 4same name
- adxptived/Rust-Skills★ 1same name
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 repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/AGENTS.mdAGENTS.md
- animation-vocabularySkill
- apple-designSkill
- branchSkill
- codebase-designSkill
- code-qualitySkill
- commitSkill
- emil-design-engSkill
- english-modeSkill
- find-animation-opportunitiesSkill
- find-skillsSkill
- grillingSkill
- handoffSkill
- improve-animationsSkill
- investigateSkill
- ios-app-designSkill
- nix-darwinSkill
- no-useeffectSkill
- prototypeSkill
- react-best-practicesSkill
- resolving-merge-conflictsSkill
- review-animationsSkill
- self-reviewSkill
- seo-audit-fullSkill
- seo-auditSkill
- skill-creatorSkill
- slow-is-fastSkill
- ste-writingSkill
- tddSkill
- thermo-nuclear-code-quality-reviewSkill
- thermo-nuclear-reviewSkill
- thermosSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Start from the compiler error, API decision, or code under review.
- Very specific: line 13
Check the crate's edition, MSRV, and whether it is a library or binary.
- Distinctive: line 14
Follow the crate's existing conventions for errors, builders, and unsafe boundaries before introducing a new pattern.
- Very specific: line 16
When a lifetime is too short and no borrow reshaping fits, prefer an owned type over widening lifetimes or adding 'static bounds.
- Very specific: line 42
Use the applicable AGENTS.md test mode.
“Common” is measured: kept by at least 6 in 10 of the 3 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 Design Patterns
Start from the compiler error, API decision, or code under review. Read only the reference sections that match; the catalog is not a checklist to apply everywhere.
Establish applicability
- Check the crate's edition, MSRV, and whether it is a library or binary. Library crates carry compatibility constraints (
non_exhaustive, lint policy, public types) that binaries do not. - Follow the crate's existing conventions for errors, builders, and unsafe boundaries before introducing a new pattern.
- For borrow checker errors, reshape ownership before reaching for
clone,Rc, orArc. Treat a clone as a deliberate cost, not a way to silence the compiler. - When a lifetime is too short and no borrow reshaping fits, prefer an owned type over widening lifetimes or adding
'staticbounds.
Read by problem
| Problem or decision | Reference |
Move a value out of &mut, or swap enum variants | ownership-patterns.md — mem::take and mem::replace |
| Borrow two fields of a struct independently | ownership-patterns.md — Struct Decomposition |
| Choosing shared ownership, or tempted to clone | ownership-patterns.md — Rc/Arc Decision Guide |
| Guaranteed cleanup (locks, files, transactions) | ownership-patterns.md — RAII Guards, Finalisation in Destructors |
| Unsafe code needs a safe boundary | ownership-patterns.md — Contain Unsafety in Small Modules |
Function parameter types (&str vs &String) | api-design.md — Borrowed Types for Arguments |
| Many optional constructor parameters | api-design.md — Builder Pattern, Default Trait |
| Distinct types over the same representation | api-design.md — Newtype Pattern |
| Compile-time state transitions | api-design.md — Type State Pattern |
| Public types that must evolve without breaking callers | api-design.md — non_exhaustive, Constructor Conventions |
| FFI errors, strings, or object lifetimes | api-design.md — FFI Patterns |
| Dynamic dispatch without boxing | idioms.md — On-Stack Dynamic Dispatch |
Closure captures, post-setup immutability, Option in iterator chains | idioms.md |
| A consuming call fails and the caller needs the value back | idioms.md — Return Consumed Argument on Error |
| Reviewing existing Rust for common mistakes | common-pitfalls.md — start with Review Checklist |
Examples illustrate the shape of a pattern, not code to paste. Verify version-sensitive behavior against the crate's toolchain.
Complete the change
Use the applicable AGENTS.md test mode. cargo clippy flags most of the unnecessary clones and borrowed-type issues these references describe.
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.

