with one click
refactor
Code quality analysis and refactoring with validation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Code quality analysis and refactoring with validation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | refactor |
| description | Code quality analysis and refactoring with validation |
| user-invocable | true |
| allowed-tools | Read, Grep, Glob, Bash(cargo check*), Bash(cargo clippy*), Bash(cargo test*), Bash(cargo fmt*), Bash(git status*), Bash(git diff*), Bash(git stash*), Bash(wc *), Edit, Write, Task |
Code quality analysis and incremental refactoring with continuous validation.
Arguments (optional):
/refactor crates/app — limit scopecargo clippy --workspace --all-targets 2>&1 — warnings countcargo test --workspace 2>&1 — baseline: all tests passing?Analyze code across 8 dimensions. For large scope, use parallel Task agents (subagent_type=Explore) — one per category or group of categories.
Analysis checklist:
Architecture (SOLID)
Legitimate exceptions to "1 file = 1 type": Error+ErrorKind pairs, Builder+Target, small private helpers (<30 LOC), related DTO families (Request/Response), typestate marker types, newtype wrapper collections.
Module coupling / cohesion
pub API — types/functions public without necessityDuplication (DRY)
Dead code
use, functions, types, constantsPerformance
.clone() / .to_string() / .to_owned() where a reference sufficesError boundaries
unwrap() / expect() in production code — replace with ? or explicit handling.map_err(|_| ...) without information)Security
Style and idioms
#[must_use] on pure functionsOutput to terminal (do not create files):
## Analysis results
| Category | Found | Critical |
|----------------|-------|----------|
| Architecture | N | N |
| Coupling | N | N |
| Duplication | N | N |
| Dead code | N | N |
| Performance | N | N |
| Errors | N | N |
| Security | N | N |
| Style | N | N |
Baseline: X clippy warnings, Y total LOC
### Top issues (by impact)
1. ...
2. ...
Ask the user via AskUserQuestion:
For each fix:
cargo check — compiles?cargo test --workspaceOrder: simple and safe first (dead code, style), then structural.
On compilation/test failure — revert the change and move to next.
cargo fmt --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
Compare with baseline: warnings removed, LOC deleted/changed.