Skip to content
rtk-ai avatar

Code Simplifier

Rust simplification guide for RTK that removes verbosity while preserving the project's required constraints.

CCM score
69 of 100
skills.sh installs
2.3K
GitHub stars
88.2K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers seven idiom patterns: iterator chains, join string building, Option/Result chaining, struct destructuring, early returns, redundant clone removal, and if let
  • Lists project constraints never to simplify away, including LazyLock regexes, .context() on ?, raw-command fallbacks, and exit code propagation
  • Provides post-change checks: cargo fmt, cargo clippy, and cargo test, plus greps for Regex::new and production .unwrap() calls
  • Designed for RTK maintainers who want idiomatic Rust cleanup without changing command behavior

Install

$ npx -y skills add rtk-ai/rtk --skill code-simplifier -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

// ❌ 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

// ❌ 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");

Details

Repository
github.com/rtk-ai/rtk
Categories
Rust, Code Review & Quality
First seen
Jun 3, 2026

Questions

What does the code-simplifier skill do for RTK Rust code?

It reviews RTK Rust code for idiomatic simplification, detecting over-engineering, unnecessary allocations and verbose patterns. It applies Rust idioms such as iterator chains, early returns and avoiding redundant clones without changing behavior.

How do I install the code-simplifier skill?

Run npx -y skills add rtk-ai/rtk --skill code-simplifier -y in your project. The agent can then simplify Rust code when asked to simplify, refactor or make code idiomatic.

Which constraints does the code-simplifier skill keep in place?

It never removes LazyLock regex statics, the context calls on every question-mark operator, the fallback to raw command output, exit code propagation, or test modules. These parts look redundant but act as safety nets in RTK.

Where does code-simplifier rank in the Rust category?

It ranks in the top 50 on the Rust category page on Claude Marketplaces. Other skills in that category include fix-errors, rust-best-practices, rust-async-patterns, rust-testing and rust-patterns.

More from rtk-ai/rtk

All 7

Similar to Code Simplifier

More Rust