code-simplifier skill
Review RTK Rust code for idiomatic simplification. Detects over-engineering, unnecessary allocations, verbose patterns. Applies Rust idioms without changing behavior.
A100/100content scan
Is the code-simplifier skill safe?
Clean: nothing in its files matched our rules. We read 1 file in the folder on 2026-11-10.
No findings.
Install the code-simplifier skill
A skill is a folder. Copy it into your agent's skills folder and the agent loads it when the task matches its description.
git clone --depth 1 https://github.com/rtk-ai/rtk.git /tmp/rtk mkdir -p ~/.claude/skills cp -r /tmp/rtk/.claude/skills/code-simplifier ~/.claude/skills/code-simplifier
available in every project
In the Claude apps, zip the folder and upload it from the Skills settings. The folder on GitHub
The instructions your agent would load
SKILL.md as published, without the frontmatter. Read it on GitHub
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");3. Option/Result chaining
// ❌ 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
// ❌ 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
// ❌ 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
// ❌ 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
// ❌ 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! + fallbackRTK-Specific Checks
Run these after simplification:
# 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)] blocksWhat NOT to Simplify
- static RE: LazyLock = 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
More skills from rtk-ai/rtk
- Adesign-patternsRust design patterns for RTK. Newtype, Builder, RAII, Trait Objects, State Machine. Applied to CLI filter modules. Use when designing new modules or refactoring existing ones.
- Aissue-triageIssue triage: audit open issues, categorize, detect duplicates, cross-ref PRs, risk assessment, post comments. Args: "all" for deep analysis of all, issue numbers to focus (e.g. "42 57"), "en"/"fr" for language, no arg = audit only in French.
- AperformanceCLI performance optimization - startup time, memory usage, token savings benchmarking
- Apr-reviewBatch review des PRs RTK par ordre de complexité croissante (XS → S → M → L). Pour chaque PR : vérifie l'état (conflits, CLA, reviews), lit le diff complet, analyse le code en contexte, présente un résumé avec lien + taille + recommandation. Attend validation explicite avant tout merge. Poste des commentaires boldguy-adapt sur les PRs bloquées (conflit, CLA, CHANGES_REQUESTED). Args: "triage" pour lancer un triage complet avant la review. "from:<num>" pour reprendre à partir d'un numéro de PR spécifique.
- Apr-triagePR triage: audit open PRs, deep review selected ones, draft and post review comments. Args: "all" to review all, PR numbers to focus (e.g. "42 57"), "en"/"fr" for language, no arg = audit only in French.
- Arepo-recapGenerate a comprehensive repo recap (PRs, issues, releases) for sharing with team. Pass "en" or "fr" as argument for language (default fr).
- Drtk-tddEnforces TDD (Red-Green-Refactor) for Rust development. Auto-triggers on implementation, testing, refactoring, and bug fixing tasks. Provides Rust-idiomatic testing patterns with anyhow/thiserror, cfg(test), and Arrange-Act-Assert workflow.
- Artk-triageTriage complet RTK : exécute issue-triage + pr-triage en parallèle, puis croise les données pour détecter doubles couvertures, trous sécurité, P0 sans PR, et conflits internes. Sauvegarde dans claudedocs/RTK-YYYY-MM-DD.md. Args: "en"/"fr" pour la langue (défaut: fr), "save" pour forcer la sauvegarde.
- Fsecurity-guardianCLI security expert for RTK - command injection, shell escaping, hook security
- AshipBuild, commit, push & version bump workflow - automates the complete release cycle
- Atdd-rustTDD workflow for RTK filter development. Red-Green-Refactor with Rust idioms. Real fixtures, token savings assertions, snapshot tests with insta. Auto-triggers on new filter implementation.