# Second Opinion

> 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".

- Skill: `guyaga/second-opinion` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add guyaga/second-opinion`
- Raw SKILL.md: https://api.skillmd.com/api/skills/guyaga/second-opinion/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: guyaga (https://skillmd.com/u/guyaga)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/guyaga/second-opinion

---


# 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:

1. **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>`)."
2. **Task** — what the user is trying to achieve, self-contained (Codex has none of the conversation context).
3. **Claude's proposal** — the full artifact under review (the prompt, plan, code, copy), verbatim.
4. **Claude's reasoning** — why these choices were made, including known doubts. This is the shared-thinking channel; be honest about weak spots.
5. **Pointed questions** — 2–4 specific things to challenge, not "thoughts?".
6. **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):
```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):
```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):
```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):
```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.

