refactor-plan
它能做什么
这个代理会在修改多个代码文件之前,先制定一份详细的计划。它会分析现有代码,找出受影响的文件,并建议一个安全的修改顺序。
适用场景
- ✓当你想规划一次大型代码修改时。
- ✓在同时修改多个文件之前。
- ✓为了确保代码修改安全且有条理。
技能链接
https://github.com/github/awesome-copilot/blob/main/skills/refactor-plan/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想重构登录系统,请为我制定一份计划。”
每周 5 个新技能,1 分钟读完。
工作原理
它会先了解代码的工作原理,然后按安全的步骤规划修改,例如类型、实现、测试和清理,并包含验证步骤,以及出错时的回退步骤。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Refactor Plan
Create a detailed plan before making any code changes.
Instructions
- Do not edit files while preparing the plan.
- Search the codebase to understand the current state. Read enough implementation, tests, configuration, and docs to make the plan specific to the repository.
- Identify affected files, ownership boundaries, dependencies, and likely hidden coupling.
- Plan changes in a safe sequence. Prefer contracts and types first, then implementations, then callers, then tests, then cleanup.
- Include verification steps between phases and a final validation command.
- Include rollback or recovery steps for the riskiest phases.
- Output the complete plan using the format below.
- Stop after the plan and ask for confirmation before implementing. If the user already asked you to implement, still produce the plan first and wait for confirmation unless they explicitly said to continue without review after the plan.
If the request is too ambiguous to plan safely, ask concise clarifying questions instead of editing files.
Output Format
## Refactor Plan: [title]
### Current State
[Brief description of how things work now]
### Target State
[Brief description of how things will work after]
### Affected Files
| File | Change Type | Dependencies |
|------|-------------|--------------|
| path | modify/create/delete | blocks X, blocked by Y |
### Execution Plan
#### Phase 1: Types and Interfaces
- [ ] Step 1.1: [action] in `file.ts`
- [ ] Verify: [how to check it worked]
#### Phase 2: Implementation
- [ ] Step 2.1: [action] in `file.ts`
- [ ] Verify: [how to check]
#### Phase 3: Tests
- [ ] Step 3.1: Update tests in `file.test.ts`
- [ ] Verify: Run `npm test`
#### Phase 4: Cleanup
- [ ] Remove deprecated code
- [ ] Update documentation
### Rollback Plan
If something fails:
1. [Step to undo]
2. [Step to undo]
### Risks
- [Potential issue and mitigation]
After the plan, ask: "Shall I proceed with Phase 1?"
常见问题
什么是“重构”?
重构是在不改变代码外部行为的前提下,重新组织现有代码,使其更容易理解和维护。
为什么要在修改代码前先制定计划?
计划有助于防止出错,确保代码的各个部分都被考虑到,让修改过程更安全、更可预测。
计划展示之后会发生什么?
代理会等你确认后,才开始按计划的第一阶段应用修改。
详情
作者的原始描述
Create a concrete plan before starting a multi-file refactor. Use when the user asks to plan, sequence, scope, or safely execute a refactor across multiple files; always investigate first, output the plan, and wait for confirmation before making code changes.
repo: github/awesome-copilot
热度
- GitHub 星标
- 40k
- 排名
- #7395
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
acquire-codebase-knowledge
40k帮你的智能体理解并编写现有代码项目的文档。它有助于新成员快速上手,或者快速了解项目架构。
acreadiness-assess
40k让你的智能体评估一个项目对 AI 的准备程度,并生成报告。它有助于了解项目在使用 AI 工具方面的准备情况。
acreadiness-generate-instructions
40k帮你的智能体根据评估结果编写 AI 工具的指令文件。它有助于改善 AI 与代码的交互方式,并弥补已发现的不足。
acreadiness-policy
40k让你的智能体协助制定或应用 AI 项目评估的政策。它有助于规范项目的评估方式,并确保合规。