🔥 openai/codex-plugin-cc:Claude Code 的 Codex 插件
英文标题:🔥 openai/codex-plugin-cc
该插件为 Claude Code 用户提供一组斜杠命令,可在现有工作流中直接调用 Codex 执行只读审查、可引导的对抗性审查以及后台任务委托。支持 ChatGPT 订阅或 OpenAI API 密钥,并允许通过后台运行和状态管理实现异步工作。开发者无需离开 Claude Code 即可利用 Codex 的审查与修复能力,实现更安全、高效的协作开发与任务转移。
48.7 KB
中文
Claude Code 的 Codex 插件
在 Claude Code 内部使用 Codex 进行代码审查或将任务委托给 Codex。
这个插件面向希望从已有工作流中轻松开始使用 Codex 的 Claude Code 用户。
-
/codex:review用于普通的只读 Codex 审查 -
/codex:adversarial-review用于可引导的挑战性审查 -
/codex:rescue、/codex:transfer、/codex:status、/codex:result和/codex:cancel用于委托工作、移交会话以及管理后台任务 -
ChatGPT 订阅(包含免费版)或 OpenAI API 密钥。
- 使用情况将计入你的 Codex 用量额度。了解更多。
-
Node.js 18.18 或更高版本
在 Claude Code 中添加市场:
/plugin marketplace add openai/codex-plugin-cc
安装插件:
/plugin install codex@openai-codex
重新加载插件:
然后运行:
/codex:setup 会告诉你 Codex 是否已就绪。如果缺少 Codex 且 npm 可用,它可以帮你自动安装 Codex。
如果你更希望自己安装 Codex,请使用:
npm install -g @openai/codex
如果 Codex 已安装但尚未登录,请运行:
安装完成后,你应该会看到:
- 下面列出的斜杠命令
/agents中的codex:codex-rescue子代理
一个简单的首次运行示例:
/codex:review --background /codex:status /codex:result
对当前工作内容运行一次普通的 Codex 审查。其代码审查质量与在 Codex 中直接运行 /review 一致。
注意
代码审查(尤其是多文件变更)可能需要一些时间。通常建议在后台运行。
当你需要以下内容时使用:
- 对当前未提交变更的审查
- 将你的分支与基础分支(如
main)进行比较的审查
使用 --base <ref> 进行分支审查。它也支持 --wait 和 --background。该命令不可引导,也不接受自定义焦点文本。当你想挑战特定的决策或风险领域时,请使用 /codex:adversarial-review。
示例:
/codex:review /codex:review --base main /codex:review --background
此命令为只读,不会执行任何更改。在后台运行时,你可以使用 /codex:status 查看进度,使用 /codex:cancel 取消正在进行的任务。
/codex:adversarial-review
运行一个可引导的审查,对所选的实现和设计提出质疑。
可用它来对假设、权衡、失效模式以及采用其他方案是否会更安全或更简单进行压力测试。
它使用与 /codex:review 相同的审查目标选择方式,包括用于分支审查的 --base <ref>。也支持 --wait 和 --background。与 /codex:review 不同的是,它可以在标志后面接收额外的焦点文本。
当你需要以下内容时使用:
- 在发布前对方向性进行挑战的审查,而不仅仅是代码细节
- 专注于设计选择、权衡、隐藏假设和替代方案的审查
- 围绕特定风险领域(如认证、数据丢失、回滚、竞态条件或可靠性)进行压力测试
示例:
/codex:adversarial-review /codex:adversarial-review --base main 质疑当前的缓存和重试设计是否正确 /codex:adversarial-review --background 寻找竞态条件并质疑所选方法
此命令为只读。它不会修复代码。
通过 codex:codex-rescue 子代理将任务交给 Codex。
当你希望 Codex 执行以下操作时使用:
- 调查一个 bug
- 尝试修复
- 继续之前的 Codex 任务
- 使用更小的模型进行更快或更经济的处理
注意
根据任务和你选择的模型,这些任务可能需要很长时间,通常建议强制将任务置于后台或将代理移至后台。
它支持 --background、--wait、--resume 和 --fresh。如果省略 --resume 和 --fresh,插件可以帮你继续该仓库最近的救援线程。
示例:
/codex:rescue 调查测试为什么开始失败 /codex:rescue 用最小的安全补丁修复失败的测试 /codex:rescue --resume 应用上次运行中排名最高的修复 /codex:rescue --model gpt-5.4-mini --effort medium 调查不稳定的集成测试 /codex:rescue --model spark 快速修复问题 /codex:rescue --background 调查回归
你也可以直接要求将任务委托给 Codex:
请 Codex 重新设计数据库连接以使其更具韧性。
备注:
- 如果你不传递
--model或--effort,Codex 将自行选择默认值。 - 如果你说
spark,插件会将其映射为gpt-5.3-codex-spark - 后续的救援请求可以继续该仓库中最近的 Codex 任务
/codex:transfer
从当前 Claude Code 会话创建一个持久化的 Codex 线程,并打印 codex resume <session-id> 命令。
当你在 Claude Code 中开始了一段调试或实现讨论,并想在 Codex 中直接继续同一上下文时使用。
示例:
/codex:transfer /codex:transfer --source ~/.claude/projects/-Users-me-repo/.jsonl
插件已有的 SessionStart 钩子会自动提供当前会话记录路径;--source 作为手动覆盖选项。转移过程使用 Codex 的外部代理会话导入器,因此它遵循与在 Codex App 中导入 Claude 历史相同的转换规则,并创建可在 App 或 TUI 中继续的可视化对话轮次。源文件必须位于 ~/.claude/projects 下,并且不支持会话导入的较旧 Codex 版本在使用此命令前必须升级。
显示当前仓库正在运行和最近的 Codex 作业。
示例:
/codex:status /codex:status task-abc123
使用它来:
- 检查后台工作的进度
- 查看最近完成的作业
- 确认某个任务是否仍在运行
显示已完成作业的最终存储的 Codex 输出。当可用时,它还会包含 Codex 会话 ID,以便你可以通过 codex resume <session-id> 直接在 Codex 中重新打开该运行。
示例:
/codex:result /codex:result task-abc123
取消一个活跃的后台 Codex 作业。
示例:
/codex:cancel /codex:cancel task-abc123
检查 Codex 是否已安装并认证。如果缺少 Codex 且 npm 可用,它可以帮你安装 Codex。
你还可以使用 /codex:setup 来管理可选的审查门控。
/codex:setup --enable-review-gate /codex:setup --disable-review-gate
当审查门控启用时,插件会使用一个 Stop 钩子基于 Claude 的响应运行针对性的 Codex 审查。如果该审查发现问题,停止操作将被阻止,以便 Claude 可以先进行处理。
警告
审查门控可能会产生长时间运行的 Claude/Codex 循环,并可能迅速消耗用量额度。请仅在你计划主动监控会话时启用它。
/codex:rescue 调查为什么 CI 中的构建在失败
启动一个长时间运行的任务
/codex:adversarial-review --background /codex:rescue --background 调查不稳定的测试
然后通过以下方式检查:
/codex:status /codex:result
Codex 插件封装了 Codex app server。它使用你环境中安装的全局 codex 二进制文件,并应用相同的配置。
如果你想更改插件使用的默认推理投入度或默认模型,可以在用户级或项目级的 config.toml 中进行定义。例如,要让一个特定项目始终在 high 下使用 gpt-5.4-mini,你可以在启动 Claude 的目录根下的 .codex/config.toml 文件中添加以下内容:
model = "gpt-5.4-mini" model_reasoning_effort = "high"
你的配置将基于以下顺序被加载:
- 用户级配置在
~/.codex/config.toml - 项目级覆盖在
.codex/config.toml - 项目级覆盖仅在项目被信任时加载
查看 Codex 文档了解更多配置选项。
将工作转移至 Codex
委托的任务和任何停止门控运行也可以通过运行 codex resume 直接在 Codex 中恢复,你可以使用从 /codex:result 或 /codex:status 获得的特定会话 ID,或从列表中选择。
这样你就可以在 Codex 中审查其工作或继续工作。
我是否需要单独的 Codex 账户来使用此插件?
如果你已在本机登录 Codex,该账户应该也可以在这里立即使用。此插件使用你本地的 Codex CLI 认证。
如果你目前只使用 Claude Code 而尚未使用 Codex,你还需要使用 ChatGPT 账户或 API 密钥登录 Codex。Codex 随你的 ChatGPT 订阅提供,并且 codex login 同时支持 ChatGPT 和 API 密钥登录。运行 /codex:setup 检查 Codex 是否就绪,如果未就绪则使用 !codex login。
插件是否使用单独的 Codex 运行时?
不。此插件通过你本地的 Codex CLI 和 Codex app server 在同一台机器上进行委托。
这意味着:
- 它使用你直接使用时会用到的相同 Codex 安装
- 它使用相同的本地认证状态
- 它使用相同的仓库检出和机器本地环境
它会使用我已经拥有的 Codex 配置吗?
是的。如果你已经在使用 Codex,该插件会加载相同的配置。
我可以继续使用当前的 API 密钥或 base URL 设置吗?
可以。因为该插件使用你本地的 Codex CLI,你现有的登录方式和配置仍然有效。
如果你需要将内置的 OpenAI 提供方指向其他端点,请在 Codex 配置中设置 openai_base_url。
English / 原文
Codex plugin for Claude Code
Use Codex from inside Claude Code for code reviews or to delegate tasks to Codex.
This plugin is for Claude Code users who want an easy way to start using Codex from the workflow they already have.
-
/codex:reviewfor a normal read-only Codex review -
/codex:adversarial-reviewfor a steerable challenge review -
/codex:rescue,/codex:transfer,/codex:status,/codex:result, and/codex:cancelto delegate work, hand off sessions, and manage background jobs -
ChatGPT subscription (incl. Free) or OpenAI API key.
- Usage will contribute to your Codex usage limits. Learn more.
-
Node.js 18.18 or later
Add the marketplace in Claude Code:
/plugin marketplace add openai/codex-plugin-cc
Install the plugin:
/plugin install codex@openai-codex
Reload plugins:
Then run:
/codex:setup will tell you whether Codex is ready. If Codex is missing and npm is available, it can offer to install Codex for you.
If you prefer to install Codex yourself, use:
npm install -g @openai/codex
If Codex is installed but not logged in yet, run:
After install, you should see:
- the slash commands listed below
- the
codex:codex-rescuesubagent in/agents
One simple first run is:
/codex:review --background
/codex:status
/codex:result
Runs a normal Codex review on your current work. It gives you the same quality of code review as running /review inside Codex directly.
Note
Code review especially for multi-file changes might take a while. It's generally recommended to run it in the background.
Use it when you want:
- a review of your current uncommitted changes
- a review of your branch compared to a base branch like
main
Use --base <ref> for branch review. It also supports --wait and --background. It is not steerable and does not take custom focus text. Use /codex:adversarial-review when you want to challenge a specific decision or risk area.
Examples:
/codex:review
/codex:review --base main
/codex:review --background
This command is read-only and will not perform any changes. When run in the background you can use /codex:status to check on the progress and /codex:cancel to cancel the ongoing task.
/codex:adversarial-review
Runs a steerable review that questions the chosen implementation and design.
It can be used to pressure-test assumptions, tradeoffs, failure modes, and whether a different approach would have been safer or simpler.
It uses the same review target selection as /codex:review, including --base <ref> for branch review. It also supports --wait and --background. Unlike /codex:review, it can take extra focus text after the flags.
Use it when you want:
- a review before shipping that challenges the direction, not just the code details
- review focused on design choices, tradeoffs, hidden assumptions, and alternative approaches
- pressure-testing around specific risk areas like auth, data loss, rollback, race conditions, or reliability
Examples:
/codex:adversarial-review
/codex:adversarial-review --base main challenge whether this was the right caching and retry design
/codex:adversarial-review --background look for race conditions and question the chosen approach
This command is read-only. It does not fix code.
Hands a task to Codex through the codex:codex-rescue subagent.
Use it when you want Codex to:
- investigate a bug
- try a fix
- continue a previous Codex task
- take a faster or cheaper pass with a smaller model
Note
Depending on the task and the model you choose these tasks might take a long time and it's generally recommended to force the task to be in the background or move the agent to the background.
It supports --background, --wait, --resume, and --fresh. If you omit --resume and --fresh, the plugin can offer to continue the latest rescue thread for this repo.
Examples:
/codex:rescue investigate why the tests started failing
/codex:rescue fix the failing test with the smallest safe patch
/codex:rescue --resume apply the top fix from the last run
/codex:rescue --model gpt-5.4-mini --effort medium investigate the flaky integration test
/codex:rescue --model spark fix the issue quickly
/codex:rescue --background investigate the regression
You can also just ask for a task to be delegated to Codex:
Ask Codex to redesign the database connection to be more resilient.
Notes:
- if you do not pass
--modelor--effort, Codex chooses its own defaults. - if you say
spark, the plugin maps that togpt-5.3-codex-spark - follow-up rescue requests can continue the latest Codex task in the repo
/codex:transfer
Creates a persistent Codex thread from the current Claude Code session and prints a codex resume <session-id> command.
Use it when you started a debugging or implementation conversation in Claude Code and want to continue that same context directly in Codex.
Examples:
/codex:transfer
/codex:transfer --source ~/.claude/projects/-Users-me-repo/<session-id>.jsonl
The plugin's existing SessionStart hook supplies the current transcript path automatically; --source is available as a manual override. The transfer uses Codex's external-agent session importer, so it follows the same conversion rules as importing Claude history in the Codex App and creates visible turns that can be continued in the App or TUI. The source must be under ~/.claude/projects, and older Codex versions that do not expose session import must be upgraded before using this command.
Shows running and recent Codex jobs for the current repository.
Examples:
/codex:status
/codex:status task-abc123
Use it to:
- check progress on background work
- see the latest completed job
- confirm whether a task is still running
Shows the final stored Codex output for a finished job. When available, it also includes the Codex session ID so you can reopen that run directly in Codex with codex resume <session-id>.
Examples:
/codex:result
/codex:result task-abc123
Cancels an active background Codex job.
Examples:
/codex:cancel
/codex:cancel task-abc123
Checks whether Codex is installed and authenticated. If Codex is missing and npm is available, it can offer to install Codex for you.
You can also use /codex:setup to manage the optional review gate.
/codex:setup --enable-review-gate
/codex:setup --disable-review-gate
When the review gate is enabled, the plugin uses a Stop hook to run a targeted Codex review based on Claude's response. If that review finds issues, the stop is blocked so Claude can address them first.
Warning
The review gate can create a long-running Claude/Codex loop and may drain usage limits quickly. Only enable it when you plan to actively monitor the session.
/codex:rescue investigate why the build is failing in CI
Start Something Long-Running
/codex:adversarial-review --background
/codex:rescue --background investigate the flaky test
Then check in with:
/codex:status
/codex:result
The Codex plugin wraps the Codex app server. It uses the global codex binary installed in your environment and applies the same configuration.
If you want to change the default reasoning effort or the default model that gets used by the plugin, you can define that inside your user-level or project-level config.toml. For example to always use gpt-5.4-mini on high for a specific project you can add the following to a .codex/config.toml file at the root of the directory you started Claude in:
model = "gpt-5.4-mini"
model_reasoning_effort = "high"
Your configuration will be picked up based on:
- user-level config in
~/.codex/config.toml - project-level overrides in
.codex/config.toml - project-level overrides only load when the project is trusted
Check out the Codex docs for more configuration options.
Moving The Work Over To Codex
Delegated tasks and any stop gate run can also be directly resumed inside Codex by running codex resume either with the specific session ID you received from running /codex:result or /codex:status or by selecting it from the list.
This way you can review the Codex work or continue the work there.
Do I need a separate Codex account for this plugin?
If you are already signed into Codex on this machine, that account should work immediately here too. This plugin uses your local Codex CLI authentication.
If you only use Claude Code today and have not used Codex yet, you will also need to sign in to Codex with either a ChatGPT account or an API key. Codex is available with your ChatGPT subscription, and codex login supports both ChatGPT and API key sign-in. Run /codex:setup to check whether Codex is ready, and use !codex login if it is not.
Does the plugin use a separate Codex runtime?
No. This plugin delegates through your local Codex CLI and Codex app server on the same machine.
That means:
- it uses the same Codex install you would use directly
- it uses the same local authentication state
- it uses the same repository checkout and machine-local environment
Will it use the same Codex config I already have?
Yes. If you already use Codex, the plugin picks up the same configuration.
Can I keep using my current API key or base URL setup?
Yes. Because the plugin uses your local Codex CLI, your existing sign-in method and config still apply.
If you need to point the built-in OpenAI provider at a different endpoint, set openai_base_url in your Codex config.