Second Opinion
Shell out to external LLM CLIs for an independent code review powered by a separate model. Supports OpenAI Codex CLI and Google Gemini CLI.
When to Use
- Getting a second opinion on code changes from a different model
- Reviewing branch diffs before opening a PR
- Checking uncommitted work for issues before committing
- Running a focused review (security, performance, error handling)
- Comparing review output from multiple models
When NOT to Use
- Neither Codex CLI nor Gemini CLI is installed
- No API key or subscription configured for either tool
- Reviewing non-code files (documentation, config)
- You want Claude's own review (just ask Claude directly)
Safety Note
Gemini CLI is invoked with `--yolo`, which auto-approves all tool calls without confirmation. This is required for headless (non-interactive) operation but means Gemini will execute any tool actions its extensions request without prompting.
Quick Reference
# Codex (headless exec with structured JSON output)
codex exec --sandbox read-only --ephemeral \
--output-schema codex-review-schema.json \
-o "$output_file" - < "$prompt_file"
# Gemini (code review extension)
gemini -p "/code-review" --yolo -e code-review
# Gemini (headless with diff — see references/ for full pattern)
git diff HEAD > /tmp/review-diff.txt
{ printf '%s\n\n' 'Review this diff for issues.'; cat /tmp/review-diff.txt; } \
| gemini -p - --yolo -m gemini-3.1-pro-previewInvocation
1. Gather context interactively
Use `AskUserQuestion` to collect review parameters in one shot. Adapt the questions based on what the user already provided in their invocation (skip questions they already answered).
Combine all applicable questions into a single `AskUserQuestion` call (max 4 questions).
**Question 1 — Tool** (skip if user already specified):
header: "Review tool"
question: "Which tool should run the review?"
options:
- "Both Codex and Gemini (Recommended)" → run both in parallel
- "Codex only" → codex exec
- "Gemini only" → gemini CLI**Question 2 — Scope** (skip if user already specified):
header: "Review scope"
question: "What should be reviewed?"
options:
- "Uncommitted changes" → git diff HEAD + untracked files
- "Branch diff vs main" → git diff <branch>...HEAD (auto-detect default branch)
- "Specific commit" → git diff <sha>~1..<sha> (follow up for SHA)**Question 3 — Project context** (skip if neither CLAUDE.md nor AGENTS.md exists):
Check for CLAUDE.md first, then AGENTS.md in the repo root. Only show this question if at least one exists.
header: "Project context"
question: "Include project conventions file so the review
checks against your standards?"
options:
- "Yes, include it"
- "No, standard review"**Question 4 — Review focus** (always ask):
header: "Review focus"
question: "Any specific focus areas for the review?"
options:
- "General review" → no custom prompt
- "Security & auth" → security-focused prompt
- "Performance" → performance-focused prompt
- "Error handling" → error handling-focused prompt2. Run the tool directly
Do not pre-check tool availability. Run the selected tool immediately. If the command fails with "command not found" or an extension is missing, report the install command from the Error Handling table below and skip that tool (if "Both" was selected, run only the available one).
Diff Preview
After collecting answers, show the diff stats:
# For uncommitted (tracked + untracked):
git diff --stat HEAD
git ls
<!-- truncated -->