code-simplifier
Review RTK Rust code for idiomatic simplification. Detects over-engineering, unnecessary allocations, verbose patterns. Applies Rust idioms without changing behavior.
By rtk-ai · 1,550 installs
npx skills add rtk-ai/rtk --skill code-simplifier
Source repository · Upstream listing
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
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
RTK Specific Checks
Run these after simplification:
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