Codex Plugin for Claude Code:一行指令让两个 AI 互相审代码

以前每次从 Claude Code 切到 Codex 做 review 要花两三分钟,现在一行指令 5 秒搞定。本文带你从安装到实战,涵盖基本 review、对抗性审查、任务委派,最后还有一个自动审 code 的 Review Gate 功能——等于在你的工作流里塞了一个 OpenAI 的 QA 工程师。

一、安装 Codex Plugin

首先确认 Node.js 版本在 18.18 以上:

bash
node --version

安装 Codex CLI:

bash
npm install -g @openai/codex

登入 OpenAI 帐号,免费帐号就能用:

bash
codex login

接下来在 Claude Code 里面安装插件,依序输入四条指令:

Claude Code
/plugin marketplace add openai/codex-plugin-cc
Claude Code
/plugin install codex@openai-codex
Claude Code
/reload-plugins
Claude Code
/codex:setup

跑完 /codex:setup 后看到全部绿勾勾就代表安装成功。

二、基本 Review

在 Claude Code 里 cd 到项目目录,然后跑 review:

Claude Code
/codex:review

它会扫描所有还没 commit 的改动,每个文件都帮你 review。连效能风险跟 edge case 都能抓到。

如果要比较分支差异,加上 --base flag:

Claude Code
/codex:review --base main

这样只 review 跟 main 的差异。如果你的 repo 用的是 master,把 main 换掉就好。每次开 PR 之前跑一次,reviewer 直接看逻辑就好。

算一下省多少时间:以前每次切到 Codex 来回 2 分钟,现在一行指令。一天 review 6 次,一年省超过 70 小时。

三、Adversarial Review(对抗性审查)

普通 review 不会挑战你的设计,但 adversarial review 会。同一段代码换个指令:

Claude Code
/codex:adversarial-review

简单讲就是「故意找碴的 review」。它会直接判 no-ship,不准上线。以下是实际案例中找到的三个 critical 问题:

  • Token 伪造漏洞:refresh token 那支 API 用了 jwt.decode 而不是 jwt.verify,等于任何人随便丢一串 token 进来,它就帮你签一张新的,直接伪造身份。
  • 权限提升漏洞:更新角色的 endpoint 完全没有认证,任何人都可以把自己升成 admin。
  • 数据泄露漏洞:export 那支 API 把整个数据库 dump 出来,连 token 都一起吐,等于把所有用户的登入凭证公开给全世界。

你还可以指定 focus,后面直接接自然语言,想看什么就写什么:

Claude Code
/codex:adversarial-review focus on authentication flow and token handling

跑比较久可以丢到背景:

Claude Code
/codex:adversarial-review --background

建议用法:commit 前跑普通 review,开 PR 前跑 adversarial。

四、任务委派 Rescue

不只想找问题,还想让 Codex 直接帮你修?用 /codex:rescue

Claude Code
/codex:rescue investigate why the build is failing in CI

以前 debug CI 平均花 30 到 40 分钟,现在一句话丢出去它自己查、自己修。一个月至少省 10 小时。

丢到背景跑,你继续写别的,两个 AI 同时运行:

Claude Code
/codex:rescue --background fix the N+1 query in user dashboard

查看进度和结果:

Claude Code
/codex:status
Claude Code
/codex:result

想在 Codex 那边接着做,在 terminal 打:

bash
codex resume <session-id>

踩坑提醒:第一次没加 --background,结果整个 Claude Code 卡了好几分钟。记住,任务不是几秒能搞定的,一律加 --background

五、Review Gate(自动审 Code)

这是最强的一招。开启后,每次 Claude Code 写完代码给你之前,会自动先丢给 Codex review 一次。有问题就挡住先改好再给你:

Claude Code
/codex:setup --enable-review-gate

实测效果:让 Claude Code 写一个批量删除用户的 endpoint:

Prompt
add a POST /api/users/batch-delete endpoint in src/routes/users.js that accepts an array of ids and deletes them all

Claude Code 写完没有直接给你,先过了一关 Codex review,发现没有认证检查,自己改好才交出来。你什么都不用做。

注意:每次触发都消耗 Codex 额度,loop 跑起来烧蛮快的。做重要功能才开,平常改小东西就关掉。

不用的时候关掉:

Claude Code
/codex:setup --disable-review-gate

六、进阶配置

想调模型或 reasoning 等级,打开 config 文件:

bash
open ~/.codex/config.toml

加入以下设置:

toml
model = "gpt-5.4-mini"
model_reasoning_effort = "xhigh"

model 填你要的模型,reasoning effort 从 low 到 xhigh,一般用 high 就够了。

项目层级的设置放在项目根目录 .codex/config.toml,会覆盖全局设置:

bash
mkdir -p .codex && cp ~/.codex/config.toml .codex/

第一次跑的时候选 trust 就好。

四个核心指令速查

指令 用途 建议时机
/codex:review 基本代码审查 commit 前
/codex:adversarial-review 对抗性深度审查 开 PR 前
/codex:rescue 委派任务让 Codex 自动修 debug / 修复
/codex:setup --enable-review-gate 自动审 code 闸门 做重要功能时