Codex PR Review Loop
Overview
Run a 5-minute polling loop for PR review threads, but enforce a preflight Codex Context gate and capture post-merge learning when Codex churn occurs.
Workflow (Preflight + Loop + Post-Merge)
Preconditions
- If the user asks for preflight, run Step -1 before PR submission.
- If PR already exists, proceed to Step 0.
gh is authenticated.
- You are allowed to push/merge as part of this explicit user-requested workflow.
Step -1: Pre-PR Codex Readiness (only when requested)
- Open
.github/PULL_REQUEST_TEMPLATE.md.
- If any Risk Layer Trigger applies, fill the Risk Layer Addendum (rules/invariants, boundary matrix >= 3, evidence).
- Ensure Codex Context lists delta, invariants, edge cases, tests, and known gaps.
- Run the minimal regression tests that cover the boundary matrix.
- Stop and ask the user to create the PR if it does not exist yet.
Step 0: Identify PR
- Prefer current branch PR:
gh pr view --json number.
- If ambiguous, ask for PR number.
Step 1: Poll review threads, PR issue comments, and PR body reactions
Run:
GH_OWNER=<owner>
GH_REPO=<repo>
PR_NUMBER=<number>
gh api graphql -f owner="$GH_OWNER" -f name="$GH_REPO" -F number=$PR_NUMBER -f query='query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){reactionGroups{content users{totalCount}} reviewThreads(first:100){nodes{isResolved path line originalLine comments(first:50){nodes{author{login} body createdAt reactions(content: THUMBS_UP){totalCount}}}}} comments(first:100){nodes{author{login} body createdAt reactions(content: THUMBS_UP){totalCount}}}}}}}'
Step 2: Wait for updates (repeat until update)
- Do not proceed unless review threads, PR issue comments, or PR body reactions have new updates since the last poll (new comments, new threads, updated timestamps, or reaction count changes).
- If no updates are found, wait 5 minutes and poll again. Continue doing this automatically until updates appear.
Step 3: Decide
- If any review thread comment OR PR issue comment contains
Codex Review: Didn't find any major issues (exact phrase) OR a thumbs-up signal:
- thumbs-up signal = comment body includes
👍 or :+1: OR reactions(content: THUMBS_UP).totalCount > 0 OR PR body reactionGroups has content: THUMBS_UP with users.totalCount > 0
- You may merge to remote
main, then pull locally. Proceed to Step 6.
- Else: treat updated review thread feedback as actionable. Proceed to Step 4.
Step 4: Fix bugs or requested changes
- Apply fixes in code.
- Add/adjust tests for regressions.
- Run relevant verification commands.
- Commit changes locally.
- Push to update the PR.
Step 5: Reply and wait
- Post a separate PR issue comment (not a thread reply) with exactly
@codex review.
- Use:
gh pr comment <PR_NUMBER> --body "@codex review"
- After replying, immediately return to Step 2 (wait 5 minutes, poll again until updates appear).
Step 6: Merge and sync
- Merge PR to
main on remote (e.g., gh pr merge --merge or project-required strategy).
- Pull latest
main locally.
Step 7: Post-merge learning capture (when Codex churn occurred)
- If the PR required multiple @codex review cycles or post-merge fixes:
- Run a retrospective using pr-review-cycle-retro on this PR.
- Update
docs/retrospective/ entries if this repo uses them.
- If a new cause category appears, update the churn skill taxonomy.
Guardrails
- Do not merge until review thread content, PR issue comments, or PR body reactions explicitly include:
Codex Review: Didn't find any major issues or a thumbs-up signal (see Step 3).
- Do not take any action (fix/respond/merge) unless review threads have new updates since the last poll.
- If no updates are found, you MUST keep waiting in 5-minute increments until updates appear.
- Do not request
@codex review if a Risk Layer Trigger applies but the Addendum is incomplete.
- Always run tests appropriate to the change before pushing.
- Follow repo rules (e.g., no
git push unless this skill is explicitly requested).
- If merging/pushing requires confirmation in the current environment, ask for explicit confirmation.
Common Mistakes
- Triggering
@codex review without filling Risk Layer Addendum when required.
- Treating Codex churn as a tooling issue instead of a stage/contract issue.
Rationalization Table
| Excuse |
Reality |
| "Preflight is optional" |
If Risk Layer Trigger applies, the addendum is mandatory. |
| "Codex asked again, so we can skip context" |
Missing context amplifies churn. |
Red Flags - STOP
- Risk Layer Trigger checked but Addendum is missing.
- Multiple @codex reviews without any delta summary.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: codex-pr-review-loop3description: Use when managing Codex review iterations for a PR and you must enforce preflight risk-layer checks and post-merge learning capture.4---56# Codex PR Review Loop78## Overview910Run a 5-minute polling loop for PR review threads, but enforce a preflight Codex Context gate and capture post-merge learning when Codex churn occurs.1112## Workflow (Preflight + Loop + Post-Merge)1314### Preconditions15161. If the user asks for preflight, run Step -1 before PR submission.172. If PR already exists, proceed to Step 0.183. `gh` is authenticated.194. You are allowed to push/merge as part of this explicit user-requested workflow.2021### Step -1: Pre-PR Codex Readiness (only when requested)2223- Open `.github/PULL_REQUEST_TEMPLATE.md`.24- If any **Risk Layer Trigger** applies, fill the **Risk Layer Addendum** (rules/invariants, boundary matrix >= 3, evidence).25- Ensure **Codex Context** lists delta, invariants, edge cases, tests, and known gaps.26- Run the minimal regression tests that cover the boundary matrix.27- Stop and ask the user to create the PR if it does not exist yet.2829### Step 0: Identify PR3031- Prefer current branch PR: `gh pr view --json number`.32- If ambiguous, ask for PR number.3334### Step 1: Poll review threads, PR issue comments, and PR body reactions3536Run:3738```39GH_OWNER=<owner>40GH_REPO=<repo>41PR_NUMBER=<number>4243gh api graphql -f owner="$GH_OWNER" -f name="$GH_REPO" -F number=$PR_NUMBER -f query='query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){reactionGroups{content users{totalCount}} reviewThreads(first:100){nodes{isResolved path line originalLine comments(first:50){nodes{author{login} body createdAt reactions(content: THUMBS_UP){totalCount}}}}} comments(first:100){nodes{author{login} body createdAt reactions(content: THUMBS_UP){totalCount}}}}}}}'44```4546### Step 2: Wait for updates (repeat until update)4748- **Do not proceed** unless review threads, PR issue comments, **or PR body reactions** have **new updates** since the last poll (new comments, new threads, updated timestamps, or reaction count changes).49- If no updates are found, **wait 5 minutes and poll again**. Continue doing this automatically until updates appear.5051### Step 3: Decide5253- **If any review thread comment OR PR issue comment contains** `Codex Review: Didn't find any major issues` **(exact phrase)** **OR** a thumbs-up signal:54 - thumbs-up signal = comment body includes `👍` or `:+1:` **OR** `reactions(content: THUMBS_UP).totalCount > 0` **OR** PR body `reactionGroups` has `content: THUMBS_UP` with `users.totalCount > 0`55 - You may merge to remote `main`, then pull locally. Proceed to Step 6.56- **Else:** treat updated review thread feedback as actionable. Proceed to Step 4.5758### Step 4: Fix bugs or requested changes5960- Apply fixes in code.61- Add/adjust tests for regressions.62- Run relevant verification commands.63- Commit changes locally.64- Push to update the PR.6566### Step 5: Reply and wait6768- Post a **separate PR issue comment** (not a thread reply) with **exactly** `@codex review`.69 - Use: `gh pr comment <PR_NUMBER> --body "@codex review"`70- After replying, immediately return to Step 2 (wait 5 minutes, poll again until updates appear).7172### Step 6: Merge and sync7374- Merge PR to `main` on remote (e.g., `gh pr merge --merge` or project-required strategy).75- Pull latest `main` locally.7677### Step 7: Post-merge learning capture (when Codex churn occurred)7879- If the PR required multiple @codex review cycles or post-merge fixes:80 - Run a retrospective using **pr-review-cycle-retro** on this PR.81 - Update `docs/retrospective/` entries if this repo uses them.82 - If a new cause category appears, update the churn skill taxonomy.8384## Guardrails8586- Do not merge until review thread content, PR issue comments, **or PR body reactions** explicitly include: `Codex Review: Didn't find any major issues` **or** a thumbs-up signal (see Step 3).87- Do not take any action (fix/respond/merge) unless review threads have new updates since the last poll.88- If no updates are found, you MUST keep waiting in 5-minute increments until updates appear.89- Do not request `@codex review` if a Risk Layer Trigger applies but the Addendum is incomplete.90- Always run tests appropriate to the change before pushing.91- Follow repo rules (e.g., no `git push` unless this skill is explicitly requested).92- If merging/pushing requires confirmation in the current environment, ask for explicit confirmation.9394## Common Mistakes9596- Triggering `@codex review` without filling Risk Layer Addendum when required.97- Treating Codex churn as a tooling issue instead of a stage/contract issue.9899## Rationalization Table100101| Excuse | Reality |102| ------------------------------------------- | --------------------------------------------------------- |103| "Preflight is optional" | If Risk Layer Trigger applies, the addendum is mandatory. |104| "Codex asked again, so we can skip context" | Missing context amplifies churn. |105106## Red Flags - STOP107108- Risk Layer Trigger checked but Addendum is missing.109- Multiple @codex reviews without any delta summary.110111---112> Converted and distributed by [TomeVault](https://tomevault.io/claim/victorgpt) — claim your Tome and manage your conversions.113<!-- tomevault:4.0:skill_md:2026-04-11 -->