collaborating-with-claude
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCollaborating with Claude Code (Codex)
与Claude Code(Codex)协作
Use Claude Code CLI as a collaborator while keeping Codex as the primary implementer.
This skill provides a lightweight bridge script () that returns structured JSON and supports multi-turn sessions via .
scripts/claude_bridge.pySESSION_ID将Claude Code CLI作为协作工具,同时以Codex作为主要实现工具。
本技能提供了一个轻量级的桥接脚本(),可返回结构化JSON,并支持通过进行多轮会话。
scripts/claude_bridge.pySESSION_IDWhen to use
适用场景
- You want a second opinion (design tradeoffs, edge cases, missing tests).
- You want Claude to propose or review a unified diff (Claude does not edit files).
- You want multi-turn back-and-forth while you implement locally.
- 你需要第二意见(设计权衡、边缘情况、缺失的测试)。
- 你希望Claude提出或审查Unified Diff Patch(Claude不会编辑文件)。
- 你希望在本地实现的同时进行多轮来回沟通。
When not to use
不适用场景
- The task is trivial or one-shot (do it directly in Codex).
- You need authoritative facts that require browsing/citations (Claude may guess).
- You might paste sensitive data (secrets, private keys, prod logs).
- 任务琐碎或只需单次完成(直接在Codex中操作即可)。
- 你需要需要浏览/引用的权威事实(Claude可能会猜测)。
- 你可能会粘贴敏感数据(密钥、私钥、生产日志)。
Core rules
核心规则
- Claude is a collaborator; you own the final result and must verify changes locally.
- Do not invoke directly; always use the bridge script (
claude) so output/session handling stays consistent.scripts/claude_bridge.py - Prefer file/line references over pasting snippets. Run the bridge with set to the repo root (it sets the
--cdprocess working directory); useclaudewhen Claude needs access to additional directories.--add-dir - For code changes, request Unified Diff Patch ONLY and forbid direct file modification.
- Always run the bridge script with first if you are unsure of parameters.
--help - Always capture and reuse it for follow-ups to keep the collaboration conversation-aware.
SESSION_ID - For automation, prefer (resume). Session selectors are mutually exclusive: choose one of
--SESSION_ID,--SESSION_ID, or--continue.--session-id - Keep a short Collaboration State Capsule updated while this skill is active.
- Default timeout: when invoking via the Codex command runner, set to 600000 (10 minutes) unless a shorter/longer timeout is explicitly required.
timeout_ms - Default model: prefer for routine work; use
sonnetonly for complex tasks or when explicitly requested.opus - Ensure Claude Code is logged in before running headless commands (run and
claudeonce if needed)./login - Streamed JSON requires ; the bridge enables this automatically.
--verbose
- Claude是协作工具;你拥有最终结果的所有权,必须在本地验证更改。
- 不要直接调用;始终使用桥接脚本(
claude),以保持输出/会话处理的一致性。scripts/claude_bridge.py - 优先使用文件/行引用而非粘贴代码片段。运行桥接脚本时设置为仓库根目录(它会设置
--cd进程的工作目录);当Claude需要访问额外目录时使用claude。--add-dir - 对于代码更改,仅请求Unified Diff Patch,禁止直接修改文件。
- 如果你不确定参数,始终先运行桥接脚本的命令。
--help - 始终捕获并在后续操作中复用,以使协作会话保持上下文感知。
SESSION_ID - 对于自动化,优先使用(恢复会话)。会话选择器互斥:选择
--SESSION_ID、--SESSION_ID或--continue中的一个。--session-id - 当此技能处于激活状态时,保持简短的协作状态胶囊更新。
- 默认超时:通过Codex命令运行器调用时,将设置为600000(10分钟),除非明确需要更短或更长的超时时间。
timeout_ms - 默认模型:日常工作优先使用;仅在处理复杂任务或明确要求时使用
sonnet。opus - 在运行无头命令前确保Claude Code已登录(如有需要,运行并执行
claude一次)。/login - 流式JSON需要;桥接脚本会自动启用此选项。
--verbose
Model selection
模型选择
Claude Code supports model aliases, so you can use / instead of hard-coding versioned model IDs.
--model sonnet--model opus- If you omit , Claude Code uses its configured default (typically from
--model, optionally overridden by~/.claude/settings.jsonand.claude/settings.json)..claude/settings.local.json - If you need strict reproducibility, pass a full model name via .
--model <full-name>
Claude Code支持模型别名,因此你可以使用 / ,而非硬编码带版本的模型ID。
--model sonnet--model opus- 如果你省略,Claude Code将使用其配置的默认模型(通常来自
--model,可通过~/.claude/settings.json和.claude/settings.json选择性覆盖)。.claude/settings.local.json - 如果你需要严格的可重复性,通过传递完整的模型名称。
--model <full-name>
Quick start (shell-safe)
快速开始(Shell安全)
⚠️ If your prompt contains Markdown backticks (), do not pass it directly via (your shell may treat backticks as command substitution). Use a heredoc instead; see .
`like/this`--PROMPT "..."references/shell-quoting.mdbash
PROMPT="$(cat <<'EOF'
Review src/auth.py around login() and propose fixes.
OUTPUT: Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --model sonnet --PROMPT "$PROMPT" --output-format stream-jsonOutput: JSON with , , , and optional / .
successSESSION_IDagent_messageserrorall_messages⚠️ 如果你的提示包含Markdown反引号(),请勿直接通过传递(你的Shell可能会将反引号视为命令替换)。请改用here文档;详见。
`like/this`--PROMPT "..."references/shell-quoting.mdbash
PROMPT="$(cat <<'EOF'
Review src/auth.py around login() and propose fixes.
OUTPUT: Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --model sonnet --PROMPT "$PROMPT" --output-format stream-json输出: 包含、、以及可选的 / 的JSON。
successSESSION_IDagent_messageserrorall_messagesMulti-turn sessions
多轮会话
bash
undefinedbash
undefinedStart a session
启动会话
PROMPT="$(cat <<'EOF'
Analyze the bug in foo(). Keep it short.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --PROMPT "$PROMPT" --output-format stream-json
PROMPT="$(cat <<'EOF'
Analyze the bug in foo(). Keep it short.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --PROMPT "$PROMPT" --output-format stream-json
Continue the same session
继续同一会话
PROMPT="$(cat <<'EOF'
Now propose a minimal fix as Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --SESSION_ID "<SESSION_ID>" --PROMPT "$PROMPT" --output-format stream-json
undefinedPROMPT="$(cat <<'EOF'
Now propose a minimal fix as Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --cd "." --SESSION_ID "<SESSION_ID>" --PROMPT "$PROMPT" --output-format stream-json
undefinedPrompting patterns (token efficient)
提示模式(Token高效)
Use as a starter when crafting .
assets/prompt-template.md--PROMPT制作时,可使用作为模板。
--PROMPTassets/prompt-template.md1) Ask Claude to open files itself
1) 让Claude自行打开文件
Provide:
- Entry file(s) and approximate line numbers
- Objective and constraints
- Output format (diff vs analysis)
Avoid:
- Pasting large code blocks
- Multiple competing objectives in one request
提供:
- 入口文件和大致行号
- 目标和约束
- 输出格式(差异对比 vs 分析)
避免:
- 粘贴大段代码块
- 一个请求中包含多个相互竞争的目标
2) Enforce safe output for code changes
2) 确保代码更改的输出安全
Append this to prompts when requesting code:
OUTPUT: Unified Diff Patch ONLY. Strictly prohibit any actual modifications.
当请求代码时,在提示末尾添加:
OUTPUT: Unified Diff Patch ONLY. Strictly prohibit any actual modifications.
3) Use Claude for what it’s good at
3) 让Claude发挥其优势
- Alternative solution paths and edge cases
- UI/UX and readability feedback
- Review of a proposed patch (risk spotting, missing tests)
- 替代解决方案路径和边缘情况
- UI/UX和可读性反馈
- 对提议补丁的审查(风险识别、缺失的测试)
Verification
验证
- Smoke-test the bridge: .
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --help - If you need a session: run one prompt with and confirm the JSON contains
--output-format stream-jsonand asuccess: true.SESSION_ID - Note: won’t include a newly generated session id; use
--output-format text/stream-jsonto capture it. If you resume withjsonin--SESSION_IDmode, the bridge echoes thattextin its JSON output.SESSION_ID
- 烟雾测试桥接脚本:。
python3 .codex/skills/collaborating-with-claude/scripts/claude_bridge.py --help - 如果需要会话:运行一个带的提示,确认JSON包含
--output-format stream-json和success: true。SESSION_ID - 注意:不会包含新生成的会话ID;使用
--output-format text/stream-json来捕获它。如果你在json模式下使用text恢复会话,桥接脚本会在其JSON输出中回显该--SESSION_ID。SESSION_ID
Safety & guardrails
安全与防护措施
- Never paste secrets (private keys, API keys, seed phrases) into prompts.
- For code changes, request Unified Diff Patch ONLY and apply changes yourself.
- Treat Claude output as suggestions; verify locally (tests, lint, build) before merging.
- 切勿在提示中粘贴机密信息(私钥、API密钥、助记词)。
- 对于代码更改,仅请求Unified Diff Patch并自行应用更改。
- 将Claude的输出视为建议;在合并前在本地验证(测试、代码检查、构建)。
Collaboration State Capsule
协作状态胶囊
Keep this short block updated near the end of your reply while collaborating:
text
[Claude Collaboration Capsule]
Goal:
Claude SESSION_ID:
Files/lines handed off:
Last ask:
Claude summary:
Next ask:协作时,请在回复末尾附近更新此简短模块:
text
[Claude Collaboration Capsule]
Goal:
Claude SESSION_ID:
Files/lines handed off:
Last ask:
Claude summary:
Next ask:References
参考资料
- (prompt patterns)
assets/prompt-template.md - (shell quoting/backticks)
references/shell-quoting.md
- (提示模式)
assets/prompt-template.md - (Shell引用/反引号)
references/shell-quoting.md