patch-edit
它能做什么
这个工具可以帮你一次只对编程代码做一个小改动。它不会一次性改动所有内容,而是每次只应用一个小的修复或改进,方便人们审查和理解每一处变更。
适用场景
- ✓当你需要修复代码中的一个小 bug 时。
- ✓当你要添加一个小而可测试的新功能时。
- ✓想改进代码的某个特定部分,又不影响其他部分时。
技能链接
https://github.com/nexu-io/open-design/blob/main/plugins/_official/atoms/patch-edit/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想把重构计划的下一步应用到 'utils.js' 文件上。”
每周 5 个新技能,1 分钟读完。
工作原理
工具会接收一个包含多个步骤的计划,并逐个应用这些步骤。每完成一步,它都会记录做了什么,让你看到进度,并决定是否批准下一步的改动。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Patch edit
Spec §20.3 / §21.3.2: code-migration / tune-collab cannot ship a trustworthy diff when the agent rewrites whole files in one pass — the reviewer can't audit the change. This atom enforces "one step per turn, smallest possible localised edit".
Inputs
plan/steps.jsonfromrewrite-plan.- The current value of
iterations(the daemon's per-stage counter). code/index.jsonfor the file's known imports + neighbours.
Output
The atom mutates files inside the project cwd via the file-edit tool.
After every iteration, it writes a per-step receipt:
project-cwd/
└── plan/
├── steps.json (status updated: 'pending' → 'completed' | 'skipped')
└── receipts/
└── step-<id>.json # { files: ['...'], diffSummary, rationale, completedAt }
Convergence
The atom completes when every step in plan/steps.json is in a
terminal state (completed / skipped) OR iterations >= OD_MAX_DEVLOOP_ITERATIONS. Use:
{
"id": "patch-edit-loop",
"atoms": ["patch-edit"],
"repeat": true,
"until": "plan.steps.terminal === plan.steps.total || iterations >= 8"
}
Anti-patterns the prompt fragment forbids
- Rewriting an entire file when the rewrite-plan step is localised.
- Touching a file outside the step's
files[]. - Touching a
shell-tier file when the step'sriskis not'high'or the user hasn't confirmed. - Skipping a step without a receipt + a rationale string.
Status
Implemented by the daemon runner in
apps/daemon/src/plugins/atoms/patch-edit.ts. It validates step ownership and
risk, applies unified diffs with atomic writes, and records receipts and
progress.
常见问题
为什么不一次把整个文件都改掉?
一次性改动整个文件,会让审查变得困难,也不容易发现错误。每次只改一小部分,过程更安全,也更便于检查。
一个步骤应用之后会发生什么?
工具会保存一份详细的变更记录,包括修改了哪些文件以及原因。这样就形成了一份修改历史。
我可以跳过某个步骤吗?
可以,但你需要记录跳过的原因。这样能确保所有决定都有据可查。
详情
作者的原始描述
Apply one rewrite-plan step at a time as small reviewable file edits, never rewriting whole files when a localised change suffices.
repo: nexu-io/open-design
热度
- GitHub 星标
- 101k
- 排名
- #987
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/15
评论
- …