Codex review loop

From Soju06/codex-lb · View interactive version

Codex review loop is an AI agent skill from the GitHub repository Soju06/codex-lb. Adversarial PR code review using Codex CLI. Codex review (~20-50 min) -> structured findings -> HITL approval -> fix loop.

How to use this skill

Skill file

Codex Review Loop

Adversarial code review via Codex CLI, structured finding analysis,

HITL-gated fix loop, optional re-verification.

Arguments

Phases

  1. Scope Resolution — determine review target (PR/branch/uncommitted)
  2. Codex Review — launch adversarial review via Codex CLI (~20-50 min)
  3. Finding Analysis — parse raw output into structured findings
  4. Atomic Fix Loop — fix, verify, commit each approved finding
  5. Re-review Loop — re-run review until 0 findings (max 3 iterations)
  6. Final Report — summary of all findings, fixes, and verification status

Phase 1: Scope Resolution

Determine the review target and extract the base branch.

and display PR metadata (title, file count, additions/deletions).

If no argument is given, auto-detect the user's most recent open PR and confirm.


Phase 2: Codex Review

Launch the adversarial review as a background process.

  1. Run the review script with run_in_background=true:

```

bash <skill-dir>/scripts/codex-subagent.sh --base <branch>

```

Note: Codex CLI v0.105.0+ does not support combining --base/--commit

with a custom prompt. The built-in review logic is used automatically.

For --uncommitted mode (no diff target), pipe stdin for custom instructions:

```

cat <prompt-file> | bash <skill-dir>/scripts/codex-subagent.sh --uncommitted

```

  1. Inform the user the review is running (~20-50 min).
  2. The script parses Codex output and returns the final review text. Review

rollouts intentionally remain persistent. If terminal output is lost, use

codex resume --include-non-interactive to locate the review, or

codex resume <SESSION_ID> when its ID is known. Do not add

--ephemeral to the wrapper. The wrapper also relies on the configured

non-interactive approval/sandbox policy because Codex CLI 0.147.0 removed

the historical --full-auto argument from exec review.

Error handling

| Exit code | Meaning | Action |

|-----------|---------|--------|

| 0 | Success | Proceed to Phase 3 |

| 1 | Codex error | Show error, offer retry or abort |

| 127 | codex not found | Guide: npm i -g @openai/codex |

Environment overrides

| Variable | Purpose |

|----------|---------|

| CODEX_REVIEW_MODEL | Override Codex model |

| CODEX_REVIEW_REASONING | Override reasoning effort |


Phase 3: Finding Analysis

Parse the raw Codex output into structured findings.

References

severity/category/effort enums, status lifecycle

project coding conventions to cross-reference

Severity escalation/downgrade guide

injection vectors, data integrity compromise

NoneType error, blocking I/O in async context

duplicate logic, unnecessary complexity

Convention-to-category mapping

Process

  1. Parse each finding from the raw output
  2. Assign severity and category using the schema definitions and guide above
  3. Cross-reference with project conventions
  4. Estimate fix effort
  5. Deduplicate (keep the most severe instance)
  6. Sort: severity desc, file path asc

HITL Gate 1: Finding Review

Present all findings to the user as a summary table

(ID, severity, category, file:line, title, effort).

Ask the user to choose a fix scope:


Phase 4: Atomic Fix Loop

For each approved finding, execute an atomic fix-verify-commit cycle.

Per finding:

  1. Fix: Read target file(s), apply the fix.
  2. HITL Gate 2 (conditional): For Critical/High findings that modify existing

logic (not just adding new code), show the current and proposed code to the

user for confirmation. Medium/Low findings are auto-fixed.

  1. Verify (all must pass):
  1. Commit: fix(review): P{i} - {title}
  2. On failure: Roll back changes, mark finding as skipped, continue to next.

Phase 5: Re-review Loop

After all fixes are committed, automatically re-run the Codex review

to check for regressions or new issues introduced by the fixes.

Loop behaviour

  1. Re-run Codex review (--base <branch>) against the same base.
  2. Parse findings (Phase 3) and present to user (HITL Gate 1).
  3. If 0 findings → loop terminates, proceed to Final Report.
  4. If findings exist → execute Phase 4 (fix-verify-commit), then repeat

from step 1.

Safety limits

After 3 iterations, terminate the loop regardless of remaining findings

and output the Final Report with unresolved items noted.

mark it as wont_fix and skip in subsequent iterations.

HITL override

At each re-review result, the user may choose:


Final Report

Output a summary including:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.