adelabdelgawad/fullstack-agents/rust-correctness
Claude Code and agent skill by adelabdelgawad/fullstack-agents
- community
Checking that the SKILL.md file is still in the repository.
Rust correctness — ownership, borrowing, lifetimes, async and Send/Sync hazards, error handling, compiler errors E0382/E0499/E0502/E0597. For any non-trivial Rust.
Install
npx vskill@latest install adelabdelgawad/fullstack-agents/rust-correctnessSKILL.md
The same SKILL.md was published earlier as adelabdelgawad/fullstack-agents/rust-correctness.
Rust Correctness Reference
The language-level discipline behind every Rust skill. Organized as forbidden patterns with fixes — these are the bugs that compile (or almost compile) and bite later.
Ownership & Borrowing
Rules: every value has one owner; any number of & XOR exactly one &mut; references never outlive their referent.
| Forbidden | Fix | |
|---|---|---|
.clone() to silence a borrow error | Restructure: shorten the borrow's scope, or split the struct | |
& and &mut to the same data alive together (E0502) | Narrow the shared borrow's lifetime (NLL ends a borrow at last use) | |
| Returning a reference to a local (E0515) | Return the owned value | |
| Moving out of a borrowed value (E0507) | std::mem::take/replace, clone deliberately, or take ownership | |
&Vec<T> / &String parameters | &[T] / &str — accept slices | |
Two &mut to the same data (E0499) | Split borrows per field, or reorder operations |
Panic vs Result
Resultfor ALL fallible operations — propagate with?.panic!/unwrap/expectONLY in: tests,main()bootstrap, and genuinely
unreachable invariants (with a message saying why).
- NEVER in handlers, use cases, repositories, or library code.
let Some(x) = opt else { return Err(...) }—let elsefor early returns.
Async Concurrency (Tokio)
| Forbidden | Why | Fix | |
|---|---|---|---|
std::sync::MutexGuard held across .await | Future becomes !Send — won't spawn | Drop the guard before awaiting, or tokio::sync::Mutex | |
Rc/RefCell in spawned tasks | !Send | Arc / Arc<Mutex<T>> | |
Blocking calls (std::fs, heavy CPU, reqwest::blocking) in async | Starves the runtime | tokio::task::spawn_blocking or async equivalents | |
| Inconsistent lock acquisition order | Deadlock | One canonical order, documented | |
.lock().unwrap() everywhere | Poisoned mutex panics cascade | Handle PoisonError or use tokio Mutex (no poisoning) | |
DB connection held across unrelated .awaits | Pool exhaustion | Acquire late, release early |
Channels (mpsc, broadcast, watch) over shared state where the data flows one way.
Smart Pointer Selection
| Need | Use | |
|---|---|---|
| Heap allocation / recursive type | Box<T> | |
| Shared ownership, single thread | Rc<T> | |
| Shared ownership, multi-thread / async | Arc<T> | |
| Interior mutability, single thread | RefCell<T> (runtime-checked) | |
| Interior mutability, multi-thread | Mutex<T> / RwLock<T> (tokio variants in async) | |
| Breaking reference cycles | Weak<T> |
Arc<Mutex<T>> with no writer is a smell — Arc<T> suffices for read-only.
Lifetimes
- Let elision work; annotate only when the compiler asks.
- A named lifetime ties OUTPUT to INPUT:
fn first<'a>(s: &'a str) -> &'a str. 'staticmeans "lives forever or owned" — don't reach for it to silence
E0597; restructure ownership instead.
Traits & Generics
impl Traitin argument/return position for single concrete types; generics
<T: Trait> when the caller chooses; dyn Trait when you need runtime dispatch or heterogeneous collections (ports use Arc<dyn Repo>).
- Implement
From, getIntofree — never implement both. - Object safety:
async fnin traits needs#[async_trait]fordynuse.
Pattern Matching
matchmust be exhaustive — avoid_ =>on YOUR OWN enums; adding a variant
should break compilation everywhere it matters.
if letfor single-variant interest;let elsefor extract-or-return.matches!()for boolean checks.
Iterators & Collections
- Iterator chains over index loops:
filter/map/collect— lazy until consumed. with_capacitywhen the size is known.entry()API for HashMap upsert:map.entry(k).or_insert_with(Vec::new).push(v).- Closures: default borrow capture;
movefor spawned tasks and returns.
Unsafe
Forbidden in application services. If FFI or a sound abstraction genuinely requires it: isolate in one module, document the safety contract on every unsafe block, and test the invariants. Never transmute as a shortcut.
Compiler Error Quick-Route
| Error | Section | |
|---|---|---|
| E0382 (use after move), E0499, E0502, E0505, E0507 | Ownership & Borrowing | |
| E0106, E0515, E0597 (lifetime) | Lifetimes | |
| "future cannot be sent between threads" | Async Concurrency | |
| E0038 (not object safe) | Traits & Generics | |
| non-exhaustive match | Pattern Matching |
When MULTIPLE compiler errors cascade: fix in dependency order, rebuild ONCE (see batch-error-resolution).
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/fullstack-agents/skills/rust-correctness/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/adelabdelgawad/fullstack-agents/rust-correctness)