rust-patterns

rust-patterns is a skill for Claude Code from softspark/ai-toolkit. It costs 53 tokens per session (3,038 once invoked), scanned A, original, Apache-2.0.

A set of coding guidance for Rust, a programming language that checks memory use closely. It covers ownership, lifetimes, asynchronous code, errors, traits, and unsafe code.

In plain words
What is it for?
Use it when building or reviewing Rust applications, libraries, command-line tools, or Tokio-based asynchronous code.
Why use it?
It helps an agent produce Rust code that follows common project patterns and avoids frequent compiler and design problems.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: positional $N argument.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is let input = include_str!("../fixtures/large.json");.

Part of the ai-toolkit plugin — 115 skills, 44 agents, 14 hooks shipped together

Good fit Use it when building or reviewing Rust applications, libraries, command-line tools, or Tokio-based asynchronous code.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/softspark/ai-toolkit
agentmods
npx agentmods add skills/softspark/ai-toolkit/rust-patterns

Made for: Claude Code.

Or install ai-toolkit, the plugin that ships this one along with the rest of its 115 skills, 44 agents, 14 hooks.

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/softspark/ai-toolkit/rust-patterns/github.svg)](https://agentmods.dev/skills/softspark/ai-toolkit/rust-patterns)
Your own site
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/rust-patterns"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/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/softspark/ai-toolkit/rust-patterns"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/rust-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,038 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Rogue Agent · line 308
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
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.00053 $0.03038
Opus 5.5 $0.00021 $0.01215
Sonnet 5.5 $0.00011 $0.00608
Haiku 4.5 $0.00005 $0.00304

Measured 1mo ago against content hash 6d955fccd5b2, 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 0 findings 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

app/skills/rust-patterns/SKILL.md · 448 lines

How it starts

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

Rust Patterns

Project Structure

my-app/
├── Cargo.toml
├── src/
│   ├── main.rs           # Binary entry point
│   ├── lib.rs            # Library root (re-exports)
│   ├── error.rs          # Crate-level error types
│   ├── api/
│   │   ├── mod.rs
│   │   └── handlers.rs
│   └── domain/
│       ├── mod.rs
│       └── service.rs
├── tests/                # Integration tests (separate crate)
│   └── api_test.rs
├── benches/              # criterion benchmarks
│   └── throughput.rs
└── examples/
    └── demo.rs

Workspace layout for multi-crate projects:

# Cargo.toml (workspace root)
[workspace]
resolver = "2"
members = ["crates/core", "crates/api", "crates/cli"]

[workspace.dependencies]
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full"] }

Idioms / Code Style

Ownership and Borrowing

// Borrow when you only need to read
fn print_name(name: &str) { println!("{name}"); }

// Take ownership when storing or consuming the value
fn register_user(name: String) -> User {
    User { name, id: Uuid::new_v4() }
}

Lifetimes

// Annotate only when the compiler cannot infer
struct Parser<'input> {
    source: &'input str,
    pos: usize,
}

impl<'input> Parser<'input> {
    fn next_token(&mut self) -> Option<&'input str> {
        let start = self.pos;
        // ... advance self.pos ...
        Some(&self.source[start..self.pos])
    }
}

Trait-Based Design

trait Repository {
    fn find_by_id(&self, id: Uuid) -> Result<Option<User>, DbError>;
    fn save(&self, user: &User) -> Result<(), DbError>;
}

// Accept generics for testability
fn create_user(repo: &impl Repository, name: String) -> Result<User, AppError> {
    let user = User::new(name);
    repo.save(&user)?;
    Ok(user)
}

Iterators, Pattern Matching, Newtype

// Iterator chains over manual loops
let active: Vec<&str> = users.iter()
    .filter(|u| u.is_active)
    .map(|u| u.email.as_str())
    .collect();

// Exhaustive matching
match command {
    Command::Start { port } => start_server(port),
    Command::Stop => shutdown(),
}

// let-else for early exit (Rust 1.65+)
let Some(cfg) = load_config() else { return Ok(Config::default()); };

// Newtype to prevent primitive misuse
struct UserId(Uuid);
struct Email(String);

impl Email {
    fn new(raw: &str) -> Result<Self, ValidationError> {
        if raw.contains('@') { Ok(Self(raw.to_lowercase())) }
        else { Err(ValidationError::InvalidEmail) }
    }
}

Read the full file on GitHub · 448 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 · 448 lines · 53 tokens per session scan A 6d955fccd5b2

Subscribe to this mod's changes

rust-patterns is a skill published in the GitHub repository softspark/ai-toolkit (181 stars, last pushed today), licensed Apache-2.0. It adds 53 tokens to every session and 3,038 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

rust-best-practices

Idiomatic Rust development with ownership, borrowing, lifetimes, error handling (thiserror/anyhow), async Tokio patterns, traits, generics, Clippy linting, cargo workspaces, and production patterns for web services (axum/actix-web), CLI tools (clap), and systems programming. Use when writing, reviewing, or debugging…

medy-gribkov/arcana · 80 tokens

rust-performance

Use when writing or reviewing performance-sensitive Rust, profiling slow Rust code, reducing allocations, investigating latency or throughput regressions, or diagnosing bloated binaries and long compile times. Covers allocation, iterators, data layout, hashing, async/concurrency, build profiles, Clippy review gates…

Lu1sDV/skillsmd · 146 tokens

rust-concurrency

Use when implementing or debugging Rust threads, Send/Sync bounds, Arc and synchronization, channels, Tokio async tasks, cancellation, graceful shutdown, backpressure, deadlocks, or choosing Rayon for CPU-bound parallel work.

Lu1sDV/skillsmd · 47 tokens

rust-tdd

Use when implementing Rust features test-first, reproducing Rust bugs with regression tests, characterizing legacy Rust, or applying red-green-refactor with cargo test. Covers boundary and equivalence cases, proptest shrinking, mockall expectations, rstest fixtures, async/concurrent/CLI tests, and coverage…

Lu1sDV/skillsmd · 76 tokens

rust-unsafe-ffi

Use when writing or reviewing Rust unsafe blocks, raw-pointer abstractions, MaybeUninit or manual Drop code, unsafe trait implementations, or C/C++ FFI bindings. Covers pointer validity, aliasing and provenance, C ABI/layout, callbacks, allocator ownership, C strings, unwinding, Rust 2024 unsafe syntax, and…

Lu1sDV/skillsmd · 79 tokens

rust-wasm

Use when compiling Rust to WebAssembly, integrating wasm-bindgen or web-sys with browser JavaScript and the DOM, packaging with wasm-pack, choosing wasm32-unknown-unknown versus wasm32-wasip1 or wasm32-wasip2, designing WIT component interfaces, or debugging Wasm loading, capabilities, and target tests.

Lu1sDV/skillsmd · 73 tokens