From github-devex
Automate Codex code review on GitHub PRs with full fix-and-iterate loops. Use this whenever you need to request Codex review for a PR and have it automatically poll for feedback, apply fixes, commit changes, and iterate until completion. Mention this for requests like "request codex review for PR
How this skill is triggered — by the user, by Claude, or both
Slash command
/github-devex:request-codex-reviewThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Fully automate Codex code review polling, feedback detection, fix application, and iteration until completion.
Fully automate Codex code review polling, feedback detection, fix application, and iteration until completion.
When you ask for Codex review on a PR, you need to provide:
owner)my-repo)42)Or just ask: "codex review for PR #42" and infer from git context if in a repo.
The skill will then automatically:
Before using this skill, ensure:
gh) is authenticated: gh auth status<your-test-command>, <your-lint-command>, etc.)Your role: Provide owner/repo/PR number (or ask to infer from git)
Claude's role:
.codex/codex-review-loop-state-pr<PR>.json# Locate the bundled orchestration script from the plugin install cache
ORCHESTRATE_SCRIPT=$(find ~/.claude/plugins -name "orchestrate_codex_review.py" 2>/dev/null | head -1)
python3 "$ORCHESTRATE_SCRIPT" \
<owner> <repo> <pr> \
.codex/codex-review-loop-state-pr<pr>.json \
--once
status field:
needs_action → Go to Phase 2waiting → Wait 3 minutes, return to step 3completed → Go to Phase 4error → Report error and exitWhen Codex posts new comments (status: needs_action)
Claude's role:
new_comments array from the responseid — needed to reply directly to this comment threadsource — "review_comment" (line-level) or "issue_comment" (top-level)body (the Codex feedback text)Example Codex comment:
File: src/worker/provision-processor.ts
Lines: 295-310
Missing error handling in applyBdReferralCredit. The findUnique and updateMany
calls execute before the try/catch, so a transient DB error here escapes
the function and can fail the provisioning job.
Suggested fix: Wrap entire function body in try/catch with referralId
tracking outside the try block.
Claude extracts:
src/worker/provision-processor.ts295-310For each Codex comment, Claude must:
# Read the flagged file
cat src/worker/provision-processor.ts
Locate the exact lines mentioned by Codex. If line numbers are off, search for the function/code block mentioned.
Before writing fixes, understand:
Make the code change directly. Examples:
Example 1: Add error handling
// BEFORE (Codex flagged this)
async function applyBdReferralCredit(...) {
const referral = await prisma.bdReferral.findUnique(...); // Can throw!
// ... rest of function
}
// AFTER (Your fix)
let referralId = null;
try {
const referral = await prisma.bdReferral.findUnique(...);
if (!referral) return;
// ... rest of function
referralId = referral.id;
} catch (error) {
console.error("Credit grant failed:", error);
if (referralId) {
await prisma.bdReferral.updateMany(...).catch(() => {});
}
}
Example 2: Use advisory lock for serialization
// BEFORE (Codex flagged concurrent write race condition)
const currentLimit = await getProvisionedKeyByHash({ keyId });
await updateProvisionedKeyLimit({ keyId, limit: currentLimit + 3 });
// AFTER (Your fix)
await runSerializableTransactionWithRetries(async (tx) => {
await tx.$executeRaw`SELECT pg_advisory_xact_lock(hashtext(${keyId}))`;
const keyDetails = await getProvisionedKeyByHash({ keyId });
await updateProvisionedKeyLimit({ keyId, limit: keyDetails.limit + 3 });
});
Example 3: Defer operation until after guard check
// BEFORE (Codex flagged phantom records on rollback)
const bdFirstPaymentAmountCents = billingObject.amount_paid ?? 0;
if (billingReason === "subscription_create" && bdPartnerMetadata?.bdPartnerId) {
await createBdCommissionForFirstPayment(...); // Created before capacity check!
}
const provisioningResult = await createOrEnqueueProvisioningJob(...);
if (provisioningResult.kind === "capacity_blocked") {
await rollbackCapacityBlockedSubscription(...); // But subscription rolled back!
}
// AFTER (Your fix)
const bdFirstPaymentAmountCents = billingObject.amount_paid ?? 0;
const provisioningResult = await createOrEnqueueProvisioningJob(...);
if (provisioningResult.kind === "capacity_blocked") {
await rollbackCapacityBlockedSubscription(...);
return NextResponse.json({ received: true }); // Early return, skip commission
}
// Only create commission after capacity guard passes
if (billingReason === "subscription_create" && bdPartnerMetadata?.bdPartnerId) {
await createBdCommissionForFirstPayment(...);
}
Run project verification commands:
Before starting the loop: detect the project's verification commands from
package.jsonscripts (look for keys liketest,test:unit,lint), or ask the user which commands to run.
# Detect and run your project's test suite.
# Auto-detect from package.json scripts, or ask the user.
# Examples: npm run test:unit, npm test, pytest, go test ./...
<your-test-command>
# Detect and run your project's linter.
# Examples: npm run lint, flake8, golangci-lint run
<your-lint-command>
All must pass. If they don't:
Use the /commit skill to create a descriptive commit:
Commit message format:
<type>(<scope>): <subject>
<body - explain the fix>
Addresses Codex review feedback on <file>:<lines>
Example:
/commit
fix(provision): guard BD credit errors from failing provisioning
- Wrap entire applyBdReferralCredit body in try/catch so transient DB
errors in findUnique/updateMany don't escape and deprovision a running
instance. referralId is tracked outside the try block so the APPLYING
→ FAILED rollback still works when the error fires after the claim.
Addresses Codex review feedback on src/worker/provision-processor.ts:295-310
Immediately after committing, reply directly to this specific Codex comment thread — before moving to the next comment. Use the comment's id and source from Phase 2:
If source == "review_comment" (line-level):
gh api repos/{owner}/{repo}/pulls/{pr}/comments/{comment_id}/replies \
--method POST \
--field body="@codex I've applied the fix you suggested:
- [File]: <file>
- [Change]: <description of fix>
- [Verification]: <your-test-command> ✅ passed"
If source == "issue_comment" (top-level — no thread reply API):
gh api repos/{owner}/{repo}/issues/{pr}/comments \
--method POST \
--field body="@codex I've applied the fix you suggested (in reply to your comment <comment_url>):
- [File]: <file>
- [Change]: <description of fix>
- [Verification]: <your-test-command> ✅ passed"
When there are multiple Codex comments in the same round, repeat steps 3a–3f for each comment individually — apply fix, verify, commit, then reply to that specific comment's thread before moving to the next.
After all comments are processed, push all commits at once:
git push
Since each Codex comment already has an individual reply (Step 3f), post a single top-level PR comment to trigger the next review pass:
gh pr comment {pr} --repo {owner}/{repo} --body "@codex, please review again.
I've addressed all feedback from this review pass. Please perform
another code quality pass on the updated code."
This asks Codex to perform another full review.
When polling returns status: completed:
Output:
Completed the code quality guardrail workflow.
Summary:
- Total review cycles: <N>
- Issues found and fixed: <count>
- All Codex feedback addressed ✅
If Codex posts one comment with 3 issues:
Don't commit after each individual fix.
If Codex mentions lines that don't exist or reference outdated code:
Codex will clarify if your interpretation was wrong.
If <your-test-command> or <your-lint-command> fails after your fix:
Repeat as needed until all tests pass before requesting re-review.
It's normal for Codex to ask for refinements:
This continues until Codex is satisfied.
If polling returns waiting for more than 10 minutes and you suspect something is wrong:
.codex/codex-review-loop-state-pr<PR>.jsonstatus fieldneeds_action but you've already applied those fixes, manually comment: @codex, please review again. and continue pollingerror, check PR comments to see if there's a Codex error message✅ Do:
❌ Don't:
You ask:
Request codex review for PR #42 in owner/my-repo
Claude automatically does:
Polling cycle 1 (Phase 1)
Extract feedback (Phase 2)
processPayment (line 87)"updateBalance (line 134)"Apply fix #1 (Phase 3 — Comment 1)
src/payments/processor.ts:87fix: guard processPayment errors from propagatingApply fix #2 (Phase 3 — Comment 2)
src/balances/updater.ts:134fix: serialize balance updates to prevent race conditionRequest re-review (Phase 4)
@codex, please review again.Wait & poll (Phase 5)
Report completion (Phase 6)
Completed the code quality guardrail workflow.All without manual intervention after the initial request!
Before requesting Codex review, verify:
gh auth status shows you're logged ingit branch --show-currentgit status<your-test-command><your-lint-command>find ~/.claude/plugins -name "check_codex_review_state.py" | head -1If any fail, fix them first before requesting Codex review.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub jchen0824/claude-code-plugins --plugin github-devex