一键导入
refactor
Use when improving existing code structure without changing behavior, after tests are green
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when improving existing code structure without changing behavior, after tests are green
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when reviewing a spec or task graph for completeness before implementation
Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, logging in, or automating browser actions
Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, logging in, or automating browser actions
Use when decomposing a spec, design, or feature description into a task dependency graph with self-evaluating acceptance criteria
Use when doing creative product, feature, component, functionality, or behavior design work
Use when infrastructure or features are built but before declaring done -- verifies work is wired into the system and actively used
| name | refactor |
| description | Use when improving existing code structure without changing behavior, after tests are green |
Safe refactoring with a green test baseline. No behavior changes — only structural improvements.
NO REFACTORING WITHOUT GREEN TESTS FIRST
If tests aren't passing before you start, you can't distinguish refactoring breakage from pre-existing issues.
# Go
go test ./...
# Python
uv run pytest
All tests must pass before any changes.
Identify:
Each change should be:
For each step:
After all steps:
When refactoring, prefer these transformations:
| From | To |
|---|---|
| Mutable state | Immutable values |
| Side effects in logic | Pure core, impure edges |
| Imperative loops | map/filter/reduce |
| Class with methods | Functions + data |
| Shared mutable state | Passed parameters |
| Excuse | Reality |
|---|---|
| "Tests are mostly passing" | Mostly ≠ all. Fix first. |
| "This small change can't break anything" | Run tests. Trust evidence, not intuition. |
| "I'll add the feature while refactoring" | Separate concerns. Refactor then feature. |
| "Testing each step is slow" | Slower than debugging a broken refactor. |