second-opinion
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecond 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.
调用外部LLM CLI,借助独立模型进行独立代码审查。支持OpenAI Codex CLI和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
- 从不同模型获取代码更改的第二意见
- 发起PR前审查分支差异
- 提交前检查未提交工作中的问题
- 进行针对性审查(安全、性能、错误处理)
- 对比多个模型的审查输出
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)
- 未安装Codex CLI或Gemini CLI
- 未为任一工具配置API密钥或订阅
- 审查非代码文件(文档、配置)
- 想要Claude自身的审查结果(直接向Claude请求即可)
Safety Note
安全说明
Gemini CLI is invoked with , 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.
--yolo调用Gemini CLI时使用参数,该参数会自动批准所有工具调用而无需确认。这是无头(非交互式)操作的必需设置,但意味着Gemini会执行其扩展请求的任何工具操作,不会进行提示。
--yoloQuick Reference
快速参考
undefinedundefinedCodex
Codex
codex review --uncommitted
codex review --base <branch>
codex review --commit <sha>
codex review --uncommitted
codex review --base <branch>
codex review --commit <sha>
Gemini (code review extension)
Gemini(代码审查扩展)
gemini -p "/code-review" --yolo -e code-review
gemini -p "/code-review" --yolo -e code-review
Gemini (headless with diff — see references/ for full heredoc pattern)
Gemini(无头模式+差异对比 — 查看references/获取完整 heredoc 模式)
git diff HEAD > /tmp/review-diff.txt
cat <<'PROMPT' | gemini -p - --yolo
Review this diff...
$(cat /tmp/review-diff.txt)
PROMPT
undefinedgit diff HEAD > /tmp/review-diff.txt
cat <<'PROMPT' | gemini -p - --yolo
Review this diff...
$(cat /tmp/review-diff.txt)
PROMPT
undefinedInvocation
调用流程
1. Gather context interactively
1. 交互式收集上下文
Use 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).
AskUserQuestionCombine all applicable questions into a single
call (max 4 questions).
AskUserQuestionQuestion 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 review
- "Gemini only" → gemini CLIQuestion 2 — Scope (skip if user already specified):
header: "Review scope"
question: "What should be reviewed?"
options:
- "Uncommitted changes" → --uncommitted / git diff HEAD
- "Branch diff vs main" → --base (auto-detect default branch)
- "Specific commit" → --commit (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"Note: Project context only applies to Gemini and to Codex
with . For Codex with /, the
positional prompt is not supported — inform the user that Codex
will review without custom instructions in this mode (it still
reads if one exists in the repo).
--uncommitted--base--commitAGENTS.mdQuestion 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 prompt使用一次性收集审查参数。根据用户在调用时已提供的信息调整问题(跳过已回答的问题)。
AskUserQuestion将所有适用问题合并到一个调用中(最多4个问题)。
AskUserQuestion问题1 — 工具(若用户已指定则跳过):
header: "审查工具"
question: "应使用哪个工具进行审查?"
options:
- "Codex和Gemini都用(推荐)" → 并行运行两者
- "仅使用Codex" → codex review
- "仅使用Gemini" → gemini CLI问题2 — 范围(若用户已指定则跳过):
header: "审查范围"
question: "应审查哪些内容?"
options:
- "未提交的更改" → --uncommitted / git diff HEAD
- "与主分支的差异" → --base(自动检测默认分支)
- "特定提交" → --commit(后续询问SHA值)问题3 — 项目上下文(若仓库根目录中不存在CLAUDE.md和AGENTS.md则跳过):
先检查CLAUDE.md,再检查AGENTS.md。仅当至少存在一个时显示此问题。
header: "项目上下文"
question: "是否包含项目约定文件,以便审查符合你的标准?"
options:
- "是,包含"
- "否,进行标准审查"注意:项目上下文仅适用于Gemini和使用参数的Codex。对于使用/的Codex,不支持传入自定义提示 — 需告知用户此限制(Codex会读取仓库中已有的,但本工具不会创建该文件)。
--uncommitted--base--commitAGENTS.md问题4 — 审查重点(始终询问):
header: "审查重点"
question: "审查是否有特定的重点领域?"
options:
- "通用审查" → 无自定义提示
- "安全与认证" → 安全导向提示
- "性能" → 性能导向提示
- "错误处理" → 错误处理导向提示2. Run the tool directly
2. 直接运行工具
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).
无需预先检查工具可用性。立即运行选定的工具。若命令执行失败并提示"command not found"或缺少扩展,告知用户下方错误处理表中的安装命令,并跳过该工具(若选择了"两者都用",则仅运行可用的工具)。
Diff Preview
差异预览
After collecting answers, show the diff stats:
bash
undefined收集所有回答后,展示差异统计信息:
bash
undefinedFor uncommitted:
未提交更改:
git diff --stat HEAD
git diff --stat HEAD
For branch diff:
分支差异:
git diff --stat <branch>...HEAD
git diff --stat <branch>...HEAD
For specific commit:
特定提交:
git diff --stat <sha>~1..<sha>
If the diff is empty, stop and tell the user.
If the diff is very large (>2000 lines changed), warn the user
that high-effort reasoning on a large diff will be slow and ask
whether to proceed or narrow the scope.git diff --stat <sha>~1..<sha>
若差异为空,停止操作并告知用户。
若差异非常大(更改行数超过2000行),警告用户对大差异进行深度推理会很慢,并询问是否继续或缩小范围。Auto-detect Default Branch
自动检测默认分支
For branch diff scope, detect the default branch name:
bash
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null \
| sed 's@^refs/remotes/origin/@@' || echo main对于分支差异范围,检测默认分支名称:
bash
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null \
| sed 's@^refs/remotes/origin/@@' || echo mainCodex Invocation
Codex调用
See references/codex-invocation.md
for full details on command syntax, prompt passing, and model
fallback.
Summary:
- Model: , reasoning:
gpt-5.3-codexxhigh - takes a positional prompt
--uncommitted - and
--basedo NOT accept custom prompts (Codex reads--commitif present, but the skill will not create one; note this limitation to the user)AGENTS.md - Falls back to on auth errors
gpt-5.2-codex - Output is verbose — summarize findings, don't dump raw (see references/codex-invocation.md § Parsing Output)
- Set on the Bash call
timeout: 600000
有关命令语法、提示传递和模型回退的完整详细信息,请参阅references/codex-invocation.md。
摘要:
- 模型:,推理级别:
gpt-5.3-codexxhigh - 支持传入位置参数提示
--uncommitted - 和
--base不接受自定义提示 (Codex会读取仓库中已有的--commit,但本工具不会创建该文件;需向用户说明此限制)AGENTS.md - 认证错误时回退到
gpt-5.2-codex - 输出内容冗长 — 需总结结果,不要直接输出原始内容 (请参阅references/codex-invocation.md § 解析输出)
- 在Bash调用中设置
timeout: 600000
Gemini Invocation
Gemini调用
See references/gemini-invocation.md
for full details on flags, scope mapping, and extension usage.
Summary:
- Model: , flags:
gemini-3-pro-preview,--yolo,-e-m - For uncommitted general review:
gemini -p "/code-review" --yolo -e code-review - For branch/commit diffs: pipe into
git diffgemini -p - Security extension name is (not
gemini-cli-security)security - is interactive-only — use
/security:analyzewith a security prompt instead-p - Run as bonus when security focus selected
/security:scan-deps - Set on the Bash call
timeout: 600000
Scope mapping for (Gemini has no built-in scope flags):
git diff| Scope | Diff command |
|---|---|
| Uncommitted | |
| Branch diff | |
| Specific commit | |
有关标志、范围映射和扩展使用的完整详细信息,请参阅references/gemini-invocation.md。
摘要:
- 模型:,标志:
gemini-3-pro-preview,--yolo,-e-m - 未提交更改的通用审查:
gemini -p "/code-review" --yolo -e code-review - 分支/提交差异:将结果通过管道传递给
git diffgemini -p - 安全扩展名称为(而非
gemini-cli-security)security - 仅支持交互式使用 — 改用带安全提示的
/security:analyze参数-p - 选择安全审查重点时,额外运行
/security:scan-deps - 在Bash调用中设置
timeout: 600000
git diff| 范围 | 差异命令 |
|---|---|
| 未提交更改 | |
| 分支差异 | |
| 特定提交 | |
Running Both
同时运行两个工具
When the user picks "Both" (the default):
- Run Codex and Gemini in parallel — issue both Bash tool calls in a single response. Both commands are read-only (they review diffs via external APIs) so there is no shared state or git lock contention.
- Collect both results, then present with clear headers:
undefined当用户选择"两者都用"(默认选项)时:
- 并行运行Codex和Gemini — 在单个响应中发起两个Bash工具调用。两个命令均为只读操作(通过外部API审查差异),因此不存在共享状态或Git锁竞争问题。
- 收集两个结果后,使用清晰的标题展示:
undefinedCodex Review (gpt-5.3-codex)
Codex审查(gpt-5.3-codex)
<codex output>
<codex输出内容>
Gemini Review (gemini-3-pro-preview)
Gemini审查(gemini-3-pro-preview)
<gemini output>
```
Summarize where the two reviews agree and differ.
<gemini输出内容>
总结两个审查结果的一致和不同之处。Error Handling
错误处理
| Error | Action |
|---|---|
| Tell user: |
| Tell user: |
Gemini | Tell user: |
Gemini | Tell user: |
| Model auth error (Codex) | Retry with |
| Empty diff | Tell user there are no changes to review |
| Timeout | Inform user and suggest narrowing the diff scope |
| Tool partially unavailable | Run only the available tool, note the skip |
| 错误 | 操作 |
|---|---|
| 告知用户: |
| 告知用户: |
缺少Gemini | 告知用户: |
缺少Gemini | 告知用户: |
| Codex模型认证错误 | 使用 |
| 差异为空 | 告知用户没有可审查的更改 |
| 超时 | 告知用户并建议缩小差异范围 |
| 部分工具不可用 | 仅运行可用的工具,并说明跳过的原因 |
Examples
示例
Both tools (default):
User: /second-opinion
Claude: [asks 4 questions: tool, scope, context, focus]
User: picks "Both", "Branch diff", "Yes include CLAUDE.md", "Security"
Claude: [detects default branch = main]
Claude: [shows diff --stat: 6 files, +103 -15]
Claude: [runs Codex review with security prompt]
Claude: [runs Gemini review with security prompt + dep scan]
Claude: [presents both reviews, highlights agreements/differences]Codex only with inline args:
User: /second-opinion check uncommitted changes for bugs
Claude: [scope known: uncommitted, focus known: custom]
Claude: [asks 2 questions: tool, project context]
User: picks "Codex only", "No context"
Claude: [shows diff --stat: 3 files, +45 -10]
Claude: [runs codex review --uncommitted with prompt]
Claude: [presents review]Gemini only:
User: /second-opinion
Claude: [asks 4 questions]
User: picks "Gemini only", "Uncommitted", "No", "General"
Claude: [shows diff --stat: 2 files, +20 -5]
Claude: [runs gemini -p "/code-review" --yolo -e code-review]
Claude: [presents review]Large diff warning:
User: /second-opinion
Claude: [asks questions] → user picks "Both", "Uncommitted", "General"
Claude: [shows diff --stat: 45 files, +3200 -890]
Claude: "Large diff (3200+ lines). High-effort reasoning will be
slow. Proceed, or narrow the scope?"
User: "proceed"
Claude: [runs both reviews]同时使用两个工具(默认):
用户:/second-opinion
Claude:[询问4个问题:工具、范围、上下文、重点]
用户:选择“两者都用”、“分支差异”、“是,包含CLAUDE.md”、“安全”
Claude:[检测到默认分支 = main]
Claude:[展示diff --stat:6个文件,+103 -15]
Claude:[使用安全提示运行Codex审查]
Claude:[使用安全提示+依赖扫描运行Gemini审查]
Claude:[展示两个审查结果,突出一致和不同之处]仅使用Codex并附带内联参数:
用户:/second-opinion 检查未提交更改中的bug
Claude:[已知范围:未提交,已知重点:自定义]
Claude:[询问2个问题:工具、项目上下文]
用户:选择“仅使用Codex”、“不包含上下文”
Claude:[展示diff --stat:3个文件,+45 -10]
Claude:[使用自定义提示运行codex review --uncommitted]
Claude:[展示审查结果]仅使用Gemini:
用户:/second-opinion
Claude:[询问4个问题]
用户:选择“仅使用Gemini”、“未提交更改”、“否”、“通用”
Claude:[展示diff --stat:2个文件,+20 -5]
Claude:[运行gemini -p "/code-review" --yolo -e code-review]
Claude:[展示审查结果]大差异警告:
用户:/second-opinion
Claude:[询问问题] → 用户选择“两者都用”、“未提交更改”、“通用”
Claude:[展示diff --stat:45个文件,+3200 -890]
Claude:“差异过大(超过3200行)。深度推理会很慢。是否继续,或缩小范围?”
用户:“继续”
Claude:[运行两个审查]