Second Opinion (Claude ⇄ Codex relay)
Consult the locally installed Codex CLI (codex exec, non-interactive) as an independent reviewer, then run a short debate. Both sides share their reasoning: Claude writes its thinking into the brief; Codex is asked to return a verdict plus reasoning. The goal is a better final answer, not agreement for its own sake.
When to use
- The user explicitly asks for a second opinion / Codex's view on something Claude produced or proposed (a generation prompt, an architecture, copy, a plan, a diff).
- High-stakes or taste-driven decisions where an independent model genuinely helps.
Do NOT invoke on your own for routine work; it costs a real Codex turn (~30–90s each round).
Setup facts
- Command:
codex exec (non-interactive). Verified on codex-cli 0.144.x; flags are identical on Windows, macOS, and Linux.
- OS detection: read the platform from the session environment —
win32 → use the PowerShell variants below; darwin/linux → use the bash variants. Never ask the user which OS they're on.
- Codex's default model + reasoning effort come from
~/.codex/config.toml (currently a GPT-5.x model at high effort). Only pass -m <model> if the user names a model.
- Codex loads the user's Claude skills from
~/.agents/skills at startup — you can tell it by name which skill to consult.
- A round's stdout transcript can be 100KB+ (Codex dumps files it reads). ALWAYS redirect the transcript to a log file and capture the final answer with
-o.
Workflow
1. Assemble the brief
Create a working folder under the session scratchpad (e.g. <scratchpad>\second-opinion\). Write brief.md containing, in this order:
- Role framing — "You are being consulted by Claude (another AI agent) for an independent second opinion. Do not rubber-stamp. Challenge weak choices. You may consult your available skills if relevant (e.g.
<skill-name>)."
- Task — what the user is trying to achieve, self-contained (Codex has none of the conversation context).
- Claude's proposal — the full artifact under review (the prompt, plan, code, copy), verbatim.
- Claude's reasoning — why these choices were made, including known doubts. This is the shared-thinking channel; be honest about weak spots.
- Pointed questions — 2–4 specific things to challenge, not "thoughts?".
- Response format — "Reply with a verdict line first: AGREE / AGREE WITH CHANGES / DISAGREE, then your revised version and your reasoning. Keep it under N words." (250 is a good default; caps keep rounds fast.)
Never put secrets, API keys, or credentials in the brief.
2. Round 1 — ask Codex
Windows (PowerShell):
$wd = "<scratchpad>\second-opinion"
Get-Content "$wd\brief.md" -Raw | codex exec -s read-only -C "<project dir>" --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd\round1.md" - *> "$wd\round1.log"
Get-Content "$wd\round1.md" -Raw
Select-String -Path "$wd\round1.log" -Pattern "session id:"
macOS / Linux (bash):
wd="<scratchpad>/second-opinion"
codex exec -s read-only -C "<project dir>" --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd/round1.md" - < "$wd/brief.md" > "$wd/round1.log" 2>&1
cat "$wd/round1.md"
grep "session id:" "$wd/round1.log"
- reads the brief from stdin (avoids quoting issues with long briefs).
-C <project dir>: point at the real project when the question references project files, so Codex can read them; otherwise point at the working folder.
-s read-only always — Codex must never modify files; Claude implements any changes.
- Timeout: allow 300000ms; large briefs can take a few minutes.
- Save the session id from the log header — it's needed for relay rounds.
- If you want Codex's step-by-step thinking, skim
round1.log (its intermediate messages appear after codex marker lines; skill/file dumps appear after exec lines — skip those).
3. Claude thinks
Read Codex's verdict and reasoning and genuinely evaluate it:
- Adopt what is actually better, and say so.
- Where you disagree, articulate WHY — a real technical or creative reason, not preference.
- Watch for factual corrections (Codex may know/verify things Claude assumed wrong) — verify against the relevant skill or docs when it matters.
4. Relay rounds (only if warranted, max 2 more)
Only continue if there is genuine disagreement or an open question. Write replyN.md with Claude's counterpoints and reasoning, then resume the SAME Codex session:
Windows (PowerShell):
Get-Content "$wd\reply1.md" -Raw | codex exec resume <session-id> --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd\round2.md" - *> "$wd\round2.log"
macOS / Linux (bash):
codex exec resume <session-id> --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd/round2.md" - < "$wd/reply1.md" > "$wd/round2.log" 2>&1
resume inherits the original sandbox and workdir; no need to repeat -s/-C.
- In relays, ask for a per-point verdict: "CONCEDE / HOLD, one sentence of reasoning each, final version only if changed. Under 150 words."
- Stop when converged, or after round 3 total. Never capitulate just to converge, and never let Codex's confidence substitute for checking.
- Fallback if the session id was lost:
codex exec resume --last ... (riskier — grabs the newest session globally).
5. Synthesize for the user
The final message must stand alone:
- The final artifact (revised prompt/plan/code) after the debate.
- What Codex agreed with, what it pushed back on, and what Claude changed as a result (with the why).
- Any unresolved disagreement: state both positions and Claude's recommendation.
- Where the round files live, in case the user wants the full transcript.
Modes
- Quick check (default when the user says "quick" or the stakes are low): one round, no relay, 150-word cap.
- Debate (default): up to 3 rounds as described.
- Deep: user asks for a thorough review — raise the word cap, let Codex read project files via
-C, allow more rounds.
Failure handling
codex not found → tell the user to install/check PATH.
- Auth errors → user runs
codex login themselves (suggest ! codex login).
- Ignore startup noise in the log: MCP AuthRequired errors, skill-frontmatter load errors, "skills context budget" warnings — they don't affect the run.
- If a round times out, retry once with a longer timeout and a shorter brief before giving up; if Codex is down, say so and give Claude's own best answer.
1---2name: second-opinion3description: Get an independent second opinion from the Codex CLI (OpenAI GPT-5.x) on a plan, prompt, design, code change, or any piece of work — then run a structured debate/relay between Claude and Codex until they converge, and synthesize a joint recommendation. Codex shares Claude's skills (via ~/.agents/skills) so it can ground its critique in the same playbooks (e.g. seedance-2-prompt-engineer). Use when the user says "second opinion", "ask codex", "what does codex think", "run it by codex", "debate this with codex", "sanity check with gpt", or "/second-opinion".4---56# Second Opinion (Claude ⇄ Codex relay)78Consult the locally installed Codex CLI (`codex exec`, non-interactive) as an independent reviewer, then run a short debate. Both sides share their reasoning: Claude writes its thinking into the brief; Codex is asked to return a verdict plus reasoning. The goal is a better final answer, not agreement for its own sake.910## When to use11- The user explicitly asks for a second opinion / Codex's view on something Claude produced or proposed (a generation prompt, an architecture, copy, a plan, a diff).12- High-stakes or taste-driven decisions where an independent model genuinely helps.1314Do NOT invoke on your own for routine work; it costs a real Codex turn (~30–90s each round).1516## Setup facts17- Command: `codex exec` (non-interactive). Verified on codex-cli 0.144.x; flags are identical on Windows, macOS, and Linux.18- **OS detection**: read the platform from the session environment — `win32` → use the PowerShell variants below; `darwin`/`linux` → use the bash variants. Never ask the user which OS they're on.19- Codex's default model + reasoning effort come from `~/.codex/config.toml` (currently a GPT-5.x model at high effort). Only pass `-m <model>` if the user names a model.20- Codex loads the user's Claude skills from `~/.agents/skills` at startup — you can tell it by name which skill to consult.21- A round's stdout transcript can be 100KB+ (Codex dumps files it reads). ALWAYS redirect the transcript to a log file and capture the final answer with `-o`.2223## Workflow2425### 1. Assemble the brief26Create a working folder under the session scratchpad (e.g. `<scratchpad>\second-opinion\`). Write `brief.md` containing, in this order:27281. **Role framing** — "You are being consulted by Claude (another AI agent) for an independent second opinion. Do not rubber-stamp. Challenge weak choices. You may consult your available skills if relevant (e.g. `<skill-name>`)."292. **Task** — what the user is trying to achieve, self-contained (Codex has none of the conversation context).303. **Claude's proposal** — the full artifact under review (the prompt, plan, code, copy), verbatim.314. **Claude's reasoning** — why these choices were made, including known doubts. This is the shared-thinking channel; be honest about weak spots.325. **Pointed questions** — 2–4 specific things to challenge, not "thoughts?".336. **Response format** — "Reply with a verdict line first: AGREE / AGREE WITH CHANGES / DISAGREE, then your revised version and your reasoning. Keep it under N words." (250 is a good default; caps keep rounds fast.)3435Never put secrets, API keys, or credentials in the brief.3637### 2. Round 1 — ask Codex38Windows (PowerShell):39```powershell40$wd = "<scratchpad>\second-opinion"41Get-Content "$wd\brief.md" -Raw | codex exec -s read-only -C "<project dir>" --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd\round1.md" - *> "$wd\round1.log"42Get-Content "$wd\round1.md" -Raw43Select-String -Path "$wd\round1.log" -Pattern "session id:"44```45macOS / Linux (bash):46```bash47wd="<scratchpad>/second-opinion"48codex exec -s read-only -C "<project dir>" --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd/round1.md" - < "$wd/brief.md" > "$wd/round1.log" 2>&149cat "$wd/round1.md"50grep "session id:" "$wd/round1.log"51```52- `-` reads the brief from stdin (avoids quoting issues with long briefs).53- `-C <project dir>`: point at the real project when the question references project files, so Codex can read them; otherwise point at the working folder.54- `-s read-only` always — Codex must never modify files; Claude implements any changes.55- Timeout: allow 300000ms; large briefs can take a few minutes.56- Save the **session id** from the log header — it's needed for relay rounds.57- If you want Codex's step-by-step thinking, skim `round1.log` (its intermediate messages appear after `codex` marker lines; skill/file dumps appear after `exec` lines — skip those).5859### 3. Claude thinks60Read Codex's verdict and reasoning and genuinely evaluate it:61- Adopt what is actually better, and say so.62- Where you disagree, articulate WHY — a real technical or creative reason, not preference.63- Watch for factual corrections (Codex may know/verify things Claude assumed wrong) — verify against the relevant skill or docs when it matters.6465### 4. Relay rounds (only if warranted, max 2 more)66Only continue if there is genuine disagreement or an open question. Write `replyN.md` with Claude's counterpoints and reasoning, then resume the SAME Codex session:6768Windows (PowerShell):69```powershell70Get-Content "$wd\reply1.md" -Raw | codex exec resume <session-id> --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd\round2.md" - *> "$wd\round2.log"71```72macOS / Linux (bash):73```bash74codex exec resume <session-id> --skip-git-repo-check -c model_reasoning_summary="detailed" -o "$wd/round2.md" - < "$wd/reply1.md" > "$wd/round2.log" 2>&175```76- `resume` inherits the original sandbox and workdir; no need to repeat `-s`/`-C`.77- In relays, ask for a per-point verdict: "CONCEDE / HOLD, one sentence of reasoning each, final version only if changed. Under 150 words."78- Stop when converged, or after round 3 total. Never capitulate just to converge, and never let Codex's confidence substitute for checking.79- Fallback if the session id was lost: `codex exec resume --last ...` (riskier — grabs the newest session globally).8081### 5. Synthesize for the user82The final message must stand alone:83- **The final artifact** (revised prompt/plan/code) after the debate.84- What Codex agreed with, what it pushed back on, and what Claude changed as a result (with the why).85- Any unresolved disagreement: state both positions and Claude's recommendation.86- Where the round files live, in case the user wants the full transcript.8788## Modes89- **Quick check** (default when the user says "quick" or the stakes are low): one round, no relay, 150-word cap.90- **Debate** (default): up to 3 rounds as described.91- **Deep**: user asks for a thorough review — raise the word cap, let Codex read project files via `-C`, allow more rounds.9293## Failure handling94- `codex` not found → tell the user to install/check PATH.95- Auth errors → user runs `codex login` themselves (suggest `! codex login`).96- Ignore startup noise in the log: MCP AuthRequired errors, skill-frontmatter load errors, "skills context budget" warnings — they don't affect the run.97- If a round times out, retry once with a longer timeout and a shorter brief before giving up; if Codex is down, say so and give Claude's own best answer.