idiomatic-rust

idiomatic-rust is a skill for Claude Code, Codex from rewrite-rs/skills. It costs 75 tokens per session (1,212 once invoked), scanned A, original, BSD-3-Clause.

A guide to writing Rust in styles that Rust developers commonly expect, such as iterator pipelines, conversions, and strongly typed wrappers.

In plain words
What is it for?
Writing new Rust, reviewing translated Rust, and choosing idiomatic alternatives to index loops, hand-written conversions, and bare primitive values.
Why use it?
It helps replace code that merely copies patterns from another language with code that fits Rust’s type system and conventions.

Skill for Claude CodeCodex

Written for Claude Code and Codex: shipped in a Claude Code plugin, but also agents/openai.yaml present.

Part of the rewrite-rs-skills plugin — 28 skills shipped together

Good fit Writing new Rust, reviewing translated Rust, and choosing idiomatic alternatives to index…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rewrite-rs/skills/idiomatic-rust
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 rewrite-rs/skills --skill idiomatic-rust
Clone the repo
git clone --depth 1 https://github.com/rewrite-rs/skills

Made for: Claude Code, Codex.

Or install rewrite-rs-skills, the plugin that ships this one along with the rest of its 28 skills.

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 idiomatic-rust

README.md
[![agentmods](https://agentmods.dev/badge/skills/rewrite-rs/skills/idiomatic-rust.svg)](https://agentmods.dev/skills/rewrite-rs/skills/idiomatic-rust)
Your own site
<a href="https://agentmods.dev/skills/rewrite-rs/skills/idiomatic-rust"><img src="https://agentmods.dev/badge/skills/rewrite-rs/skills/idiomatic-rust.svg" alt="Measured on agentmods" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,212 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.
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.00075 $0.01212
Opus 5 $0.00037 $0.00606
Sonnet 5 $0.00015 $0.00242
Haiku 4.5 $0.00007 $0.00121

Measured 6d ago against content hash 429584c33711, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

idiomatic-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 6d 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.

skills/rust/idiomatic-rust/SKILL.md · 125 lines

How it starts

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

Idiomatic Rust

This skill is about expression: what form does a Rust reader expect to see?

The shape of idiomatic Rust

Prefer expressions over statements: a match that returns a value beats one that assigns to a let mut in every arm, and a chain that produces the answer beats a flag variable set in a loop and checked after it — let the type system carry invariants instead of runtime checks. let ... else keeps an early return at the top instead of drifting the happy path rightward under a nested if let; matches! is the boolean test on a pattern. If-let chains compose conditions where the toolchain supports them — a recent edition, so check the repo MSRV first.

Iterators

Reach for the iterator pipeline before the index loop — for i in 0..v.len() { ... v[i] ... } almost always has an iterator equivalent, and the iterator version fails to compile on bad bounds instead of panicking at runtime. Collect into the type you want, not a Vec you then convert:

// Reads like a translation.
let mut names = Vec::new();
for user in &users {
    names.push(user.name.clone());
}

// Reads like Rust.
let names: Vec<String> = users.iter().map(|u| u.name.clone()).collect();

collect also targets HashMap, HashSet, String, and Result<Vec<_>, _> — that last is how ? composes with iteration.

use std::num::ParseIntError;

fn parse_all(lines: &[&str]) -> Result<Vec<i64>, ParseIntError> {
    lines.iter().map(|line| line.parse::<i64>()).collect::<Result<Vec<_>, _>>()
}

Prefer the plain for loop when the body has real side effects or an early exit a combinator would obscure — clarity beats iterator purity.

Conversions

When one type can be built from another, implement FromInto comes free through the blanket impl, so never write both directions by hand. When the conversion can fail, implement TryFrom instead of From plus a panic or a sentinel value.

struct Celsius(f64);
struct Fahrenheit(f64);

impl From<Celsius> for Fahrenheit {
    fn from(c: Celsius) -> Self {
        Fahrenheit(c.0 * 9.0 / 5.0 + 32.0)
    }
}

Read the full file on GitHub · 125 lines

Files

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.

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. 6d ago First seen · 125 lines · 75 tokens per session scan A 429584c33711

Subscribe to this mod's changes

idiomatic-rust is a skill published in the GitHub repository rewrite-rs/skills (1 stars, last pushed 21d ago), licensed BSD-3-Clause. It adds 75 tokens to every session and 1,212 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-08-31.

Related

Other skills, from other repositories

polars

High-performance DataFrame library for Python ETL, analytics, and pandas migration. Use for expression-based data manipulation with lazy query optimization, parallel execution, streaming out-of-core processing, Arrow interoperability, and optional GPU execution.

K-Dense-AI/scientific-agent-skills · 47 tokens

rust-engineer

Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions. Implements ownership patterns, manages lifetimes, designs trait hierarchies, builds async applications with tokio, and structures error handling with Result/Option. Use when building Rust applications, solving ownership or…

Jeffallan/claude-skills · 120 tokens

rust-crate-ci

Load before editing any Rust crate in this repo (currently runners/swarm-sandbox-runner). Covers the mandatory local validation gate, common rustfmt/clippy pitfalls, and Windows-specific Rust correctness patterns that CI enforces but are hard to catch locally without a Windows toolchain.

ZaxbyHub/opencode-swarm · 60 tokens

solana-development

Build, test, deploy, and audit Solana programs with Anchor or native Rust, and build with ZK Compression (Light Protocol). Use when developing Solana smart contracts, implementing token operations, optimizing compute, deploying to networks, auditing programs for vulnerabilities, or creating compressed tokens/PDAs.

tenequm/skills · 63 tokens

rust-skills

Comprehensive Rust coding guidelines with 265 rules across 26 categories. Use when writing, reviewing, or refactoring Rust code. Covers ownership, error handling, async patterns, concurrency, unsafe code, API design, memory optimization, performance, numeric safety, conversions, serde, pattern matching, macros…

leonardomso/rust-skills · 84 tokens

pinocchio-development

Comprehensive guide for building high-performance Solana programs using Pinocchio - the zero-dependency, zero-copy framework. Covers account validation, CPI patterns, optimization techniques, and migration from Anchor.

sendaifun/skills · 44 tokens