Runs Codex CLI peer review against the current branch via a PR URL, generates a structured markdown report classifying each finding as "Real issue (fix)" or "Not a real issue", and offers to apply fixes. Supports autonomous mode for auto-fixing. Use when the user asks for a codex review, codex code review, AI peer review of their branch, or wants a second opinion from Codex on their changes. Takes a GitHub PR URL as input.
Run OpenAI Codex CLI peer review against the current branch using a GitHub PR URL to derive the target branch and ticket name. Produce a structured markdown report with actionable determinations. Optionally fix issues and git stash the report.
| Mode | Trigger | Behavior |
|---|---|---|
| Interactive (default) | User provides a PR URL without saying "autonomous" | Generates report, asks before fixing |
| Autonomous | User says "autonomous", "auto-fix", or "auto mode" | Fixes all "Real issue / Fix" items, commits, pushes, git stashes report |
Determine the mode from the user's message. If unclear, default to Interactive.
dynamic-app/pr-reviews/ before applying any fixes/codex-peer-review command — do NOT call codex CLI directlyExtract owner, repo, and pr_number from the input URL.
Supported formats:
https://github.com/{owner}/{repo}/pull/{number}{owner}/{repo}#{number}Fetch PR metadata:
gh pr view {number} --repo {owner}/{repo} --json title,number,url,headRefName,baseRefName,author
From the response, extract:
baseRefName — the PR's target branch (e.g., main). This is the base for the Codex review.headRefName — the PR's source branch (e.g., TRIDENT-822). This is the current branch.TICKET-123: or [TICKET-123]). Use this for naming the report file.Verify you are on the correct branch:
CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"
If CURRENT_BRANCH does not match headRefName, warn the user and ask if they want to continue.
Verify there are changes to review:
git diff {baseRefName}...HEAD --stat
If no changes, inform the user and stop.
Dispatch to the /codex-peer-review command with the target branch:
/codex-peer-review --base {baseRefName}
This runs the full Codex peer review workflow (via the codex-peer-reviewer subagent) against the PR's target branch and returns synthesized findings.
Capture the full Codex output for analysis.
Extract each distinct finding from the Codex output. For each finding, identify:
For each Codex finding:
Determination must be one of:
| Determination | Meaning |
|---|---|
| Not a real issue | Codex's concern is unfounded, already handled, or a style preference that doesn't match this project's conventions. |
| Real issue | The concern is valid. Assess size (S/M/L), risk (S/M/L), and recommend "Fix" or "Leave as is". |
Create a markdown file following the template in references/report-template.md.
File naming convention:
{TICKET-NUMBER}-CODEX-REVIEW-{ITERATION}.md
TRIDENT-822)1. If {TICKET}-CODEX-REVIEW-1.md exists in dynamic-app/pr-reviews/, use 2, and so onPR-{number}-CODEX-REVIEW-{ITERATION}.mddynamic-app/pr-reviews/ (create the directory if it doesn't exist)After saving the report:
"I found {N} fixable issues. Would you like me to fix any of them?"
When the user requests fixes:
After fixes are applied (or if no fixes requested), git stash the report file:
git add dynamic-app/pr-reviews/{TICKET-NUMBER}-CODEX-REVIEW-*.md
git stash push -m "Codex review report: {TICKET-NUMBER}" -- dynamic-app/pr-reviews/
"Git stashed report. Retrieve with: git stash pop"When the user triggers autonomous mode, run Steps 1–5 first (parse PR URL, run Codex via /codex-peer-review --base {baseRefName}, parse findings, research, generate and save the report to dynamic-app/pr-reviews/). Then, instead of Steps 6–7, execute the following:
fix: address Codex review findings ({TICKET-NUMBER})
- {one-line summary of each fix}
Co-Authored-By: Claude Opus 4.6 <[email protected]>
git push origin {headRefName}
git add dynamic-app/pr-reviews/{TICKET-NUMBER}-CODEX-REVIEW-*.md
git stash push -m "Codex review report: {TICKET-NUMBER}" -- dynamic-app/pr-reviews/
"Git stashed report. Retrieve with: git stash pop"