clean-code-rust
Skill1 starsChanged 3 months agoMITView on GitHub
Use when writing or reviewing Rust — deeper idioms (ownership/borrows, error handling with thiserror/anyhow, avoiding unwrap and Rc<RefCell>, iterator style, newtypes).
In this repository9 other files it gives its agents.
- agent-orchestrationSkill
- clean-code-audioSkill
- clean-code-bashSkill
- clean-code-coreSkill
- clean-code-cppSkill
- clean-code-cSkill
- clean-code-goSkill
- clean-code-pythonSkill
- clean-code-tsSkill
The file
Files
Clean-code Rust (depth)
On top of the base rules (edition 2021, clippy -D warnings, rustfmt, cargo test).
Errors
- Libraries: define an error enum with
thiserror, returnResult<_, MyError>, propagate with?. - Binaries:
anyhow::Result+.context("..."). Never.unwrap()/.expect()outside tests or justified startup.
Ownership & borrows
- Take
&T/&mut Tin function signatures; own only when you must. Return owned values. - Reach for
Rc<RefCell<_>>only when shared mutability is genuinely required — it's a smell as a default; prefer restructuring ownership or passing&mut. - Newtypes (
struct UserId(u64)) over bare primitives for meaning + type safety.
Style
- Iterators/adapters over manual index loops;
?over match-on-error pyramids. - Producing many values: return
impl Iterator<Item = T>and let the caller decide whether tocollect(). - A validated newtype has a constructor returning
Result(Normalized::new(v)?), so holding one proves the check ran. - Derive (
Debug,Clone,PartialEq) rather than hand-writing.impl Traitin args for flexibility. clippy::pedanticis a good aspiration; silence lints with a reason, never blanket-allow.
Smells
.clone()sprinkled to dodge the borrow checker → rethink ownership.unsafewithout// SAFETY:→ not acceptable.- Stringly-typed IDs/states → newtype or enum.
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.

