refactoring
Use when code needs behavior-preserving restructuring to improve clarity, reduce duplication, or enable safer changes without altering outputs
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when code needs behavior-preserving restructuring to improve clarity, reduce duplication, or enable safer changes without altering outputs
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use when approach is chosen and need a detailed implementation plan before coding. After researching, before implementer
Use when idea is vague, multiple interpretations exist, scope is undefined, or stakeholders need alignment before technical work begins
Use when requirements are fuzzy, multiple technical approaches exist, or change affects architecture, API, data, or security
Use when an approved implementation blueprint exists and you are about to start implementation
Use when need to create reusable technique, pattern, or reference guide for AI agents
Use when need to create specialized subagent for recurring tasks, domain-specific work, or pipeline automation
| name | refactoring |
| description | Use when code needs behavior-preserving restructuring to improve clarity, reduce duplication, or enable safer changes without altering outputs |
Use when behavior must remain the same while improving structure, readability, or testability.
Prerequisites: Tests exist or you can add characterization tests to lock behavior.
Skip if: you are changing behavior or adding features, there is no safety net and you cannot add characterization tests, or the issue is purely formatting or linting.
| Smell | Refactor |
|---|---|
| Long function | Extract function |
| Magic value | Extract constant |
| Unclear name | Rename for intent |
| Deep nesting | Guard clauses or early return |
| God class | Split responsibilities |
| Duplication | Extract shared function |
Pipeline: refactoring → code-review
Before refactoring:
After refactoring: