agentleFS
radimsemradimsem/mithril/.claude/skills/code-simplifier/SKILL.md

code-simplifier

Skill16 starsChanged 7 months agoApache-2.0View on GitHub

Use when writing, reviewing, or editing Rust code in this project - applies iterator chains, Option/Result chaining, early returns, borrow-over-clone, and if-let simplifications per project conventions

59 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use tdd-rust, type-design-analyzer and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • FlorianBruniauxSkill

    tdd-rust

    Also in 3 projects that use this

  • PaulKinlanSkill

    type-design-analyzer

    Analyzes type design quality focusing on encapsulation, invariant expression, usefulness, and enforcement. Provides quantitative ratings (1-10) for each dimension.

    Also in 3 projects that use this

  • PaulKinlanSkill

    comment-analyzer

    Analyzes code comments for accuracy, completeness, and long-term maintainability. Identifies misleading comments, comment rot, and documentation gaps.

    Also in 4 projects that use this

  • ufodev-ioSkill

    security-guardian

    Comprehensive security layer for all interactions with Claude: audits code, dependencies, commands, configs, and AI-generated output for vulnerabilities. Protects against prompt injection, data leaks, unsafe advice, and social engineering. Works in Cursor, Claude Code, claude.ai, and API contexts. Use always as a background security protocol in any Claude-powered environment.

    Also in 3 projects that use this

  • SentrySkill

    find-bugs

    Find bugs, security vulnerabilities, and code quality issues in local branch changes. Use when asked to review changes, find bugs, security review, or audit code on the current branch.

    Also in 3 projects that use this

  • tossSkill

    pr-triage

    Classify and summarize a PR for efficient review

    Also in 3 projects that use this

  • +1 more from PaulKinlan

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 54 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use iterator chains for transformation logic.

    line 14
  2. Very specific:

    Use match only when both arms carry logic.

    line 146

“Common” is measured: kept by at least 6 in 10 of the 54 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

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

// WRONG — main logic buried in nested conditions
fn process(entries: &[Entry], prefix: &str) -> Vec<String> {
    let mut results = Vec::new();
    if !entries.is_empty() {
        if !prefix.is_empty() {
            for entry in entries {
                if entry.name.starts_with(prefix) {
                    results.push(entry.name.strip_prefix(prefix).unwrap().to_owned());
                }
            }
        }
    }
    results
}

// RIGHT — guard clauses, then flat logic
fn process(entries: &[Entry], prefix: &str) -> Vec<String> {
    if entries.is_empty() || prefix.is_empty() {
        return Vec::new();
    }

    entries
        .iter()
        .filter(|e| e.name.starts_with(prefix))
        .filter_map(|e| e.name.strip_prefix(prefix))
        .map(|s| s.to_owned())
        .collect()
}

Signals to look for: is_empty(), is_none(), is_err(), boolean flags checked before the real work begins.

4. Avoid Redundant Clones

Borrow instead of cloning. When ownership is needed, use .to_owned() (not .clone()). Use String::from("...") for string literals (not "...".to_string()).

// WRONG — clones where borrows suffice
fn format_tool(tool: &Tool) -> String {
    let data = tool.data.clone();
    let name = tool.name.clone();
    format!("{}: {}", name, data)
}

// RIGHT — format! borrows automatically
fn format_tool(tool: &Tool) -> String {
    format!("{}: {}", tool.name, tool.data)
}
// WRONG
let label = "default".to_string();
let copy = config.clone();

// RIGHT
let label = String::from("default");
let copy = config.to_owned();

5. if let for Single-Variant Match

Use match only when both arms carry logic. Use if let when only one variant matters.

// WRONG — match with throwaway arm
match result {
    Some(val) => process(val),
    None => (),
}

// RIGHT
if let Some(val) = result {
    process(val);
}

// RIGHT — match when both arms carry logic
match result {
    Ok(ctx) => tool.format(ctx).await,
    Err(e) => log_and_report(e),
}

Common Mistakes

MistakeFix
.clone() to satisfy borrow checkerRestructure to borrow, or use .to_owned() if ownership needed
"literal".to_string()String::from("literal")
Nested if/match guarding empty/noneEarly return guard clause at top
for loop that only filters + mapsIterator chain with .filter().map().collect()
match x { Some(v) => f(v), None => () }if let Some(v) = x { f(v); }
Nested match on Option chains? operator or .and_then()

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.