RTK Code Simplifier
Review and simplify Rust code in RTK while respecting the project's constraints.
Constraints (never simplify away)
LazyLockregex — 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 beOk(())but it isn't


