adelabdelgawad/fullstack-agents/rust-correctness

Claude Code and agent skill by adelabdelgawad/fullstack-agents

Trust tier 3
  • community
Source check pending

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-correctness

SKILL.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.

ForbiddenFix
.clone() to silence a borrow errorRestructure: 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

  • Result for ALL fallible operations — propagate with ?.
  • panic!/unwrap/expect ONLY 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 else for early returns.

Async Concurrency (Tokio)

ForbiddenWhyFix
std::sync::MutexGuard held across .awaitFuture becomes !Send — won't spawnDrop the guard before awaiting, or tokio::sync::Mutex
Rc/RefCell in spawned tasks!SendArc / Arc<Mutex<T>>
Blocking calls (std::fs, heavy CPU, reqwest::blocking) in asyncStarves the runtimetokio::task::spawn_blocking or async equivalents
Inconsistent lock acquisition orderDeadlockOne canonical order, documented
.lock().unwrap() everywherePoisoned mutex panics cascadeHandle PoisonError or use tokio Mutex (no poisoning)
DB connection held across unrelated .awaitsPool exhaustionAcquire late, release early

Channels (mpsc, broadcast, watch) over shared state where the data flows one way.

Smart Pointer Selection

NeedUse
Heap allocation / recursive typeBox<T>
Shared ownership, single threadRc<T>
Shared ownership, multi-thread / asyncArc<T>
Interior mutability, single threadRefCell<T> (runtime-checked)
Interior mutability, multi-threadMutex<T> / RwLock<T> (tokio variants in async)
Breaking reference cyclesWeak<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.
  • 'static means "lives forever or owned" — don't reach for it to silence

E0597; restructure ownership instead.

Traits & Generics

  • impl Trait in 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, get Into free — never implement both.
  • Object safety: async fn in traits needs #[async_trait] for dyn use.

Pattern Matching

  • match must be exhaustive — avoid _ => on YOUR OWN enums; adding a variant

should break compilation everywhere it matters.

  • if let for single-variant interest; let else for extract-or-return.
  • matches!() for boolean checks.

Iterators & Collections

  • Iterator chains over index loops: filter/map/collect — lazy until consumed.
  • with_capacity when the size is known.
  • entry() API for HashMap upsert: map.entry(k).or_insert_with(Vec::new).push(v).
  • Closures: default borrow capture; move for 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

ErrorSection
E0382 (use after move), E0499, E0502, E0505, E0507Ownership & Borrowing
E0106, E0515, E0597 (lifetime)Lifetimes
"future cannot be sent between threads"Async Concurrency
E0038 (not object safe)Traits & Generics
non-exhaustive matchPattern 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/adelabdelgawad/fullstack-agents/rust-correctness/badge)](https://verified-skill.com/skills/adelabdelgawad/fullstack-agents/rust-correctness)

Something wrong with this skill or its page? Tell us.