ワンクリックで
refactor
Code quality analysis and refactoring with validation
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Code quality analysis and refactoring with validation
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| 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.