一键导入
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.