← ClaudeAtlas

code-simplifierlisted

Review RTK Rust code for idiomatic simplification. Detects over-engineering, unnecessary allocations, verbose patterns. Applies Rust idioms without changing behavior.
naviocean/sass-kit · ★ 1 · AI & Automation · score 68
Install: claude install-skill naviocean/sass-kit
# 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. Struc