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.
npx agentmods add skills/ahonn/dotfiles/rust-design-patternsnpx skills add ahonn/dotfiles --skill rust-design-patternsgit clone --depth 1 https://github.com/ahonn/dotfilesWrote 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.
[](https://agentmods.dev/skills/ahonn/dotfiles/rust-design-patterns)<a href="https://agentmods.dev/skills/ahonn/dotfiles/rust-design-patterns"><img src="https://agentmods.dev/badge/skills/ahonn/dotfiles/rust-design-patterns.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00077 | $0.02047 |
| Opus 5 | $0.00039 | $0.01024 |
| Sonnet 5 | $0.00015 | $0.00409 |
| Haiku 4.5 | $0.00008 | $0.00205 |
Grade A, and why
rust-design-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 yesterday.
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.
How it starts
The opening of the file, as written. The whole thing — 316 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Rust Design Patterns
Idioms and patterns for writing idiomatic Rust code. Focus on Rust-specific patterns that leverage ownership, borrowing, and the type system.
Decision Tree
Problem?
├── Borrow checker error?
│ ├── Need to move value from &mut enum → mem::take/replace
│ ├── Need independent field borrows → struct decomposition
│ ├── Tempted to clone? → Check: Rc/Arc? Or refactor ownership?
│ └── Lifetime too short → consider owned types or 'static
│
├── API design?
│ ├── Many constructor params → Builder pattern
│ ├── Accept flexible input → Borrowed types (&str, &[T])
│ ├── Type safety at compile time → Newtype pattern
│ ├── Default values needed → Default trait + struct update syntax
│ └── Resource cleanup needed → RAII guards (Drop trait)
│
├── FFI boundary?
│ ├── Error handling → Integer codes + error description fn
│ ├── String passing → CString/CStr patterns
│ └── Object lifetime → Opaque pointers with explicit free
│
├── Unsafe code?
│ ├── Need unsafe operations → Contain in small modules with safe wrappers
│ └── FFI types → Type consolidation into opaque wrappers
│
└── Performance concern?
├── Avoid monomorphization bloat → On-stack dynamic dispatch
└── Reduce allocations → mem::take instead of clone
Quick Patterns
Borrowed Types (CRITICAL)
Prefer &str over &String, &[T] over &Vec<T>:
// Bad: only accepts &String
fn process(s: &String) { }
// Good: accepts &String, &str, string literals
fn process(s: &str) { }
// Usage: all work with &str
process(&my_string); // String
process("literal"); // &'static str
process(&my_string[1..5]); // slice
Why: Deref coercion allows &String → &str, but not reverse. Using borrowed types accepts more input types.
mem::take Pattern (CRITICAL)
Move owned values out of &mut without clone:
use std::mem;
enum State {
Active { data: String },
Inactive,
}
fn deactivate(state: &mut State) {
if let State::Active { data } = state {
// Take ownership without clone
let owned_data = mem::take(data);
*state = State::Inactive;
// use owned_data...
}
}
What ships with it
3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- yesterday First seen · 316 lines · 77 tokens per session scan A da8cc58bf1fb
rust-design-patterns is a skill published in the GitHub repository ahonn/dotfiles (62 stars, last pushed 4d ago), licensed MIT. It adds 77 tokens to every session and 2,047 once invoked, about $0.0004 per session on Opus 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.
Other skills, from other repositories
scaffold-rust
Scaffold a complete Rust project with CI/CD, release pipeline, and sr.yaml. Uses cargo as the native build system. Loads on top of scaffold-project (run that first for cross-language standard files). Use when creating a new Rust CLI, library, or workspace, or when the user mentions "new Rust project", "cargo init", or…
scaffold-go
Scaffold a complete Go project with CI/CD, release pipeline, Makefile, sr.yaml, .envrc, and standard files. Uses go toolchain and make as the native build system. Loads on top of scaffold-project (run that first for cross-language standard files). Use when creating a new Go CLI, service, or module, or when the user…
scaffold-node
Scaffold a complete Node/TypeScript project with CI/CD, release pipeline, sr.yaml, .envrc, and standard files. Uses pnpm and biome. Loads on top of scaffold-project (run that first for cross-language standard files). Use when creating a new Node.js app, TypeScript library, or website, or when the user mentions "new…
scaffold-python
Scaffold a complete Python project with CI/CD, release pipeline, justfile, sr.yaml, pyproject.toml, .envrc, and standard files. Uses uv, ruff, and justfile (Python lacks a native task runner like pnpm scripts, so just fills that gap). Loads on top of scaffold-project (run that first for cross-language standard files).…
write-code
Operational tech-stack picks and coding patterns: error handling per language, commit conventions, interface design (Go SDKs), workspace layout, junior-friendly bias. Use when writing or reviewing implementation code and you need a concrete answer for "what tool, pattern, or idiom." Do NOT use for design-tradeoff…
ratatui
Rust terminal UI framework - widgets, components, layouts, events, input handling, and state management for TUI apps.