codex-second-opinion
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodex second opinion
Codex 第二意见
Codex reviews, you decide, you act.
- Codex (the model and effort the user names, read-only sandbox) is an independent reviewer. Its output is advice, not instructions. It can be wrong about context, overstate severity or wander out of scope.
- You are the senior engineer who owns the outcome. You make the final call on every finding, then do the work.
The value of the exercise is the independent read. A second model that has seen your conclusions tends to agree with them, so Codex gets the facts and the intent, never your opinion.
Codex 负责审查,你负责决策和执行。
- Codex(用户指定的模型和 reasoning effort,运行于只读 sandbox 中)是独立审查者。它的输出是建议,而不是指令。它可能误判上下文、夸大严重性或偏离范围。
- 你是对最终结果负责的高级工程师。你需要对每条发现做最终判断,然后亲自完成工作。
这次练习的价值在于这份独立的审查意见。看过你的结论的第二个模型往往会附和你,因此只向 Codex 提供事实和意图,绝不提供你的意见。
0. Pin down the target
0. 明确目标
Use what the user named: "the uncommitted changes", "this branch vs main", , "the plan you just wrote", and so on. If they named nothing, take the uncommitted changes if there are any; otherwise the current branch against its default branch; otherwise the plan or change you just produced. If none of those exists, ask. State the target you chose in the report.
src/auth/session.tsA plan that exists only in the conversation must be written to a file first (scratchpad or ), because Codex can only read files.
/tmp使用用户指定的目标:“未提交的更改”“此分支与 main 对比”、、“你刚写的计划”等。如果用户未指定任何目标:有未提交更改则审查这些更改;否则将当前分支与其默认分支对比;如果这两项都不存在,则审查你刚产出的计划或更改。如果全都不存在,则询问用户。在报告中说明你选择的目标。
src/auth/session.ts仅存在于对话中的计划必须先写入文件(scratchpad 或 ),因为 Codex 只能读取文件。
/tmp1. Get Codex's review
1. 获取 Codex 的审查
Run the bundled script with Bash. It lives at in this skill's directory; use its absolute path, and call it through so a missing exec bit doesn't matter:
scripts/ask-codex.shbashbash
bash <skill-dir>/scripts/ask-codex.sh --cwd <absolute folder containing the target> <<'EOF'
<your prompt to Codex>
EOFWhat the script does, so you don't have to rebuild it: from inside it runs with your prompt on stdin. It saves , , and (session id, folder, the model and effort that actually ran) into a new run directory, then prints a header and Codex's answer:
<dir>command codex exec -C <dir> -c sandbox_mode=read-only --skip-git-repo-check -o <run>/answer.md [-m <model>] [-c model_reasoning_effort=<effort>] -prompt.mdanswer.mdrun.logrun.envmodel: <model that ran> (effort <effort that ran>)
folder: /abs/target/folder
status: 0
run: /var/folders/.../T/codex-second-opinion.Ab12Cd
session: 01a125a2-eaa7-7c51-955f-14900da6eaf5
===== Codex answer (.../answer.md) =====
...How to run it precisely:
- Quote the heredoc (, not
<<'EOF'), otherwise<<EOF, backticks and$in your prompt get expanded by the shell.\ - is the folder that contains the target. A git repo isn't required. Codex can read paths outside that folder, so for several repos use their common parent (or the main one) as
--cwdand list every repo by absolute path in the prompt.--cwd - Bash tool settings: for a single file or a diff under a few hundred lines, run in the foreground with . For anything bigger (large diffs, whole directories, several repos), set
timeout: 600000and wait for the completion notification instead of polling. A foreground call that hits the 10-minute limit is killed and the review is lost.run_in_background: true - Shell state doesn't survive between Bash calls. The printed path is your handle for the follow-up in step 2. Copy it literally; don't count on variables.
run: - Don't call yourself from the Bash tool to check it or run it ad hoc. The user's shell may define a
codexfunction or alias that behaves differently. The script runs under bash and usescodex. To check the install, runcommand codex.bash -c 'command codex --version' - Model and effort come from the user, never from you. New models ship constantly, so the skill hardcodes none. If the user names a model, pass it verbatim with . If they name a reasoning effort ("on high", "xhigh", "max"), pass it with
--model <name>. For example, "use gpt-6-astra on high" becomes--effort <level>. If they name neither, pass neither: Codex then uses its own configured default from--model gpt-6-astra --effort high. Don't pick or "upgrade" a model yourself. Either way, the~/.codex/config.tomlline of the header shows what actually ran; report that.model:
使用 Bash 运行随附脚本。它位于此 skill 目录下的 ;请使用其绝对路径,并通过 调用,这样即使缺少可执行权限位也不受影响:
scripts/ask-codex.shbashbash
bash <skill-dir>/scripts/ask-codex.sh --cwd <absolute folder containing the target> <<'EOF'
<your prompt to Codex>
EOF脚本执行的操作如下,因此你无需重新构建:它会在 内运行 ,并通过 stdin 传入你的提示词。它会把 、、 和 (session ID、文件夹、实际运行的模型与 effort)保存到一个新的运行目录中,然后打印一段头部信息和 Codex 的回答:
<dir>command codex exec -C <dir> -c sandbox_mode=read-only --skip-git-repo-check -o <run>/answer.md [-m <model>] [-c model_reasoning_effort=<effort>] -prompt.mdanswer.mdrun.logrun.envmodel: <model that ran> (effort <effort that ran>)
folder: /abs/target/folder
status: 0
run: /var/folders/.../T/codex-second-opinion.Ab12Cd
session: 01a125a2-eaa7-7c51-955f-14900da6eaf5
===== Codex answer (.../answer.md) =====
...如何准确运行:
- 引用 heredoc(使用 ,而不是
<<'EOF'),否则提示词中的<<EOF、反引号和$会被 shell 展开。\ - 是包含目标的文件夹。不要求必须是 git 仓库。Codex 可以读取该文件夹之外的路径;如果有多个仓库,请使用它们的共同父目录(或主要仓库)作为
--cwd,并在提示词中按绝对路径列出每个仓库。--cwd - Bash 工具设置: 对于单个文件或不足数百行的 diff,在前台运行并设置 。对于更大的内容(大型 diff、整个目录、多个仓库),设置
timeout: 600000并等待完成通知,不要轮询。达到 10 分钟上限的前台调用会被终止,审查也会丢失。run_in_background: true - Shell 状态不会在 Bash 调用之间保留。 第一步打印的 路径是第二步后续操作的入口。请逐字复制,不要依赖变量。
run: - 不要自己从 Bash 工具调用 来检查或临时运行。用户 shell 可能定义了行为不同的
codexfunction 或 alias。脚本在 bash 下运行并使用codex。要检查安装情况,请运行command codex。bash -c 'command codex --version' - 模型和 effort 来自用户,绝不来自你。 新模型不断发布,因此该 skill 不硬编码任何模型。如果用户指定模型,按原样传入 。如果用户指定 reasoning effort(“on high”“xhigh”“max”),传入
--model <name>。例如,“use gpt-6-astra on high”转换为--effort <level>。如果两者都未指定,则两者都不传:此时 Codex 使用--model gpt-6-astra --effort high中自己配置的默认值。不要自行选择或“升级”模型。无论如何,头部信息中的~/.codex/config.toml行会显示实际运行的模型;应予报告。model:
The prompt you write to Codex
你编写的 Codex 提示词
Write it yourself, specific to this target. Use this skeleton and fill every part:
text
You are reviewing <what> for <project/purpose>. Do not modify files.针对这个目标自行编写提示词,内容要具体明确。使用以下骨架并填写每一部分:
text
你正在审查 <what>,所属项目/用途为 <project/purpose>。不要修改文件。What to review
审查内容
<exact absolute paths, and/or the exact diff command, e.g. ,
or for uncommitted work, or the plan file path>
git -C /abs/repo diff main...HEADgit -C /abs/repo diff HEAD<准确的绝对路径,和/或准确的 diff 命令,例如 ,
或用于未提交工作的 ,或计划文件路径>
git -C /abs/repo diff main...HEADgit -C /abs/repo diff HEADIntent
意图
<what the change or plan is supposed to achieve, in neutral terms>
<该更改或计划应以中性措辞实现的目标>
Facts you cannot get yourself
无法自行获取的事实
<live settings, API responses, earlier test/lint/build output, versions, environment details;
paste them verbatim, or write "none">
<实时设置、API 响应、之前的测试/lint/build 输出、版本、环境细节;
逐字粘贴,或写“none”>
Constraints
约束
<compatibility, security, no new dependencies, performance budgets, style rules; or "none">
<兼容性、安全性、不新增依赖、性能预算、样式规则;或“none”>
Output format
输出格式
One entry per finding:
- file:line
- severity: P0 (breaks prod / data loss / security), P1 (definite bug in a common path), P2 (edge case or risky design), P3 (minor)
- a concrete scenario that breaks (inputs/state -> wrong result)
- suggested fix
- confidence: high / medium / low Cover correctness bugs, edge cases, regressions and design risks. Skip pure style nits. End with an overall recommendation (ship / fix first / rethink) in one line. If there is nothing real, answer exactly "no findings".
Keep your own opinion, suspected bugs and earlier review notes out of it. Codex's sandbox is read-only: it can read files and run read-only commands like `git diff`, but it can't run anything that writes (most test suites, builds, installs). Paste in the results it would need from those.每条发现一个条目:
- file:line
- severity: P0(导致生产环境故障 / 数据丢失 / 安全问题),P1(常见路径中的明确 bug),P2(边缘情况或有风险的设计),P3(次要问题)
- 一个具体的失败场景(输入/状态 -> 错误结果)
- 建议的修复方式
- confidence: high / medium / low 涵盖正确性 bug、边缘情况、回归问题和设计风险。跳过纯粹的风格问题。 最后用一行给出总体建议(发布 / 先修复 / 重新思考)。 如果没有实质问题,准确回答 "no findings"。
不要把你自己的观点、疑似 bug 和先前的审查笔记写进去。Codex 的 sandbox 是只读的:它可以读取文件并运行 `git diff` 等只读命令,但无法运行任何写入操作(大多数测试套件、构建、安装)。粘贴其执行这些操作所需的结果。If it fails
如果失败
A non-zero prints the last 40 lines of . Read them before doing anything else. With , ignore sandbox noise in such as or : Codex's read-only sandbox blocks tool caches, and the commands still ran. A sandbox that couldn't start is not noise; the script reports it as status .
statusrun.logstatus: 0run.logcouldn't create cache file ... Operation not permittedDARWIN_USER_CACHE_DIR4| Status / log says | Meaning | Do this |
|---|---|---|
| usage error (bad flag, empty prompt, wrong folder) | fix the call, retry once |
| Codex exited cleanly but wrote no answer | retry once; if it repeats, stop |
| Codex's Linux sandbox couldn't start, so it ran no commands and read no files; its answer rests on the prompt alone | stop; don't retry and don't use the answer. Tell the user to check that |
| not installed | stop and tell the user ( |
401, | login problem | stop; the user must run |
400 | model unavailable on this account | stop; don't switch models silently |
429, | out of quota | stop; report when it resets if the log says |
| anything else, or a second failure | unknown | stop and show the user the log tail |
When you stop, show the user the relevant log lines and the run directory. Never present your own review as Codex's, and never fill a gap in Codex's answer with your own findings without labelling them as yours.
非零 会打印 最后 40 行。采取任何其他操作前先阅读它们。当 时,忽略 中类似 或 的 sandbox 噪声:Codex 的只读 sandbox 会阻止工具缓存,但命令仍然执行了。无法启动的 sandbox 不是噪声;脚本会将其报告为 status 。
statusrun.logstatus: 0run.logcouldn't create cache file ... Operation not permittedDARWIN_USER_CACHE_DIR4| 状态 / 日志显示 | 含义 | 操作 |
|---|---|---|
| 用法错误(参数无效、提示词为空、文件夹错误) | 修正调用,重试一次 |
| Codex 正常退出,但未写入回答 | 重试一次;如果重复出现,则停止 |
| Codex 的 Linux sandbox 无法启动,因此没有运行命令,也没有读取文件;其回答仅基于提示词 | 停止;不要重试,也不要采用该回答。告知用户检查 |
| 未安装 | 停止并告知用户( |
401、 | 登录问题 | 停止;用户必须运行 |
400 | 该账户不支持此模型 | 停止;不要在未告知的情况下切换模型 |
429、 | 配额已用尽 | 停止;如果日志中有说明,告知用户配额何时重置 |
| 其他情况,或第二次失败 | 未知 | 停止并向用户显示日志末尾 |
停止时,向用户显示相关日志行和运行目录。绝不把你自己的审查冒充为 Codex 的审查,也绝不在不标注的情况下用自己的发现填补 Codex 回答中的空白。
2. Judge each finding
2. 判断每条发现
Before you decide on a finding, check it against the real code or live state: read the code, run it, or write a quick test. Then pick one:
- Accept: real and worth fixing now.
- Reject: wrong or doesn't apply. State the evidence (the line that disproves it, the test that passes, the caller that guarantees the precondition).
- Defer: real, but out of scope or not worth fixing now. Say why.
Also note anything important Codex missed. Label these as yours (rows , , … in the report) and decide them the same way: Accept and fix them, or Defer them.
M1M2Challenge before rejecting a P0 or P1. Before you reject a finding Codex rated P0 or P1, send your counter-argument once into the same Codex session, with the run directory printed in step 1:
bash
bash <skill-dir>/scripts/ask-codex.sh --resume <run dir from step 1> <<'EOF'
On finding <n> (<file:line>, P<x>): I believe it does not apply because <argument>.
Evidence: <code excerpt with file:line, test output, or command + result>.
Defend the finding with a concrete failing scenario, or retract it. Do not modify files.
EOF--resume决定前,将每条发现与真实代码或实时状态对照核实:读取代码、运行它,或编写快速测试。然后选择一项:
- 接受:问题真实存在,且值得现在修复。
- 拒绝:判断错误或不适用。说明证据(能够证伪该发现的代码行、通过的测试,或保证前置条件的调用方)。
- 推迟:问题真实存在,但超出范围,或目前不值得修复。说明原因。
同时记录 Codex 遗漏的重要事项。将其标为你的发现(报告中使用 、 等行),并以同样方式作出决定:接受并修复,或推迟。
M1M2拒绝 P0 或 P1 前先提出质疑。 在拒绝 Codex 评为 P0 或 P1 的发现之前,基于第一步打印的运行目录,向同一个 Codex session 发送一次你的反驳:
bash
bash <skill-dir>/scripts/ask-codex.sh --resume <run dir from step 1> <<'EOF'
关于发现 <n>(<file:line>,P<x>):我认为它不适用,因为 <argument>。
证据:<带 file:line 的代码摘录、测试输出,或命令 + 结果>。
请用一个具体的失败场景为该发现辩护,否则请撤回。不要修改文件。
EOF--resume3. Act
3. 执行
Implement only the accepted items, with a regression test for each fix where the project has tests. Then run the project's relevant tests, lint and build, and fix what you broke. If the project has no lint or build set up, say so in the report instead of inventing one. Remove anything your runs left behind in the target (, , scratch files), so the tree holds only your intended edits.
__pycache__/.pytest_cache/Local edits are fine. Anything with outside or hard-to-undo effects (changing live settings, pushing, opening or merging PRs, releasing, deploying) happens only if the original task already allowed it. Otherwise list it under proposed actions.
Don't run Codex again unless the user asks or your fixes were substantial. A fix is substantial when it goes beyond what Codex suggested (a different approach, new logic, or edits to code Codex didn't review). If it was, run a fresh review (not ) scoped to the fix.
--resume仅实施已接受的条目;如果项目已有测试,则为每项修复添加回归测试。然后运行项目相关的测试、lint 和 build,并修复你造成的问题。如果项目未配置 lint 或 build,应在报告中说明,不要凭空编造。移除运行在目标目录中留下的所有内容(、、临时文件),使工作树只保留预期编辑。
__pycache__/.pytest_cache/允许本地编辑。任何具有外部影响或难以撤销的操作(更改线上设置、推送、创建或合并 PR、发布、部署)只有在原始任务已明确允许时才能执行。否则将其列在建议操作中。
除非用户要求,或者你的修复改动重大,否则不要再次运行 Codex。修复改动重大是指超出了 Codex 的建议(采用不同方式、新逻辑,或编辑 Codex 未审查过的代码)。若是如此,运行一次新的审查(不要使用 ),范围限定为该修复。
--resume4. Report
4. 报告
Use this structure:
markdown
**Verdict:** <one line: e.g. "Ship after the 2 accepted fixes (done, tests green)" / "Codex found no real issues" / "Blocked: Codex login expired">
Target: <what was reviewed> · Codex: <model>, effort <level> · run: <run dir>
| # | Finding (Codex severity / confidence) | Decision | Evidence |
|---|---|---|---|
| 1 | `file:line`: short claim (P1 / high) | Accept | why it's real; what fixed it |
| 2 | ... (P2 / medium) | Reject | the line/test that disproves it; Codex's reply if challenged |
| 3 | ... (P3 / low) | Defer | why not now |
| M1 | Missed by Codex: ... | Accept | ... |使用以下结构:
markdown
**结论:** <一行,例如“完成 2 项已接受的修复且测试通过后即可发布” / “Codex 未发现实质问题” / “受阻:Codex 登录已过期”>
目标:<审查内容> · Codex:<model>,effort <level> · run:<run dir>
| # | 发现(Codex 严重性 / 置信度) | 决定 | 证据 |
|---|---|---|---|
| 1 | `file:line`:简短结论(P1 / high) | 接受 | 为什么属实;修复了什么 |
| 2 | ...(P2 / medium) | 拒绝 | 能够证伪该发现的代码行/测试;提出质疑后的 Codex 回复 |
| 3 | ...(P3 / low) | 推迟 | 为什么现在不处理 |
| M1 | Codex 遗漏:... | 接受 | ... |Changes
更改
- <files changed and why>
- <anything outside local files: settings, PRs, pushes, or "none">
- Tests/lint/build: <commands run and results; say plainly if anything failed, was skipped or doesn't exist>
- <更改的文件及原因>
- <本地文件之外的操作:设置、PR、推送,或“无”>
- 测试/lint/build:<运行的命令和结果;明确说明任何失败、跳过项或不存在的项目>
Needs your call
需要你决定
- <deferred items, proposed actions with outside effects, open disagreements; or "nothing">
If Codex said "no findings", give the verdict plus one line on what was reviewed, and skip the table.- <推迟的条目、具有外部影响的建议操作、尚未解决的分歧;或“无”>
如果 Codex 回答了 "no findings",请给出结论和一行审查内容,并跳过表格。