Automated GitHub Code Review
@codex review, P0/P1 findings, and review guidelines
- Enable Codex code review for a repository and explain why it requires Codex cloud to be set up first
- Distinguish the manual `@codex review` trigger from the Automatic reviews toggle and describe the eyes-emoji review flow
- Explain why Codex flags only P0/P1 issues in GitHub and use focused-review variants for a specific concern
- Use `@codex fix` follow-ups to push fixes to the branch and recognize that any other `@codex` mention starts a cloud task with PR context
- Steer review priorities through the `## Review guidelines` section of the closest AGENTS.md per changed file
- Decide when to use the chat-driven integration versus the `openai/codex-action` GitHub Action for CI-driven review
Codex can sit in your GitHub pull-request flow as an automated reviewer: enable it per repo, and it either reviews every new PR or waits for you to comment `@codex review`. It reacts with the eyes emoji, posts a standard GitHub review that surfaces only the critical P0/P1 issues, follows the `## Review guidelines` in the closest AGENTS.md to each changed file, and can push fixes back to the branch when you ask. This lesson wires it up end to end — toggles, triggers, focused variants, fix follow-ups, and the CI-driven GitHub Action.
- 1The mental model: a reviewer that lives on your PRs
- 2Enabling code review (it builds on Codex cloud)
- 3Triggering a review: the @codex review flow
- 4Why P0/P1 only — and how to focus a review
- 5Fix follow-ups and other @codex mentions
- 6Steering priorities with AGENTS.md review guidelines
- 7CI-driven review: the openai/codex-action
The mental model: a reviewer that lives on your PRs
Before any toggles, fix the mental model: Codex code review is the same cloud agent you already delegate tasks to — pointed at a pull request instead of a prompt box.
When you comment @codex review on a PR (or let it run automatically), GitHub hands the diff and PR context to a Codex cloud task. That task reads the changed files, applies your repo's review guidelines, reasons about what could break, and writes back a standard GitHub review — the same kind of review a human teammate posts, with inline comments anchored to specific lines.
Two things make this practical rather than noisy, and they're the heart of the lesson:
- It only speaks up when it matters. In GitHub, Codex flags only P0 and P1 issues — critical and high-priority. Lower-severity nitpicks are suppressed so the review stays signal, not noise.
- It follows your house rules. Codex reads the
## Review guidelinessection of the closestAGENTS.mdto each changed file, so the review reflects your standards, not generic advice.
Everything else — the enable toggles, focused variants, fix follow-ups, the CI Action — is plumbing around that one idea: a cloud reviewer, scoped to your PR, tuned by your AGENTS.md.
Key insight
One sentence to remember
@codex review turns a pull request into a cloud task that posts a real GitHub review — surfacing only P0/P1 issues and following the ## Review guidelines in the closest AGENTS.md to each changed file.
Enabling code review (it builds on Codex cloud)
Code review is not a separate product — it rides on the GitHub ↔ Codex cloud connection. So the prerequisite is: Codex cloud must already be set up for the repository (your GitHub account connected, repo access granted). Once that's true, enabling review is two toggles.
Steps:
- Set up Codex cloud for the repository (connect GitHub, grant repo access).
- Go to
chatgpt.com/codex/settings/code-review. - Toggle Code review ON for the target repo.
- (Optional) Toggle Automatic reviews ON in the same panel.
The two toggles do different jobs:
| Toggle | What it controls | Result |
|---|---|---|
| Code review | Whether Codex is allowed to review this repo at all | Lets you trigger reviews manually with @codex review |
| Automatic reviews | Whether Codex reviews every new PR without being asked | Codex reviews each new PR on its own — including as it moves draft → ready |
Think of Code review as the master switch (manual triggering on) and Automatic reviews as the "don't make me ask" upgrade. With Automatic reviews on, you get a review on every PR with no @codex mention needed; with only Code review on, you opt in per PR by commenting.
Watch out
No cloud, no review
If Codex cloud isn't set up for the repo, the code-review toggles have nothing to attach to. Connect GitHub and confirm Codex can see the repo first — code review is built on the same connection that lets @codex open PRs and run cloud tasks.
Tip
Settings move — check the live page
Exact panel labels and the plans that include Codex shift over time. Enable from chatgpt.com/codex/settings/code-review and confirm the current plan list at the Codex docs rather than trusting a screenshot.
Triggering a review: the @codex review flow
There are two ways a review fires — you ask, or it runs automatically.
Manual trigger. Comment @codex review on the pull request. Codex acknowledges by reacting to your comment with the 👀 (eyes) emoji, runs the review as a cloud task, then posts a standard GitHub review back on the PR. The eyes emoji is your signal that it's working — if you don't see it, the trigger didn't land (check the repo is enabled and Codex cloud is connected).
Automatic trigger. When Automatic reviews is enabled, you skip the comment entirely: Codex reviews every new PR as it's opened, and again as it moves from draft → ready, posting its analysis with no mention needed.
The review flow in both cases:
@codex review (or new PR, if automatic)
│
▼
Codex reacts with 👀 ──► cloud task reads the diff + PR context
│
▼
Applies ## Review guidelines from the closest AGENTS.md per file
│
▼
Posts a standard GitHub review ──► inline comments, P0/P1 onlyBecause the review is a cloud task, it runs in the background in its own sandbox — you don't block your terminal or IDE waiting for it, and several PRs can be reviewed in parallel.
Note
Draft → ready counts as a trigger
With Automatic reviews on, Codex doesn't just review at open — it re-engages when a PR transitions from draft to ready for review. That's the natural moment to ask for scrutiny, so it's wired in.
Why P0/P1 only — and how to focus a review
A reviewer that comments on everything gets muted. Codex avoids that by only flagging P0 and P1 issues in GitHub — the critical and high-priority problems — and suppressing lower-severity nitpicks. The goal is a review you actually read, where every comment is worth acting on.
| Priority | Roughly means | Shows up in GitHub review? |
|---|---|---|
| P0 | Critical — bugs, security holes, data loss, things that must not merge | Yes |
| P1 | High-priority — likely to cause real problems, should be fixed | Yes |
| P2 / lower | Style, minor nits, subjective preferences | Suppressed (kept out of the review) |
Focusing a review. Sometimes you want Codex to look hard at one dimension. Add the concern to the trigger as a one-off:
@codex review for security regressions@codex review for missing tests@codex review for outdated dependencies@codex review for risky behavior changes
The focused phrasing steers what Codex prioritizes for that single review without changing your repo's standing guidelines. Use it when a PR touches something sensitive (auth, payments, a dependency bump) and you want the review pointed straight at the risk.
Tip
Focused reviews are one-off, guidelines are standing
@codex review for security regressions tunes a single review. For priorities you want enforced on every PR, put them in the ## Review guidelines section of AGENTS.md (next section) instead of retyping the focus each time.
Fix follow-ups and other @codex mentions
A review that only points at problems is half the value. Codex can also fix what it flagged. After a review posts, comment a fix follow-up and Codex starts a cloud task that edits the code and pushes the fix to the PR branch:
@codex fix it— fix the flagged problem(s).@codex fix the P1 issue— target a specific flagged issue.@codex fix the CI failures— start a cloud task to make the build pass.
The key mental split:
| You comment | Codex does |
|---|---|
@codex review (or focused variant) | Reviews the diff, posts a GitHub review (P0/P1 only) |
@codex fix it / @codex fix the P1 issue | Fixes and pushes to the PR branch |
@codex fix the CI failures | Cloud task to repair the failing build |
Any other @codex … mention | Starts a cloud task using the PR context |
That last row is the general rule worth internalizing: review is the only special verb. Any other @codex mention on a PR or issue — @codex add a test for the edge case, @codex explain this regression — spins up an ordinary cloud task that already has the PR's diff and discussion as context. The reviewer and the task-runner are the same agent; you're just choosing what to ask it.
Watch out
Fixes go straight to the branch — review them
@codex fix it pushes commits to the PR branch. That's convenient, but the fix is still agent-written code: read the diff it pushes before merging, exactly as you would for a human's commit. Tight branch protections (required reviews, status checks) remain your safety net.
Steering priorities with AGENTS.md review guidelines
The single highest-leverage lever over review quality is AGENTS.md — Codex's cross-tool instructions file (the analogue of Claude Code's CLAUDE.md). Codex reads it across the repo and pays special attention to a section literally headed ## Review guidelines.
What to know:
- Codex applies the guidance from the closest
AGENTS.mdto each changed file. A nestedpackages/api/AGENTS.mdgoverns changes underpackages/api/, while the rootAGENTS.mdgoverns the rest. Package-level rules "just work" because the closest file wins per file. - The section is plain Markdown — short, concrete, imperative rules beat long vague essays.
Example root AGENTS.md:
## Review guidelines
- Don't log PII.
- Verify that authentication middleware wraps every route.
- Flag any new dependency that isn't pinned to an exact version.
- Require a test for every new public function.With those rules in place, a PR that adds an unpinned dependency or an unprotected route gets called out on every review — manual or automatic — without anyone retyping a focus. This is why standing priorities belong in ## Review guidelines, and one-off concerns belong in @codex review for ….
Example
Per-package guidelines in a monorepo
Put ## Review guidelines in packages/payments/AGENTS.md demanding idempotency keys and currency-rounding checks, and a separate set in packages/web/AGENTS.md about accessibility. Codex applies each to the files under its directory — the closest AGENTS.md per changed file — so a payments PR gets payments scrutiny and a web PR gets web scrutiny.
CI-driven review: the openai/codex-action
The @codex chat integration is the easy path, but it ties review to GitHub comments and the cloud connection. When you want review (or any Codex step) to run inside your own CI pipeline — gated by your workflow rules, your secrets, your triggers — there's a first-party GitHub Action: openai/codex-action@v1.
What it does: installs the Codex CLI and runs codex exec (the headless, non-interactive Codex) inside a workflow step, so you can post reviews, apply patches, or run repeatable checks as part of CI.
@codex review (chat integration) | openai/codex-action (CI) | |
|---|---|---|
| Where it runs | Codex cloud, triggered by a PR comment / new PR | Your CI runner, triggered by your workflow |
| Auth | Your connected ChatGPT/Codex account | OpenAI API key stored as a GitHub secret |
| Control | Toggles + AGENTS.md guidelines | Full workflow YAML: triggers, permissions, sandbox, model |
| Best for | Everyday PR review with minimal setup | Custom gates, patches, deterministic CI checks |
Key inputs include openai-api-key, prompt or prompt-file, model, effort, sandbox (workspace-write / read-only / danger-full-access), and safety-strategy (drop-sudo / unprivileged-user / unsafe). Because the Action runs with your API key on your runner, the security posture is on you:
- Keep
safety-strategy: drop-sudo(the default) — useunsafeonly where you must (e.g. Windows). - Restrict who/what can trigger the workflow and sanitize any prompt inputs (untrusted PR text is a prompt-injection vector).
- Pin
@v1(or a commit SHA) so a future release can't silently change behavior.
The two paths aren't mutually exclusive: many teams use @codex review for interactive PR feedback and the Action for a deterministic CI gate.
Watch out
The Action holds an API key — lock the trigger down
openai/codex-action runs with OPENAI_API_KEY on your runner. Limit who can start the workflow, prefer trusted events over arbitrary PR comments, keep drop-sudo, and treat PR-supplied text as untrusted input. Don't hand full access to code a stranger can trigger.
Try it: Wire up Codex review on a real pull request
Goal: experience the full review loop — enable, trigger, focus, fix, and tune. 1) Confirm prerequisites. Make sure Codex cloud is set up for a repo you administer (GitHub connected). 2) Enable. Go to chatgpt.com/codex/settings/code-review, toggle Code review ON for the repo; leave Automatic reviews OFF for now so you control the trigger. 3) Add guidelines. In the repo root, add a ## Review guidelines section to AGENTS.md with two concrete rules, e.g. "Don't log PII" and "Require a test for every new public function." Commit it. 4) Open a PR with a deliberate flaw. Create a branch that, say, adds a function with no test or logs a user email — something your guidelines should catch — and open a PR. 5) Trigger a review. Comment @codex review. Confirm Codex reacts with the 👀 emoji, then read the posted GitHub review — note that it flags P0/P1 issues and reflects your guideline. 6) Try a focused review. Comment @codex review for missing tests and compare how the emphasis shifts. 7) Ask for a fix. Comment @codex fix it (or @codex fix the P1 issue), wait for it to push to the branch, and read the pushed diff before deciding to merge. 8) (Optional) CI path. Skim github.com/openai/codex-action, add a minimal workflow that runs openai/codex-action@v1 with safety-strategy: drop-sudo, an OPENAI_API_KEY secret, and a pinned @v1. 9) Write three sentences: what the eyes emoji told you, how the AGENTS.md guideline changed the review, and one thing you'd put in ## Review guidelines versus a one-off @codex review for …. This builds the instinct that Codex review is a tunable teammate, not a black box.
Key takeaways
- 1Codex code review is the cloud agent pointed at a PR: enable it at chatgpt.com/codex/settings/code-review by toggling Code review per repo (Codex cloud must already be set up), and turn on Automatic reviews to review every new PR — including draft → ready.
- 2Manual trigger is `@codex review`: Codex reacts with the 👀 emoji, then posts a standard GitHub review. In GitHub it flags only P0/P1 (critical/high) issues and suppresses lower-severity noise.
- 3Focus a single review with variants like `@codex review for security regressions` (or missing tests, outdated dependencies, risky behavior changes) — one-off, without changing standing rules.
- 4`@codex fix it` / `@codex fix the P1 issue` push fixes to the PR branch, and `@codex fix the CI failures` repairs the build; any non-review `@codex` mention starts a cloud task using the PR context.
- 5Review priorities come from the `## Review guidelines` section of the closest AGENTS.md to each changed file, so per-package rules in a monorepo apply automatically.
- 6For CI-driven review and patches, use the `openai/codex-action@v1` GitHub Action (runs `codex exec` with an API-key secret) — keep safety-strategy drop-sudo, restrict triggers, and pin the version.
Quiz
Lock in what you learned
Check your understanding
0 / 4 answered
1.You enabled Code review for a repo at chatgpt.com/codex/settings/code-review but left Automatic reviews OFF. A teammate opens a new PR and is confused that Codex didn't comment. What's the correct explanation?
2.A PR author runs `@codex review` and Codex posts a review with only two comments, even though the diff has several minor style issues. Why are the style nits missing?
3.In a monorepo, a PR changes files under both `packages/api/` (which has its own AGENTS.md with a `## Review guidelines` section) and `packages/web/`. How does Codex decide which review guidelines apply to each changed file?
4.After a review flags a high-priority bug, you comment `@codex fix the P1 issue`. Separately, you comment `@codex add an integration test for the new endpoint`. What happens?
Go deeper
Hand-picked sources to keep learning
The primary guide: enabling code review, the @codex review trigger, P0/P1 behavior, focused variants, and fix follow-ups.
How Codex connects to GitHub, the @codex mention model, and PR/issue cloud tasks.
Running codex exec in CI for reviews and patches — inputs, safety strategies, and auth via an API-key secret.
Source and README for the openai/codex-action@v1 GitHub Action, including the full input reference.
The related in-app review pane (/review, inline comments, PR context via gh) for reviewing diffs outside GitHub.
Live source for evolving details — plan availability, model defaults, and feature rollouts that change frequently.