克劳德法典大桥
](https://www.npmjs.com/package/claude-codex-bridge) ](https://www.npmjs.com/package/claude-codex-bridge)  ](https://nodejs.org)
双向 主控程序 服务器之间的网桥 克劳德代码 和 OpenAI Codex命令行界面.
让Claude和Codex作为合作伙伴工作——每个人都可以向对方寻求帮助,审查代码,解释逻辑,并计划性能改进。
┌──────────────┐ MCP ┌──────────────┐
│ │ ◄──────────────────► │ │
│ Claude Code │ claude-codex │ Codex CLI │
│ │ ◄───── bridge ─────► │ │
└──────────────┘ └──────────────┘先决条件
- Claude 代码命令行界面 --已安装并验证
- Codex CLI --已安装并验证
- >= 18
快速开始
用一个命令设置所有内容:
npx claude-codex-bridge setup这将为Claude Code和Codex注册MCP服务器,并安装 /codex 技能和codex队友经纪人。
设置
自动(推荐)
npx claude-codex-bridge setup # Full setup: both directions + skill + agent
npx claude-codex-bridge setup claude # Only Claude Code → Codex
npx claude-codex-bridge setup codex # Only Codex → Claude
npx claude-codex-bridge setup --skip-extras # MCP servers only, no skill/agent使用 --global 或 --local 控制技能和代理的安装位置(默认为交互式提示)。
手册
Claude Code → Codex (let Claude call Codex)
添加到您的Claude Code MCP配置中:
claude mcp add codex -s user -- npx claude-codex-bridge serve codex或添加到 .mcp.json 在您的项目中:
{
"mcpServers": {
"codex": {
"type": "stdio",
"command": "npx",
"args": ["claude-codex-bridge", "serve", "codex"]
}
}
}Codex → Claude (let Codex call Claude)
增添 ~/.codex/config.toml:
[mcp_servers.claude]
command = "npx"
args = ["claude-codex-bridge", "serve", "claude"]
tool_timeout_sec = 600用法
一旦设置好,只需自然地与Claude Code或Codex交谈。桥接工具会自动拾取。
在克劳德密码中——向Codex寻求帮助
> Ask Codex to review my recent changes
> Get Codex's opinion on whether this approach is correct: [paste plan]
> Have Codex explain how the parser in src/lib/codex-output-parser.ts works
> Ask Codex to analyze performance bottlenecks in the exec runner
> Ask Codex to implement error handling for the retry logic在Codex中——向克劳德求助
> Ask Claude to review the changes in HEAD~3..HEAD
> Have Claude explain the architecture of this project
> Ask Claude to critique my plan for adding caching使用 /codex 斜线命令(克劳德代码)
安装技能以获得 /codex 克劳德代码中的快捷方式:
npx claude-codex-bridge install skill claude --global # or --local然后使用它:
/codex review my recent changes
/codex explain src/lib/exec-runner.ts
/codex is my approach to caching correct?
/codex optimize the output parser for memory usage使用 /claude 斜线命令(Codex)
安装技能以获得 /claude Codex中的快捷方式:
npx claude-codex-bridge install skill codex --global # or --local然后使用它:
/claude review my recent changes
/claude explain the architecture of this project
/claude critique my plan for adding caching作为队友产卵Codex
对于并行工作,将Codex作为Claude Code的子代理生成:
> Spawn a codex-teammate to review src/lib/exec-runner.ts while we keep working工具
ccb-codex --克劳德致电Codex
| 工具 | 说明 |
|---|---|
codex_query | 问Codex一个问题或给它一个任务 |
codex_review_code | 要求Codex审查代码更改 |
codex_review_plan | 请食品法典委员会对实施计划进行评论 |
codex_explain_code | 请Codex解释代码/逻辑/架构 |
codex_plan_perf | 要求食品法典委员会计划绩效改进 |
codex_implement | 请Codex编写或修改代码 |
ccb-claude --食品法典委员会致电克劳德
| 工具 | 说明 |
|---|---|
claude_query | 问克劳德一个问题或给它一个任务 |
claude_review_code | 让Claude检查代码更改 |
claude_review_plan | 请克劳德对实施计划进行评价 |
claude_explain_code | 请Claude解释代码/逻辑/架构 |
claude_plan_perf | 让克劳德计划绩效改进 |
claude_implement | 请Claude编写或修改代码 |
Codex队友代理
您可以将Codex作为 克劳德代码队友 --一个子代理,它自动使用桥接工具为您提供第二意见、审查代码或并行处理任务。
安装代理
npx claude-codex-bridge install agent --global # or --local用法
安装后,使用任务工具从Claude Code中生成队友:
# Code review
Task(subagent_type: "codex-teammate", prompt: "Review src/lib/exec-runner.ts for bugs and performance issues")
# Explain unfamiliar code
Task(subagent_type: "codex-teammate", prompt: "Explain the architecture of the MCP server in codex-server.ts")
# Critique a plan
Task(subagent_type: "codex-teammate", prompt: "Critique this plan: [your plan here]")
# Performance analysis
Task(subagent_type: "codex-teammate", prompt: "Analyze performance bottlenecks in the output parser")
# General question
Task(subagent_type: "codex-teammate", prompt: "What's the best approach for adding retry logic to the bridge?")代理自动选择正确的Codex工具(codex_review_code, codex_explain_code, codex_plan_perf等)。
配置
| 变量 | 描述 | 默认值 |
|---|---|---|
BRIDGE_TIMEOUT_MS | 子进程超时(毫秒) | 600000 (10分钟) |
BRIDGE_MAX_RETRIES | 瞬态错误自动重试(速率限制,5xx,网络) | 2 |
BRIDGE_DEBUG | 启用stderr | --的调试日志记录 |
BRIDGE_DEPTH | 当前递归深度(自动设置) | 0 |
防逆转警卫
桥自动防止无限循环。如果克劳德呼叫Codex,Codex试图再次呼叫克劳德,则第二次呼叫将被阻止(BRIDGE_DEPTH >= 2).
发展
git clone https://github.com/Dunqing/claude-codex-bridge.git
cd claude-codex-bridge
pnpm install
pnpm build # Compile to dist/
pnpm test # Run tests
pnpm lint # Lint and type check
# Dev mode (no build needed)
pnpm dev:codex-server
pnpm dev:claude-server