rust

A Rust coding guide for programs written in Rust, a language designed to prevent many memory errors during compilation. It explains ownership, borrowing, lifetimes, error results, optional values, traits, and safe concurrent code.

In plain words
What is it for?
Use it when writing or reviewing Rust files, designing type-safe interfaces, handling errors, managing memory ownership, or building concurrent code.
Why use it?
It helps developers work with Rust's rules for sharing and managing data, and represent failures or missing values explicitly instead of discovering them later at runtime.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/dean0x/devflow/rust
Any agent
npx skills add dean0x/devflow --skill rust
Clone the repo
git clone --depth 1 https://github.com/dean0x/devflow

Made for: Claude Code, Codex.

Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,360 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00063 $0.01360
Opus 5 $0.00032 $0.00680
Sonnet 5 $0.00013 $0.00272
Haiku 4.5 $0.00006 $0.00136

Measured 2d ago against content hash d0aa3dabd143, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rust 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 2d 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.

src/assets/skills/rust/SKILL.md · 149 lines

How it starts

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

Rust Patterns

Reference for Rust-specific patterns, ownership model, and type-driven design.

Iron Law

MAKE ILLEGAL STATES UNREPRESENTABLE [15][2, C-VALIDATE]

Encode invariants in the type system. If a function can fail, return Result. If a value might be absent, return Option. If a state transition is invalid, make it uncompilable. Runtime checks are a fallback, not a strategy.

When This Skill Activates

  • Working with Rust codebases
  • Designing type-safe APIs
  • Managing ownership and borrowing
  • Implementing error handling
  • Writing concurrent code

Ownership & Borrowing [1, Ch.4][11]

Prefer borrowing over cloning — accept &str not String, &[T] not &Vec<T> [2, C-BORROW]. The borrow checker enforces the Stacked Borrows aliasing model at compile time [6][11]. Lifetime annotations required when elision rules can't resolve ambiguity [1, Ch.10].

// BAD: fn process(data: String) — takes ownership unnecessarily
fn process(data: &str) -> usize { data.len() } // GOOD: borrow [2, C-BORROW]

See references/ownership.md for elision rules, interior mutability, Cow, and Pin.


Error Handling [8][9][16]

Use thiserror for libraries (typed, matchable variants); anyhow for applications (ergonomic propagation). Never use Box<dyn Error> in library APIs [8][16].

#[derive(thiserror::Error, Debug)]
pub enum AppError {
    #[error("IO error reading {path}")]
    Io { path: String, #[source] source: io::Error },
    #[error("{entity} with id {id} not found")]
    NotFound { entity: String, id: String },
}
// ? operator propagates with source context [1, Ch.9]
fn read_config(path: &str) -> Result<Config, AppError> {
    let raw = fs::read_to_string(path).map_err(|e| AppError::Io { path: path.into(), source: e })?;
    toml::from_str(&raw).map_err(|e| AppError::Parse { source: e })
}

Type System

Newtype Pattern [2, C-NEWTYPE][15]

struct UserId(String);   struct OrderId(String);
// Can't accidentally swap — compiler enforces [15]
fn get_order(user_id: &UserId, order_id: &OrderId) -> Result<Order, AppError> { todo!() }

Read the full file on GitHub · 149 lines

Files

What ships with it

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

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. 2d ago First seen · 149 lines · 63 tokens per session scan A d0aa3dabd143

Subscribe to this mod's changes

rust is a skill published in the GitHub repository dean0x/devflow (19 stars, last pushed 2d ago), licensed MIT. It adds 63 tokens to every session and 1,360 once invoked, about $0.0003 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-08-30.

Related

Other skills, from other repositories

data-engineering

Skill "data-engineering" from fengshao1227/ccg-workflow, covering 数据工程域 · data engineering, 域概览, 数据管道编排, 框架对比 and airflow 核心模式.

fengshao1227/ccg-workflow · 53 tokens

verify-change

变更校验关卡。分析代码变更,检测文档同步状态,评估变更影响范围。当用户提到变更检查、文档同步、代码审查、提交前检查、diff分析时使用。在设计级变更、重构完成时自动触发。.

fengshao1227/ccg-workflow · 65 tokens

verify-security

安全校验关卡。自动扫描代码安全漏洞,检测危险模式,确保安全决策有文档记录。当用户提到安全扫描、漏洞检测、安全审计、代码安全、OWASP、注入检测、敏感信息泄露时使用。在新建模块、安全相关变更、攻防任务、重构完成时自动触发。.

fengshao1227/ccg-workflow · 78 tokens

liquid-glass

Apple Liquid Glass design system. Use when building UI with translucent, depth-aware glass morphism following Apple's design language. Provides CSS tokens, component patterns, dark/light mode, and animation specs.

fengshao1227/ccg-workflow · 43 tokens

gen-docs

文档生成器。自动分析模块结构,生成 README.md 和 DESIGN.md 骨架。当用户提到生成文档、创建README、创建DESIGN、文档骨架、文档模板时使用。在新建模块开始时自动触发。.

fengshao1227/ccg-workflow · 58 tokens

verify-module

模块完整性校验关卡。扫描目录结构、检测缺失文档、验证代码与文档同步。当用户提到模块校验、文档检查、结构完整性、README检查、DESIGN检查时使用。在新建模块完成时自动触发。.

fengshao1227/ccg-workflow · 61 tokens