用途
codex-plugin-cc 是一个 Claude Code 插件,用于在 Claude Code 会话内部运行 OpenAI Codex 的代码审查,并把后台任务委派给 Codex。它适合只读代码审查、对抗式设计质疑,以及把调查或修复类任务作为子智能体交给 Codex 处理。
主要能力
插件提供以下命令:
/codex:review:对未提交的更改或分支差异运行标准的只读 Codex 代码审查。/codex:adversarial-review:可引导的审查,用于质疑设计决策、权衡取舍和假设。/codex:rescue:把任务(如缺陷调查、修复等)作为后台子智能体委派给 Codex。/codex:status:查看后台 Codex 任务的进度。/codex:result:获取已完成任务的输出(包含可用于 codex resume 的 Codex 会话 ID)。/codex:cancel:取消正在运行的后台任务。/codex:setup:验证 Codex 是否已安装并完成认证;可选地启用或禁用审查门(review gate)。
使用方式
安装
- 添加市场并安装插件:
/plugin marketplace add openai/codex-plugin-cc
/plugin install codex@openai-codex
/reload-plugins
- 验证设置:
/codex:setup
如果缺少 Codex CLI,/codex:setup 可以通过 npm 为你安装,或手动安装:
npm install -g @openai/codex
- 使用 Codex 认证:
!codex login
支持 ChatGPT 账号登录或 API 密钥。如果已经登录,会自动复用现有的 Codex CLI 认证。
常用命令示例
/codex:review:
# 审查未提交的更改
/codex:review
# 审查与基础分支的差异
/codex:review --base main
# 在后台运行(推荐用于多文件更改)
/codex:review --background
# 内联运行并等待
/codex:review --wait
/codex:adversarial-review:
# 基础对抗式审查
/codex:adversarial-review
# 针对分支差异并指定关注点
/codex:adversarial-review --base main challenge whether this caching approach was correct
# 后台运行,关注竞态条件
/codex:adversarial-review --background look for race conditions and question the retry design
/codex:rescue:
# 调查失败的测试
/codex:rescue investigate why the tests started failing
# 应用最小修复
/codex:rescue fix the failing test with the smallest safe patch
# 恢复该仓库最近的 Codex 会话
/codex:rescue --resume apply the top fix from the last run
# 全新开始(忽略之前的会话)
/codex:rescue --fresh investigate the regression
# 使用特定模型和努力级别
/codex:rescue --model gpt-5.4-mini --effort medium investigate the flaky integration test
# 使用更快的 "spark" 模型(映射到 gpt-5.3-codex-spark)
/codex:rescue --model spark fix the issue quickly
# 在后台运行
/codex:rescue --background investigate why the build is failing in CI
也可以通过自然语言向 Claude 触发 rescue:
Ask Codex to redesign the database connection to be more resilient.
/codex:status:
# 列出该仓库所有正在运行和最近的任务
/codex:status
# 查看特定任务
/codex:status task-abc123
/codex:result:
# 获取最近完成的任务结果
/codex:result
# 获取特定任务的结果
/codex:result task-abc123
输出包含 Codex 会话 ID,可直接在 Codex 中恢复该会话:
codex resume <session-id>
/codex:cancel:
# 取消最近的活动任务
/codex:cancel
# 取消特定任务
/codex:cancel task-abc123
/codex:setup 审查门:
# 启用停止钩子审查门
/codex:setup --enable-review-gate
# 禁用它
/codex:setup --disable-review-gate
警告:审查门会在每次 Claude 响应时运行 Codex 审查,如果发现问题会阻止停止。这可能触发长时间的 Claude/Codex 循环并消耗使用限额。仅在主动监控会话时启用。
配置
插件使用与 Codex CLI 相同的 config.toml。配置是分层的:
~/.codex/config.toml:用户级默认值。.codex/config.toml(项目根目录):项目级覆盖(需要受信任的项目)。
示例:为项目设置默认模型和努力级别:
# .codex/config.toml
model = "gpt-5.4-mini"
model_reasoning_effort = "xhigh"
示例:指向自定义的 OpenAI 兼容端点:
# ~/.codex/config.toml
openai_base_url = "https://your-custom-endpoint.example.com/v1"
API 密钥和认证通过 codex login 管理——不要在配置文件中硬编码密钥。CLI 从已认证的会话或 OPENAI_API_KEY 环境变量读取。
适用场景
- 发布前审查:
/codex:review --base main - 启动长时间审查,稍后查看:
/codex:adversarial-review --background look for auth and data-loss risks,然后/codex:status、/codex:result - 委派缺陷调查并在 Codex 中恢复:
/codex:rescue --background investigate why the integration test is flaky,之后/codex:result,复制会话 ID 后codex resume <session-id> - 迭代式 rescue 工作流:先
/codex:rescue investigate the failing build,再/codex:rescue --resume apply the recommended fix from the last run,或/codex:rescue --fresh re-investigate with a clean slate - 用 Claude 自然委派:
Ask Codex to refactor the authentication module to remove the global state.,Claude 会自动调用 codex:codex-rescue 子智能体。
限制与要求
- 需要 Node.js 18.18 或更高版本。
- 需要 ChatGPT 订阅(免费层可用)或 OpenAI API 密钥。
- 需要支持插件的 Claude Code。
- 所有任务在本地环境针对本地仓库检出运行。
- 认证、配置和模型设置来自现有的 Codex CLI 设置。
- 后台任务按仓库跟踪,可通过会话 ID 直接在 Codex 中恢复。
- 项目级配置
.codex/config.toml仅在项目被 Codex 信任时加载。 - 审查门可能触发长时间循环并消耗使用限额,需谨慎启用。
故障排查
/codex:setup提示 Codex 未安装:npm install -g @openai/codex,或让/codex:setup安装。- Codex 已安装但未认证:
!codex login,支持 ChatGPT 账号或 API 密钥;如直接使用 API 密钥:export OPENAI_API_KEY=your-key-here。 - 后台任务似乎卡住:
/codex:status,/codex:cancel task-abc123。 - 安装后插件命令未出现:
/reload-plugins。 - 项目级配置未被读取:在项目目录直接运行 codex 以信任它,或查看 Codex 高级配置文档。
- 审查门造成失控循环:立即禁用
/codex:setup --disable-review-gate。
内部工作原理
- 插件包装本地 codex 二进制和 Codex 应用服务器。
- 所有任务在本地环境针对本地仓库检出运行。
- 认证、配置和模型设置来自现有的 Codex CLI 设置。
- 后台任务按仓库跟踪,可通过会话 ID 直接在 Codex 中恢复。
- codex:codex-rescue 子智能体注册在 /agents 中,当你要求把工作委派给 Codex 时,Claude 可以自动调用它。