SuperAPI AI Directory

codex-review

Coding & development

View repository

Updated 10-16 09:52

About this skill

Codex Review

Cross-model adversarial review. Claude produces → Codex read-only review → VERDICT loop → structured issues list.

Positioning: Use Codex to review Claude's output (automatic loop, cross-source adversarial, default gpt-5.4, can be --model switched). Complementary to plan-review / code-review—those two are Claude same-model interactive reviews, this one is a cross-model automatic review.


Step 0: Detect input + confirm

Parse arguments

Extract from ARGUMENTS --model <model-id>(if any), the remaining part serves as the review target path.

  • CODEX_MODEL = the user-specified model-id, default gpt-5.4
  • Example:/codex-review diff --model o4-mini → review diff, using o4-mini

Detect review mode

Based on ARGUMENTS (after removing --model the part) and file characteristics, determine:

Plan mode(plan review):

  1. ARGUMENTS specifies .md and the content contains # Plan: or ## Overview → plan
  2. codex-plan.md(current directory) exists → plan
  3. .claude/plans/ latest .md → plan

Code mode(code review):

  1. ARGUMENTS is a file path (not .md plan) → code
  2. ARGUMENTS is a PR number (e.g., #123)→ gh pr diff 123
  3. ARGUMENTS is diff or blank → git diff + git diff --staged

After detection, summarize the review target (1-2 sentences), use AskUserQuestion to confirm the mode and focus scope:

  • Comprehensive review(default): all dimensions
  • Focused review: security / concurrency / schema / performance (choose one)

Read context

  • Plan mode: read the plan + Target Files mentioned in the plan (read all)
  • Code mode: read the full content of changed files + key imported dependencies

Step 1: Prepare Codex Prompt

  1. Generate UUID (uuidgen or date +%s) for use in the filename
  2. From references/prompt-templates.md load the corresponding template (plan / code)
  3. Assemble the review target content + relevant source code + template into a complete prompt
  4. Write to /tmp/codex-review-input-${ID}.md

Prompt assembly structure:

[Template header — 角色 + 對抗立場 + 維度]
## 審查對象
[計畫全文 or diff/code 全文]
## 相關原始碼
[Target files 內容]
## 聚焦範圍
[全面 or 指定維度]
[Template footer — VERDICT 規則 + 輸出格式]

Step 2: VERDICT loop (core)

ROUND = 1
SESSION_ID = ""

while ROUND <= 3:
    if ROUND == 1:
        # 首輪:fresh exec,擷取 session ID
        codex exec --full-auto --skip-git-repo-check \
          -s read-only \
          -c model=${CODEX_MODEL} \
          -c model_reasoning_effort=xhigh \
          -c model_reasoning_summary=concise \
          --output-last-message /tmp/codex-review-${ID}-r${ROUND}.md \
          "$(cat /tmp/codex-review-input-${ID}.md)" \
          2>&1 | tee /tmp/codex-review-${ID}-stdout.txt

        從 stdout 擷取 session ID(格式:session ID 或類似標識)
        SESSION_ID = 擷取到的 ID

    else:
        # 後續輪:嘗試 resume 保持上下文
        # 注意:resume 不支援 -o flag,需從 stdout 擷取輸出
        嘗試:
            codex exec resume ${SESSION_ID} --full-auto \
              "$(cat /tmp/codex-review-input-${ID}.md)" \
              2>&1 | tee /tmp/codex-review-${ID}-r${ROUND}.md

        如果 resume 失敗(exit code != 0 或 session 不存在):
            # Fallback:fresh exec + Continuation template 注入上輪 context
            codex exec --full-auto --skip-git-repo-check \
              -s read-only \
              -c model=${CODEX_MODEL} \
              -c model_reasoning_effort=xhigh \
              -c model_reasoning_summary=concise \
              --output-last-message /tmp/codex-review-${ID}-r${ROUND}.md \
              "$(cat /tmp/codex-review-input-${ID}.md)"

    讀取輸出,解析 VERDICT:
        APPROVED → break,進 Step 3
        REVISE → 見下方處理

    如果 REVISE 且 ROUND < 3:
        1. 擷取 Codex 發現的 issues
        2. Claude 撰寫修訂回應(描述如何修改,不實際改 code)
        3. 從 references/prompt-templates.md 載入 Continuation template
        4. 組裝下輪 prompt:上輪 issues + Claude 修訂回應 + 要求驗證
        5. 寫入 /tmp/codex-review-input-${ID}.md(覆蓋)

    ROUND++

如果 3 輪後仍 REVISE → 標記為「未收斂」,列出所有未解決 issues

VERDICT decision rules(executed by Codex in the template):

  • APPROVED = 0 HIGH + at most 1 MEDIUM
  • REVISE = any HIGH or 2+ MEDIUM

Codex exec parameter description:

  • -s read-only: read-only sandbox, Codex will not modify files
  • model_reasoning_effort=xhigh: highest reasoning quality
  • ${CODEX_MODEL}: use the model parsed in Step 0 (default gpt-5.4)
  • Round 1 fresh exec → capture session ID
  • Round 2+ try codex exec resume to maintain cross-round context; on failure, fall back to fresh exec + Continuation template

Step 3: Organize results

APPROVED (passed on the first round)

Simplified output:

## Codex Review: LGTM

**跨模型確認** — Codex (${CODEX_MODEL}) 未發現重大問題。

| 輪次 | VERDICT | HIGH | MEDIUM | LOW |
|------|---------|------|--------|-----|
| 1    | APPROVED | 0   | 0      | 2   |

### 低風險備註
- LOW: [描述]

APPROVED (passed after multiple rounds) or REVISE (not converged)

Full output:

## Codex Review 摘要

| 輪次 | VERDICT | HIGH | MEDIUM | LOW |
|------|---------|------|--------|-----|
| 1    | REVISE  | 2    | 1      | 3   |
| 2    | REVISE  | 0    | 2      | 1   |
| 3    | APPROVED | 0   | 1      | 0   |

### Issues(按嚴重度排序)

#### HIGH
- **[H1] Auth bypass in /api/users** — `src/auth.ts:42`
  Round 1 發現,Round 2 已解決

#### MEDIUM
- **[M1] Missing input validation** — `src/handlers/create.ts:15`
  Round 1 發現,Round 3 降級為 LOW

#### LOW
- **[L1] Inconsistent error format** — `src/errors.ts:8`

### 建議行動
- [ ] `src/auth.ts:42` — 加入 token 驗證(H1)
- [ ] `src/handlers/create.ts:15` — 加入 zod schema 驗證(M1)

Non-convergence handling

If it is still REVISE after 3 rounds, mark "not converged" in the summary table, list all issues that are still HIGH/MEDIUM, and recommend that the user handle them manually.

Clean up temporary files

After the review ends (regardless of the result), clean up all temporary files:

rm -f /tmp/codex-review-input-${ID}.md /tmp/codex-review-${ID}-r*.md /tmp/codex-review-${ID}-stdout.txt

Relationship with existing skills

Skill Reviewer Mode Purpose
plan-review Claude Interactive Claude reviews the plan, human in the loop
code-review Claude Interactive Claude reviews the code, human in the loop
codex-review Codex Automatic loop Cross-source adversarial review

Recommended order of use:

  1. /codex-plan Generate plan
  2. /codex-review Cross-model review plan
  3. Implement code
  4. /codex-review diff Cross-model review code
  5. /code-review Claude interactive detailed review

Now Execute

The user's review request is shown below ARGUMENTS:. Start from Step 0.