Agent skill

RTK Rust Code Simplifier

by rtk-ai in rtk-ai/rtk

Reviews RTK's Rust code for over-engineering and verbose patterns, applying idioms like iterator chains and early returns while protecting a specific list of constraints from being simplified away.

Apache-2.0Auto-check passedDevelopment

Install RTK Rust Code Simplifier

skills CLI
$ npx skills add rtk-ai/rtk --skill code-simplifier -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rtk-ai/rtk code-simplifier --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/code-simplifier .claude/skills/code-simplifier && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
code-simplifier
GitHub stars
83k
Token cost
~1.1k tokens
SKILL.md length
149 words
Files
1
Skills in repo
7
Repo updated
First seen
Licence
Apache-2.0

At a glance

Reviews RTK's Rust code for over-engineering and verbose patterns, applying idioms like iterator chains and early returns while protecting a specific list of constraints from being simplified away.

  • Works in 7 steps: Iterator chains over manual loops → String building → Option/Result chaining → …
  • Cleaning up verbose Rust code in the RTK codebase
  • SKILL.md covers Constraints (never simplify…, Simplification Patterns, RTK-Specific Checks and What NOT to Simplify
  • Calls cargo

What it does

The skill lists patterns to apply: iterator chains instead of manual accumulation loops, cleaner string building, Option and Result chaining instead of nested match expressions, struct destructuring to avoid repeated field access, early returns instead of deep nesting, removing redundant clones, and if let in place of a full match for a single variant.

It also names constraints that must never be simplified away even though they look like candidates: a LazyLock regex that cannot be moved inside a function, mandatory .context() calls on every question-mark operator, a fallback-to-raw-command branch that looks like dead code but is a safety net, exit code propagation that must not collapse into Ok(()), and test modules marked with #[cfg(test)]. After simplifying, the skill runs cargo fmt, cargo clippy and cargo test to check for regressions.

When your agent uses it

  • Cleaning up verbose Rust code in the RTK codebase
  • Replacing a nested match or manual loop with an idiomatic Rust pattern
  • Checking whether a piece of RTK code is safe to simplify

Example prompts

  • “Simplify this nested match in the RTK output formatter without changing its behavior.”
  • “Review src/commands/run.rs for unnecessary clones and verbose loops.”
  • “Check whether this LazyLock regex can be moved inside the function.”

Requirements

  • Rust with cargo, clippy and rustfmt
  • Pre-approved tools (allowed-tools): Read, Grep, Glob, Edit

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Iterator chains over manual loops
  2. String building
  3. Option/Result chaining
  4. Struct destructuring
  5. Early returns over nesting
  6. Avoid redundant clones
  7. Use if let for single-variant match

What it can do on your machine

Read from SKILL.md and the folder at commit 8533612. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Grep
    • Glob
    • Edit

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • cargo

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

RTK Rust Code Simplifier loads about 1.1k tokens when it runs. Until then it costs about 46 tokens; SKILL.md has 149 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~46
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rtk-ai/rtk at commit 8533612, republished under its Apache-2.0 licence (© rtk-ai). 149 words, ~1,072 tokens.

Download SKILL.mdSave it as .claude/skills/code-simplifier/SKILL.md (or your agent's skills folder).
name
code-simplifier
description
Review RTK Rust code for idiomatic simplification. Detects over-engineering, unnecessary allocations, verbose patterns. Applies Rust idioms without changing behavior.
allowed-tools
Read, Grep, Glob, Edit
triggers
simplify, too verbose, over-engineered, refactor this, make this idiomatic
effort
low
tags
rust, simplify, refactor, idioms, rtk

RTK Code Simplifier

Review and simplify Rust code in RTK while respecting the project's constraints.

Constraints (never simplify away)

  • LazyLock regex — cannot be moved inside functions even if "simpler"
  • .context() on every ? — verbose but mandatory
  • Fallback to raw command — never remove even if it looks like dead code
  • Exit code propagation — never simplify to Ok(())
  • #[cfg(test)] mod tests — never remove test modules

Simplification Patterns

1. Iterator chains over manual loops
rust
// ❌ Verbose
let mut result = Vec::new();
for line in input.lines() {
    let trimmed = line.trim();
    if !trimmed.is_empty() && trimmed.starts_with("error") {
        result.push(trimmed.to_string());
    }
}

// ✅ Idiomatic
let result: Vec<String> = input.lines()
    .map(|l| l.trim())
    .filter(|l| !l.is_empty() && l.starts_with("error"))
    .map(str::to_string)
    .collect();
2. String building
rust
// ❌ Verbose push loop
let mut out = String::new();
for (i, line) in lines.iter().enumerate() {
    out.push_str(line);
    if i < lines.len() - 1 {
        out.push('\n');
    }
}

// ✅ join
let out = lines.join("\n");
3. Option/Result chaining
rust
// ❌ Nested match
let result = match maybe_value {
    Some(v) => match transform(v) {
        Ok(r) => r,
        Err(_) => default,
    },
    None => default,
};

// ✅ Chained
let result = maybe_value
    .and_then(|v| transform(v).ok())
    .unwrap_or(default);
4. Struct destructuring
rust
// ❌ Repeated field access
fn process(args: &MyArgs) -> String {
    format!("{} {}", args.command, args.subcommand)
}

// ✅ Destructure
fn process(&MyArgs { ref command, ref subcommand, .. }: &MyArgs) -> String {
    format!("{} {}", command, subcommand)
}
5. Early returns over nesting
rust
// ❌ Deeply nested
fn filter(input: &str) -> Option<String> {
    if !input.is_empty() {
        if let Some(line) = input.lines().next() {
            if line.starts_with("error") {
                return Some(line.to_string());
            }
        }
    }
    None
}

// ✅ Early return
fn filter(input: &str) -> Option<String> {
    if input.is_empty() { return None; }
    let line = input.lines().next()?;
    if !line.starts_with("error") { return None; }
    Some(line.to_string())
}
6. Avoid redundant clones
rust
// ❌ Unnecessary clone
fn filter_output(input: &str) -> String {
    let s = input.to_string();  // Pointless clone
    s.lines().filter(|l| !l.is_empty()).collect::<Vec<_>>().join("\n")
}

// ✅ Work with &str
fn filter_output(input: &str) -> String {
    input.lines().filter(|l| !l.is_empty()).collect::<Vec<_>>().join("\n")
}
7. Use if let for single-variant match
rust
// ❌ Full match for one variant
match output {
    Ok(s) => process(&s),
    Err(_) => {},
}

// ✅ if let (but still handle errors in RTK — don't silently drop)
if let Ok(s) = output {
    process(&s);
}
// Note: in RTK filters, always handle Err with eprintln! + fallback

RTK-Specific Checks

Run these after simplification:

bash
# Verify no regressions
cargo fmt --all && cargo clippy --all-targets && cargo test

# Verify no new regex in functions
grep -n "Regex::new" src/<file>.rs
# Fixed, reused patterns should be in `LazyLock<Regex>` statics

# Verify no new unwrap in production
grep -n "\.unwrap()" src/<file>.rs
# Should only appear inside #[cfg(test)] blocks

What NOT to Simplify

  • static RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(...).unwrap()); — the .unwrap() here is acceptable, it's init-time
  • .context("description")? chains — verbose but required
  • The fallback match arm Err(e) => { eprintln!(...); raw_output } — looks redundant but is the safety net
  • std::process::exit(code) at end of run() — looks like it could be Ok(())but it isn't

© rtk-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/code-simplifier of rtk-ai/rtk.

Open the folder on GitHubat commit 8533612

Compare with similar skills

RTK Rust Code Simplifier next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

RTK Rust Code Simplifier compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
RTK Rust Code Simplifier this skillrtk-ai/rtk83k—~1.1kAutomated safety check: PassApache-2.0
Code RefinerMathews-Tom/armory328—~3.1kAutomated safety check: PassMIT
Migrate Core Code to Submodulestinyhumansai/openhuman42k—~2.6kAutomated safety check: PassGPL-3.0
PonytailDavidObando/gsharp5658 repos~1.7kAutomated safety check: PassMIT
Rust Best Practicesfarm-fe/farm5.6k3 repos~1.1kAutomated safety check: PassMIT
Ponytail Lazy Developer ModeDietrichGebert/ponytail158k—~871Automated safety check: PassMIT

Similar skills

  • Code Refiner

    Mathews-Tom/armory

    Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust.

    328 GitHub stars~3.1k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Migrate Core Code to Submodules

    tinyhumansai/openhuman

    Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.

    42k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Ponytail

    DavidObando/gsharp

    Forces the laziest solution that actually works, simplest, shortest, most minimal.

    565 GitHub starsUsed in 8 repos~1.7k tokens
    DevelopmentAuto-check passed
  • Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook.

    5.6k GitHub starsUsed in 3 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Ponytail Lazy Developer Mode

    DietrichGebert/ponytail

    Makes the agent pick the laziest solution that works: skip unneeded work, reuse what exists, prefer the standard library and platform features, and keep diffs small.

    158k GitHub stars~871 tokensUpdated today
    DevelopmentAuto-check passed
  • Finds and implements evidence-backed simplifications in the ego-lite repository, such as dead code, duplicated state and speculative abstractions, without hiding behavior changes.

    17k GitHub stars~1.2k tokensUpdated 15 days ago
    DevelopmentAuto-check passed

More from rtk-ai/rtk

  • Enforces red-green-refactor for Rust work, with idiomatic test patterns, a naming convention and a pre-commit gate of cargo fmt, clippy and test.

    83k GitHub stars~753 tokensUpdated yesterday
    Auto-check: notes
  • Describes seven Rust design patterns for the RTK CLI filter modules, with when to use each, RTK examples, and notes on when a pattern is overkill.

    83k GitHub stars~1.9k tokensUpdated yesterday
    Auto-check passed
  • Enforces red-green-refactor for new RTK output filters in Rust, using real captured fixtures, snapshot tests with insta and token-savings assertions.

    83k GitHub stars~1.9k tokensUpdated yesterday
    Auto-check: notes
  • Audits open GitHub issues, categorizes them, flags duplicates and linked PRs in three phases, with optional deep analysis and comments posted only after validation.

    83k GitHub stars~3k tokensUpdated yesterday
    Auto-check: notes
  • PR Triage

    rtk-ai/rtk

    Audits a repository's open pull requests, deep-reviews chosen ones and drafts review comments that are only posted after you approve them.

    83k GitHub stars~2.5k tokensUpdated yesterday
    Auto-check: notes
  • Runs issue triage and PR triage in parallel, then cross-analyzes the results to flag duplicate coverage, security gaps, P0 issues with no PR, and PR conflicts.

    83k GitHub stars~1.6k tokensUpdated yesterday
    Auto-check: notes

Works with

Categories

Questions about RTK Rust Code Simplifier

What does RTK Rust Code Simplifier do?

Reviews RTK's Rust code for over-engineering and verbose patterns, applying idioms like iterator chains and early returns while protecting a specific list of constraints from being simplified away. The skill lists patterns to apply: iterator chains instead of manual accumulation loops, cleaner string building, Option and Result chaining instead of nested match expressions, struct destructuring to avoid repeated field access, early returns instead of deep nesting, removing redundant clones, and if let in place of a full match for a single variant.

When should I use RTK Rust Code Simplifier?

RTK Rust Code Simplifier fits situations like: cleaning up verbose Rust code in the RTK codebase; replacing a nested match or manual loop with an idiomatic Rust pattern; checking whether a piece of RTK code is safe to simplify.

How do I install RTK Rust Code Simplifier in Claude Code?

Run `npx skills add rtk-ai/rtk --skill code-simplifier -a claude-code`. Or copy the skill folder (.claude/skills/code-simplifier in rtk-ai/rtk) into .claude/skills/code-simplifier in your project. Claude Code loads it when a task matches its description.

How do I install RTK Rust Code Simplifier in Codex?

Run `npx skills add rtk-ai/rtk --skill code-simplifier -a codex`. Or copy the skill folder (.claude/skills/code-simplifier in rtk-ai/rtk) into .agents/skills/code-simplifier in your project. Codex loads it when a task matches its description.

Can I use RTK Rust Code Simplifier in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rtk-ai/rtk --skill code-simplifier -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-simplifier, .gemini/skills/code-simplifier, .github/skills/code-simplifier and .opencode/skills/code-simplifier in your project.

What does RTK Rust Code Simplifier need to run?

Going by SKILL.md and its folder, RTK Rust Code Simplifier needs the command-line tools its instructions call (cargo). Our summary lists: Rust with cargo, clippy and rustfmt. Its frontmatter pre-approves these tools: Read, Grep, Glob, Edit.

Does RTK Rust Code Simplifier access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is RTK Rust Code Simplifier safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does RTK Rust Code Simplifier use?

RTK Rust Code Simplifier is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does RTK Rust Code Simplifier use?

About 1.1k tokens (SKILL.md is roughly 4.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to RTK Rust Code Simplifier?

Skills that share tags, products or a category with RTK Rust Code Simplifier: Code Refiner (Mathews-Tom/armory, 328 stars), Migrate Core Code to Submodules (tinyhumansai/openhuman, 42k stars), Ponytail (DavidObando/gsharp, 565 stars) and Rust Best Practices (farm-fe/farm, 5.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains RTK Rust Code Simplifier?

rtk-ai (a GitHub organization) maintains it in rtk-ai/rtk, which has 82,651 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 7, 2026.

Source: rtk-ai/rtk on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.