一键导入
refactoring-patterns
Safe refactoring pattern catalog: code smell taxonomy, transformation techniques, behavior preservation strategies, and metrics tracking.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Safe refactoring pattern catalog: code smell taxonomy, transformation techniques, behavior preservation strategies, and metrics tracking.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Session bootstrap + workflows for Pathfinder semantic navigation tools. Covers: discovery protocol, tool chaining patterns (explore, impact, audit, debug), search optimization, LSP degraded mode, and error recovery.
Playwright browser automation via MCP. Covers E2E testing, UI review, web scraping, screenshot capture, and general browser interaction. MCP-first — CLI is fallback only.
Safe command execution: input sanitization, timeout handling, output capture, error propagation. For spawning processes, shell commands, system calls.
Git conventions: conventional commits, branch naming, PR hygiene, release tagging.
Structured incident workflow: severity classification, triage, diagnosis, mitigation, postmortem, and prevention. Template-driven with blameless review.
Constructs, validates, and traverses a Directed Acyclic Graph (DAG) from scope cards for safe level-based parallel dispatch. Determines execution order via topological sort. Detects cycles and invalid dependencies.
| name | refactoring-patterns |
| description | Safe refactoring pattern catalog: code smell taxonomy, transformation techniques, behavior preservation strategies, and metrics tracking. |
Catalog of safe, incremental code transformation patterns.
/refactor command| Smell | Detection | Refactoring |
|---|---|---|
| Long method | >30 lines | Extract method |
| Large class | >300 lines or >5 responsibilities | Extract class |
| Long parameter list | >4 parameters | Introduce parameter object |
| Feature envy | Method uses another class's data more than its own | Move method |
| Data clumps | Same fields appear together repeatedly | Extract class |
| Primitive obsession | Primitives where domain types belong | Introduce value object |
| Smell | Detection | Refactoring |
|---|---|---|
| God class | One class knows/does too much | Extract classes by responsibility |
| Circular dependency | A → B → A | Introduce interface, dependency inversion |
| Inappropriate intimacy | Classes access each other's internals | Move method, extract interface |
| Shotgun surgery | One change requires touching many files | Move related code together |
Before refactoring, write tests that capture current behavior:
Run existing code → record outputs → assert in tests → now refactor safely
Gradually replace old implementation with new:
Old Code ← requests
↓ gradually route to
New Code ← requests (eventually all traffic)
Old Code ← delete
Run old and new implementations simultaneously, compare outputs:
Request → Old Implementation → Response (returned to user)
→ New Implementation → Response (logged, compared)
| Metric | Tool | Target |
|---|---|---|
| Cyclomatic complexity | SonarQube, radon, gocyclo | ≤ 10 per function |
| Cognitive complexity | SonarQube | ≤ 15 per function |
| Coupling (afferent/efferent) | JDepend, NDepend | Decreasing trend |
| Duplication | SonarQube, jscpd | < 3% |
| Test coverage | lcov, coverage.py | ≥ pre-refactoring |