跳到正文
Skillpedia
通用编程40k · #7395

refactor-plan

它能做什么

这个代理会在修改多个代码文件之前,先制定一份详细的计划。它会分析现有代码,找出受影响的文件,并建议一个安全的修改顺序。

适用场景

  • ✓当你想规划一次大型代码修改时。
  • ✓在同时修改多个文件之前。
  • ✓为了确保代码修改安全且有条理。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/refactor-plan/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/refactor-plan/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想重构登录系统,请为我制定一份计划。”

每周 5 个新技能,1 分钟读完。

工作原理

它会先了解代码的工作原理,然后按安全的步骤规划修改,例如类型、实现、测试和清理,并包含验证步骤,以及出错时的回退步骤。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Refactor Plan

Create a detailed plan before making any code changes.

Instructions

  1. Do not edit files while preparing the plan.
  2. Search the codebase to understand the current state. Read enough implementation, tests, configuration, and docs to make the plan specific to the repository.
  3. Identify affected files, ownership boundaries, dependencies, and likely hidden coupling.
  4. Plan changes in a safe sequence. Prefer contracts and types first, then implementations, then callers, then tests, then cleanup.
  5. Include verification steps between phases and a final validation command.
  6. Include rollback or recovery steps for the riskiest phases.
  7. Output the complete plan using the format below.
  8. 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能