Claude 代码的 Codex 插件 (openai/codex-plugin-cc)
概述
codex-plugin-cc 是一个官方 OpenAI 插件,可将 OpenAI Codex CLI 直接集成到 Claude Code 的开发者工作流程中。它允许 Claude Code 用户触发由 Codex 提供支持的代码审查、对抗性设计挑战和后台任务委托——所有这些都无需离开 Claude Code 界面。
该插件连接了两个强大的 AI 编码代理:Anthropic 的 Claude Code 和 OpenAI 的 Codex CLI,从而实现了“第二意见”和多代理协作工作流程。
存在原因
Claude Code 是一个出色的代理编码工具,但之前将其与 Codex 一起使用需要切换上下文并手动调用单独的工具。该插件消除了这种摩擦:
- Codex 在详细、审慎的代码审查方面特别强大
- 对同一代码运行两个独立的 AI 模型比单独运行一个模型能发现更多问题
- 用户可以保留 Claude Code 作为主要界面,同时将特定任务卸载给 Codex
要求
| 要求 | 详细信息 |
|---|---|
| 身份验证 | ChatGPT 订阅(包含免费套餐)或 OpenAI API 密钥 |
| Node.js | v18.18 或更高版本 |
| Codex CLI | 通过 npm install -g @openai/codex 全局安装 |
使用次数计入您现有的 Codex 使用限额。
安装
# 1. 在 Claude Code 中添加市场源
/plugin marketplace add openai/codex-plugin-cc
# 2. 安装插件
/plugin install codex@openai-codex
# 3. 重新加载插件
/reload-plugins
# 4. 验证设置
/codex:setup
如果未安装 Codex CLI,/codex:setup 可以通过 npm 自动安装它。
核心命令
/codex:review
对您当前未提交的更改或分支差异运行标准的只读 Codex 代码审查。
/codex:review # 审查未提交的更改
/codex:review --base main # 与 main 分支进行审查
/codex:review --background # 在后台运行(建议用于大型差异)
用例: 发货前健全性检查,多文件更改审查。
/codex:adversarial-review
一次可控、有主见的审查,它挑战您的实现选择——而不仅仅是表面上的代码风格。它会质疑假设、权衡、失败模式和替代方法。
/codex:adversarial-review
/codex:adversarial-review --base main challenge whether the caching strategy is correct
/codex:adversarial-review --background look for race conditions
用例: 发货前审查,架构审计,围绕身份验证、数据丢失、回滚和可靠性的设计决策压力测试。
/codex:rescue
将任务委托给 Codex 作为后台子代理 (codex:codex-rescue)。Codex 将调查错误、应用修复或从之前的会话继续。
/codex:rescue investigate why the tests started failing
/codex:rescue fix the failing test with the smallest safe patch
/codex:rescue --model gpt-5.4-mini --effort medium investigate the flaky test
/codex:rescue --background investigate the regression
/codex:rescue --resume apply the top fix from the last run
您也可以使用自然语言:
Ask Codex to redesign the database connection to be more resilient.
支持的标志: --background、--wait、--resume、--fresh、--model、--effort
/codex:status
列出当前存储库正在运行和最近完成的 Codex 作业。
/codex:status
/codex:status task-abc123
/codex:result
检索已完成的 Codex 作业的输出。还返回 Codex 会话 ID,以便直接在 Codex CLI 中重新打开。
/codex:result
/codex:result task-abc123
/codex:cancel
取消活动的后台 Codex 任务。
/codex:cancel
/codex:cancel task-abc123
/codex:setup
检查 Codex 安装和身份验证状态。还管理可选的审查门控。
/codex:setup --enable-review-gate # auto-review every Claude response via Codex Stop hook
/codex:setup --disable-review-gate
⚠️ 审查门控可能会创建长时间运行的 Claude/Codex 反馈循环并迅速耗尽使用限额。启用时请积极监控会话。
典型工作流程
1. 发货前审查
/codex:review
2. 移交棘手的问题
/codex:rescue investigate why the build is failing in CI
3. 长时间后台工作
/codex:adversarial-review --background
/codex:rescue --background investigate the flaky test
# 稍后检查:
/codex:status
/codex:result
配置
该插件继承自 ~/.codex/config.toml(用户级别)或 .codex/config.toml(项目级别)的 Codex CLI 配置。
例如,项目级别的配置,始终以 xhigh 的工作量使用 gpt-5.4-mini:
model = "gpt-5.4-mini"
model_reasoning_effort = "xhigh"
还支持自定义 openai_base_url 以用于自定义 API 端点。
架构
该插件包装了 Codex 应用服务器,并将所有工作委托给同一台机器上全局安装的 Codex CLI 二进制文件。这意味着:
- 不会引入单独的 Codex 运行时
- 身份验证状态与任何现有 Codex 安装共享
- 存储库签出和环境与直接使用 Codex 相同
/codex:result的结果包含会话 ID,可以使用codex resume <session-id>直接恢复
常见问题解答
问:我需要单独的 Codex 帐户吗?
否。如果您已经在机器上登录了 Codex CLI,该插件将重用该身份验证。
问:该插件使用单独的 Codex 运行时吗?
否。它通过您现有的本地 Codex CLI 和应用服务器进行委托。
问:我可以使用我现有的 API 密钥或自定义基础 URL 吗?
是的。该插件会拾取您的 Codex CLI 配置,包括 openai_base_url。
摘要
codex-plugin-cc 代表了 AI 编码工具生态系统中的一个有趣融合:一个官方 OpenAI 工具,旨在扩展竞争产品(Claude Code)。它实现了一个强大的多代理审查工作流程,其中 Claude 编写和迭代代码,而 Codex 提供独立的审查——发现单个模型可能忽略的问题。