code-simplifier

Rust project guidance for writing simpler, idiomatic code with iterator chains, concise Option and Result handling, early returns, and fewer unnecessary clones.

In plain words
What is it for?
Writing, reviewing, or editing Rust code in this project.
Why use it?
It helps keep Rust changes consistent with the project’s coding conventions and reduces avoidable complexity.

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/radimsem/mithril/code-simplifier
Any agent
npx skills add radimsem/mithril --skill code-simplifier
Clone the repo
git clone --depth 1 https://github.com/radimsem/mithril

Made for: Claude Code, Codex.

Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,218 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.00044 $0.01218
Opus 5 $0.00022 $0.00609
Sonnet 5 $0.00009 $0.00244
Haiku 4.5 $0.00004 $0.00122

Measured yesterday against content hash 3566ebf6a3f3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-simplifier 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.

.claude/skills/code-simplifier/SKILL.md · 177 lines

How it starts

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

Rust Code Simplifier

Proactive pattern guide for writing simple, idiomatic Rust. Apply these patterns whenever writing or modifying Rust code — not only when asked to simplify.

Project rules: These patterns align with .claude/rules/rust-patterns.md. When in doubt, re-read the rules file.

1. Iterator Chains Over Manual Loops

Use iterator chains for transformation logic. Reserve for loops only when the body needs early error returns with ?.

// WRONG
let mut names = Vec::new();
for tool in tools {
    if tool.is_available() {
        names.push(tool.name().to_owned());
    }
}

// RIGHT
let names: Vec<String> = tools
    .iter()
    .filter(|t| t.is_available())
    .map(|t| t.name().to_owned())
    .collect();

When to keep a loop: The body calls fallible operations with ?:

// Loop is correct here — early return on error
for entry in entries {
    let meta = entry.metadata().context("failed to read metadata")?;
    process(&meta).await?;
}

2. Option/Result Chaining

Flatten nested match/if let on Option/Result into chained combinators or ?.

// WRONG — nested match pyramid
match config.project.as_ref() {
    Some(project) => match project.settings.as_ref() {
        Some(settings) => match settings.get("key") {
            Some(val) => Some(val.to_owned()),
            None => None,
        },
        None => None,
    },
    None => None,
}

// RIGHT — ? operator for Option propagation
config
    .project
    .as_ref()?
    .settings
    .as_ref()?
    .get("key")
    .map(|v| v.to_owned())

Combinator quick reference:

Pattern Use when
? Propagate None/Err to caller
.map() Transform inner value
.and_then() Chain operations that return Option/Result
.unwrap_or_default() Fallback to Default impl
.unwrap_or_else(|| ...) Fallback with computation

3. Early Returns

Guard against invalid/empty states at the top. Avoid deep nesting for the main logic.

Read the full file on GitHub · 177 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. yesterday First seen · 177 lines · 44 tokens per session scan A 3566ebf6a3f3

Subscribe to this mod's changes

code-simplifier is a skill published in the GitHub repository radimsem/mithril (16 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 44 tokens to every session and 1,218 once invoked, about $0.0002 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.