一键导入
codex-patch-editing
Use when editing files in Codex and the agent needs reliable apply_patch syntax
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when editing files in Codex and the agent needs reliable apply_patch syntax
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Inspect language and package-manager directories that are safely rebuildable and generate or apply Codex sandbox_workspace_write.writable_roots entries. Use when configuring Codex writable roots for Gradle, Maven, SwiftPM, Go, Cargo, NuGet, Python, Node, Deno, Kotlin/JVM compile daemon, Kotlin Native, vcpkg, or similar rebuildable toolchain paths.
On macOS, pass --disable-sandbox to swift build/test/package when running inside Codex sandbox.
| name | codex-patch-editing |
| description | Use when editing files in Codex and the agent needs reliable apply_patch syntax |
使用 apply_patch 工具前先加载本 skill。也适用于为其他 agent 生成 patch 指令、或修复格式错误的 patch。
apply_patch 工具编辑文件。apply_patch 是 FREEFORM 工具,输入是纯 patch 文本,不是 JSON。apply_patch。apply_patch 输入包 ```patch 等 Markdown 代码围栏;本文档中的代码块仅为展示,实际调用时不加。cat > file、echo > file、sed -i、perl -pi 或 Python 重写脚本编辑文件。每个 patch 以 *** Begin Patch 开头,*** End Patch 结尾。
更新文件:
*** Begin Patch
*** Update File: path/to/file
@@
-old line
+new line
*** End Patch
新增文件:
文件路径使用仓库相对路径。
*** Begin Patch
*** Add File: path/to/file
+content line
+another content line
*** End Patch
删除文件:
*** Begin Patch
*** Delete File: path/to/file
*** End Patch
| 前缀 | 含义 |
|---|---|
| 空格 | 上下文行(保留不变) |
- | 删除该行 |
+ | 新增该行 |
新增文件时每一行内容(包括空行)都以 + 开头。
文件路径始终使用仓库相对路径,除非上下文明确要求其他方式。
如果 patch 失败或有风险:
*** Begin Patch 开头*** End Patch 结尾+