patch-approval

A review step for code changes produced as a patch or diff, meaning a text description of file changes. Codex produces the patch in an isolated copy, Claude reviews it, and the user confirms before it is written.

In plain words
What is it for?
Safely review and approve patches that may contain issues such as injection attacks, exposed secrets, unsafe file paths, or unrelated edits.
Why use it?
It adds a check for security problems, incorrect behavior, unintended side effects, and changes outside the requested scope before they reach the working files.

Skill for Claude CodeCodex

Part of the compound-engineering plugin — 40 skills, 4 commands, 2 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/jerrylalala/compound-engineering/patch-approval
Any agent
npx skills add Jerrylalala/compound-engineering --skill patch-approval
Clone the repo
git clone --depth 1 https://github.com/Jerrylalala/compound-engineering

Made for: Claude Code, Codex.

Or install compound-engineering, the plugin that ships this one along with the rest of its 40 skills, 4 commands, 2 hooks.

Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,131 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00057 $0.01131
Opus 5 $0.00028 $0.00566
Sonnet 5 $0.00011 $0.00226
Haiku 4.5 $0.00006 $0.00113

Measured 3d ago against content hash 68a0cd7f05ee, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

patch-approval scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf "$ISOLATED_DIR"
plugins/compound-engineering/skills-custom/patch-approval/SKILL.md · 137 lines

How it starts

The opening of the file, as written. The whole thing — 137 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Patch Approval — 咨询版

Codex 评分:4/10(完整版不可行),咨询版可行。

场景:Codex 生成 patch → Claude 审批 → 用户确认 → 写入。 这比「直接接受 Codex 输出」多一层安全保障。


触发条件

当满足以下条件时激活 Patch Approval:

  1. 使用了 Codex 执行器(Codex-first Executor 路由到 Codex)
  2. Codex 返回的是 patch/diff 格式(不是直接文件修改)
  3. 任务不是纯分析(分析任务不需要审批)

审批流程

Step 0: 在隔离目录执行 Codex

注意:Codex CLI 不支持 --dry-run 参数(已验证 v0.118+)。 唯一安全方案是在临时隔离副本中执行,再用 git diff 捕获 patch。

# 1. 在临时目录创建仓库副本(跨平台安全路径)
ISOLATED_DIR=$(mktemp -d)
git clone . "$ISOLATED_DIR" --local --quiet

# 2. 在隔离目录执行 Codex(真实写入,不影响工作区)
(cd "$ISOLATED_DIR" && codex "$TASK_PROMPT")

# 3. 用 git diff 捕获改动作为 patch
git -C "$ISOLATED_DIR" diff HEAD > "${TMPDIR:-/tmp}/codex-patch.diff"

# 4. 清理隔离目录
rm -rf "$ISOLATED_DIR"

Step 1: Codex 生成 Patch

运行 Step 0 的隔离方案,将 patch 输出到 ${TMPDIR:-/tmp}/codex-patch.diff

Step 2: Claude 审批

Claude 读取 patch 内容,按以下维度评估:

## Patch 审批检查清单

**安全维度**(Blocking):
- [ ] 无 SQL 注入 / XSS / 命令注入
- [ ] 无硬编码密钥或敏感信息
- [ ] 无未授权的文件路径操作

**正确性维度**(Analytical):
- [ ] 改动符合原始任务意图
- [ ] 没有意外的副作用
- [ ] 变量名/函数签名合理

**范围维度**(Advisory):
- [ ] 改动范围在预期之内(没有多改)
- [ ] 没有删除不应删除的代码

Step 3: 审批决策

决策 条件 行动
通过 所有 Blocking 检查通过 应用 patch
修改后通过 Analytical 有小问题 Claude 修正 patch 后应用
拒绝 Blocking 检查失败 拒绝 patch,回退到 Claude 执行

Step 4: 用户确认(可选)

对于 gated_auto 类型的改动,展示 patch 摘要并询问确认:

📋 Codex Patch 摘要(已通过 Claude 审批):

  修改 3 个文件:
  + app/models/user.rb  (2 行新增)
  ~ app/controllers/users_controller.rb  (5 行修改)
  - app/views/users/index.html.erb  (1 行删除)

  审批结论:通过(无 Blocking 问题)
  主要改动:[改动描述]

  应用此 patch?(y/n/查看详情)

审批记录

在 state.md 中记录审批结果(如有 Task Bundle):

patch_approval:
  patch_source: "codex"
  approved_at: "2026-04-08T10:00:00+08:00"
  verdict: "pass"  # pass / modified_pass / rejected
  blocking_issues: []
  modifications: []  # Claude 修正的内容

限制说明(咨询版)

限制 说明
不支持自动应用(完整版) 每次都需要用户确认(安全考虑)
不支持复杂冲突解决 Codex patch 有冲突时回退到 Claude 执行
隔离目录方案依赖 git clone 工作区必须是 git 仓库,且本地 clone 可用

Read the full file on GitHub · 137 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 137 lines · 57 tokens per session scan C 68a0cd7f05ee

Subscribe to this mod's changes

patch-approval is a skill published in the GitHub repository Jerrylalala/compound-engineering (5 stars, last pushed 3mo ago), licensed MIT. It adds 57 tokens to every session and 1,131 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens