rust-patterns

rust-patterns is a skill for Claude Code, Codex from DVNghiem/FlowDeck. It costs 32 tokens per session (3,336 once invoked), scanned A, original, MIT.

A guide to common Rust programming patterns, covering ownership, borrowing, lifetimes, error handling, traits, smart pointers, and asynchronous code with Tokio.

In plain words
What is it for?
Use it when writing or reviewing Rust crates and services, resolving ownership or borrow-checker errors, handling failures, designing traits, or building asynchronous Tokio programs.
Why use it?
Rust prevents many memory and concurrency errors, but its rules can be difficult to learn. The guide explains idiomatic ways to work within those rules.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or reviewing Rust crates and services, resolving ownership or borrow-checker errors, handling failures, designing traits, or building asynchronous Tokio programs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dvnghiem/flowdeck/rust-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add DVNghiem/FlowDeck --skill rust-patterns
Clone the repo
git clone --depth 1 https://github.com/DVNghiem/FlowDeck

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rust-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/dvnghiem/flowdeck/rust-patterns/github.svg)](https://agentmods.dev/skills/dvnghiem/flowdeck/rust-patterns)
Your own site
<a href="https://agentmods.dev/skills/dvnghiem/flowdeck/rust-patterns"><img src="https://agentmods.dev/badge/skills/dvnghiem/flowdeck/rust-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rust-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/dvnghiem/flowdeck/rust-patterns"><img src="https://agentmods.dev/badge/skills/dvnghiem/flowdeck/rust-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,336 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00032 $0.03336
Opus 5.5 $0.00013 $0.01334
Sonnet 5.5 $0.00006 $0.00667
Haiku 4.5 $0.00003 $0.00334

Measured 1mo ago against content hash 5c2d42d4e008, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

rust-patterns scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

let data = fetch(url).await
src/skills/rust-patterns/SKILL.md · 493 lines

How it starts

The opening of the file, as written. The whole thing — 493 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rust Patterns Skill

Safe, idiomatic Rust for production systems. Covers the ownership model, trait system, and async patterns.

When to Activate

Activate when:

  • Writing new Rust crates or services
  • Reviewing Rust code for safety and idiom
  • Fighting the borrow checker and looking for solutions
  • Designing async services with Tokio
  • Choosing between smart pointer types

Ownership and Borrowing — Mental Model

Every value has exactly one owner. When the owner goes out of scope, the value is dropped. References borrow a value without taking ownership.

The Three Rules

  1. Each value has exactly one owner.
  2. There can be any number of shared (&T) references, OR exactly one exclusive (&mut T) reference — never both at the same time.
  3. References must not outlive the value they point to.
fn main() {
    let s1 = String::from("hello");
    let s2 = s1;          // ownership moved to s2
    // println!("{s1}");  // compile error: s1 moved

    let s3 = String::from("world");
    let r1 = &s3;         // shared borrow
    let r2 = &s3;         // another shared borrow — fine
    println!("{r1} {r2}");

    let mut s4 = String::from("mutable");
    let r3 = &mut s4;     // exclusive borrow
    r3.push_str("!");
    // let r4 = &s4;      // compile error: s4 already mutably borrowed
}

Clone When You Need a Copy

// clone() is explicit and potentially expensive — use it knowingly
let original = vec![1, 2, 3];
let copy = original.clone();
// both are usable

// For cheap copies, implement Copy (stack-allocated types)
#[derive(Clone, Copy)]
struct Point { x: f64, y: f64 }

let p1 = Point { x: 1.0, y: 2.0 };
let p2 = p1;  // copied, not moved — p1 still valid

Lifetime Annotations

The compiler infers lifetimes in most cases via elision rules. Annotate when the compiler cannot determine the relationship.

When Annotations Are Required

// Return value borrows from one of the arguments — annotate the relationship
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
    if x.len() > y.len() { x } else { y }
}

// Struct holding a reference must declare its lifetime
struct Excerpt<'a> {
    text: &'a str,
}

impl<'a> Excerpt<'a> {
    fn content(&self) -> &str {
        self.text  // lifetime elided — same as self's lifetime
    }
}

Read the full file on GitHub · 493 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 493 lines · 32 tokens per session scan A 5c2d42d4e008

Subscribe to this mod's changes

rust-patterns is a skill published in the GitHub repository DVNghiem/FlowDeck (36 stars, last pushed 2mo ago), licensed MIT. It adds 32 tokens to every session and 3,336 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.