tylores/dotfiles/rust-paradigms
Claude Code and agent skill by tylores/dotfiles
- community
Checking that the SKILL.md file is still in the repository.
Enforces global Rust architecture, memory safety, zero-cost lifetime abstractions, defensive error handling, and async concurrency. Use when reading, writing, or editing Rust source files (*.rs), tests, or Cargo.toml configuration.
Install
npx vskill@latest install tylores/dotfiles/rust-paradigmsSKILL.md
The same SKILL.md was published earlier as tylores/dotfiles/rust-paradigms.
Global Rust Architecture & Memory Safety
Context
Guidelines for building high-performance, memory-safe, and concurrent Rust systems. Code must be deeply idiomatic, leverage type-level constraints defensively, pass the borrow checker without unnecessary clones, and handle errors robustly.
Trigger Conditions
Activated automatically when reading, writing, or editing Rust source files (*.rs), tests, or Cargo.toml configuration.
Directives
1. Lifetime Management & Zero-Cost Abstractions
- Avoid Lazy Cloning: Do not insert
.clone()or.to_owned()to bypass borrow checker constraints. Leverage references, explicit lifetimes ('a), or structural changes to minimize data duplication. - Borrowing Conversions: Use
Cow<'a, str>orCow<'a, [T]>when a function can accept both borrowed and owned data. Passing slice parameters (&stror&[T]) is mandatory over owned configurations (&Stringor&Vec<T>). - Efficient Memory Reuse: Use
std::mem::takeorstd::mem::replaceto extract value out of a mutable reference without allocating new memory.
2. Explicit & Defensive Error Handling
- Production-Safe Logic: Never use
.unwrap(),.expect(), orpanic!in non-test production code paths. Handle failure states explicitly. - Idiomatic Propagation: Use the
?operator to bubble up errors. Combine functional combinators (.map_err(),.and_then(),.unwrap_or_else()) for expressive pipeline control. - Domain Error Types: Standardize error categorization:
- For libraries, use
thiserrorto define precise, type-safe custom error enums with individual#[error(...)]formats. - For applications, use
anyhowor similar wrapper frameworks for rich, high-level context tracing (.context()).
3. Asynchronous Execution & Concurrency
- Executor Safety: Never block the async thread pool (e.g. Tokio). Offload synchronous, blocking operations (heavy CPU math, blocking file system I/O, synchronous network calls) to a blocking thread using
tokio::task::spawn_blockingorstd::thread. - Lock Safety:
- Avoid holding synchronization guards (like
std::sync::MutexGuard) acrossawaitpoints. Usetokio::sync::Mutexif a lock must be held across yields, or restructure code to keep critical sections strictly synchronous. - Prefer lock-free atomic primitives (
std::sync::atomic) for simple variables and flag checks.
4. Idiomatic Pattern Matching & Expressive APIs
- Match Expression Safety: Prefer exhaustive
matchblocks over complexif/elselogic. Useif letorlet-else(divergingelse { return ... }statements) to isolate single-pattern extractions cleanly. - Expression-Driven Assignments: Declare variables directly from the evaluation of statements (
let val = if condition { x } else { y };) to minimize mutable variable declarations (let mut). - Safe Unsafe Policy: The use of
unsafeblocks is strictly prohibited unless explicitly requested by the user.
5. Testing & Verification
- Test Isolation: Utilize
cargo testframework. Keep unit tests in the same module file withinmod testsblocks, and integration tests in thetests/directory. - Document Testing: Provide compile-checked examples inside doc comments using
///`rust ...`to serve as both documentation and tests.
Quick Reference / Cheat Sheet
Directive | Standard Pattern | Anti-Pattern --- | --- | --- Error Propagation | let val = fallible_op()?; | .unwrap() or .expect() in production Slice Parameters | fn process(items: &[u8]) | fn process(items: &Vec<u8>) Async Blocking | tokio::task::spawn_blocking(move || ...) | Synchronous I/O directly in async block Extract Struct Value | std::mem::take(&mut field) | Cloning large struct to extract field Pattern Extraction | let Some(v) = opt else { return; }; | Nested if opt.is_some() { ... } Unsafe Policy | Banned unless explicitly requested | Indiscriminate unsafe { ... }
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 repositoryCheckingbotfiles/.gemini/antigravity-cli/skills/rust-paradigms/SKILL.md
Popularity
- 7-day trend score
- 0
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/tylores/dotfiles/rust-paradigms)