Recipes / Dev & code
CodexFull setupDev & code

Your own PR review bot with Codex

OpenAI's action runs Codex CLI inside a workflow with locked-down privileges; the README's example posts a code review comment on each new PR.

From openai on GitHub · Oct 2025

Setup time15 min
CostAPI usage
RunsOn PR opened
NeedsGitHub Actions, OpenAI API key (secret)
Last updated2026-10-17

What the source did

  • Installs Codex CLI and routes calls through a secure proxy.
  • Example workflow: shallow clone, fetch base and head, run Codex with a PR-specific prompt, post the output as a comment.

Summary written by Agent Cookbook from the original post. See the original for the full context. How we source recipes

Our notes

What it takes
An OpenAI API key stored as a GitHub Actions secret, and the README's two-job workflow: the codex job runs with contents: read and permission-profile :workspace, then a separate post_feedback job with issues and pull-requests write posts the comment. Keep safety-strategy at its drop-sudo default.
Where it breaks
Prompt injection from the PR itself: the security doc names hidden HTML comments in PR bodies, commit messages, AGENTS.md files in the PR and screenshots. Without drop-sudo or an unprivileged user, passwordless sudo on the runner can expose your API key even with read-only file access.
Human checkpoint
Only users with write access to the repo, plus anyone you add to allow-users, can trigger it. The prompt tells Codex to review ONLY the PR's changes and be concise and specific; it comments, and you decide what to change.
Tools involved
GitHub Actions, OpenAI API key (secret)

✓ Verified Source link checked and still live. Notes by Thomas, editor. How we verify

Get their template

Made and published by openai. Start here; it is their original, not ours.

Their prompt

From OpenAI's README Their exact wording: the prompt in the example review workflow. Source ↗

This is PR #${{ github.event.pull_request.number }} for ${{ github.repository }}. Review ONLY the changes introduced by the PR, so consider: git log --oneline ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} Suggest any improvements, potential bugs, or issues. Be concise and specific in your feedback. Pull request title and body: ---- ${{ github.event.pull_request.title }} ${{ github.event.pull_request.body }}

Approval rule

🛡
Workflow gets contents: read; only the comment step can write.

Set it up

  1. Add the key as a secret.
  2. Copy the README example workflow.
  3. Start from their example prompt above, then add your repo's own review rules.
  4. Read the repo's security doc and keep permissions read-only.

Common failures

⚠
  • Noisy nitpicks. Tell it to report only real problems.
  • Forked PRs can't read secrets by default; that's intended.

Variations

  • Run on a label instead of every PR.
  • Pair with the Claude action and compare reviews.

Get the 10 best agent setups. Free.

Plus new recipes every week. One email, no spam.

Unsubscribe anytime. Privacy

Related recipes

Same job: Dev & code

In these guides: AI code review agents →

Get their template ↗