iTranslated by AI
3 Ways to Streamline Codex Reviews
With OpenAI's AI-driven development tool "Codex," you can not only implement code but also leverage AI-powered PR reviews.
In this article, I'll explain three configurations I actually use to effectively integrate these PR reviews into the development workflow.
Adopting these will streamline your development process as follows 👇
Before
- Write code and create a pull request (PR)
- Manually comment
@codex reviewto request a Codex review - Codex completes the review. You notice it only after visiting the GitHub PR page
- Read Codex's review, fix issues, and push again
- Comment
@codex reviewonce more to request a re-review
After
- Write code and create a pull request (PR)
- ✨
@codex reviewis automatically posted - Codex completes the review. ✨ You receive an email notification automatically
- Read Codex's review, and ✨ AI automatically fixes, commits, and pushes the changes
- ✨ AI automatically comments
@codex review, so re-review runs by itself
① Automatically trigger an AI review when a pull request is created!
Use GitHub Actions to automatically comment "@codex review" when a pull request is created, so Codex sees that comment and automatically starts the review!
1. Generate a GitHub token
First, generate a key (personal access token) to allow commenting as your own GitHub account.
Why is a "Personal Access Token" necessary?
Codex is designed to ignore comments from GitHub Bots.
In other words, the "@codex review" comment requesting a Codex review must be posted using your account permissions, not from a bot. That's why we use PERSONAL_ACCESS_TOKEN.
Steps
- From your GitHub account settings, select "Developer settings"
- Select "Personal access tokens" and then choose "Fine-grained tokens"
- Click "Generate new token"
- Configure the following:
- Token name: Name of the token (e.g., "{repository_name}-GitHubActions-PRAutoComment")
- Description: Enter a description that clarifies the token's purpose (e.g., "For automatic PR review of ~")
- Resource owner: Select the account the repository belongs to
- Expiration: Set the token's expiration date
-
Repository access: Select "
Only select repositories" and choose the repositories you want to auto-review -
Permissions: Define the token's permissions as follows:
-
Codespaces: Read-only -
Issues: Read-and-write -
Metadata: Read-only (fixed by default) -
Pull requests: Read-and-write
-
- Click "Generate token"
- A confirmation modal appears. Verify the settings and click "Generate token" again
- Copy the generated token immediately — you won't be able to see it again after leaving the page.
2. Configure the generated token
Place the generated token in the corresponding repository so that GitHub Actions can use it.
Steps
- Go to the repository's settings on GitHub, select "Secrets and variables", and click "Actions"
- Under the "Repository secrets" section, click "New repository secret"
- Configure the token you just generated:
-
Name: Enter "
PERSONAL_ACCESS_TOKEN" -
Secret: Paste the token you copied (starts with
github_pat_)
-
Name: Enter "
- Click "Add secret" to apply
- If "PERSONAL_ACCESS_TOKEN" appears under "Repository secrets", you're all set.
3. Add the automation file to the repository
Add the GitHub Actions code for automatic review requests to your repository.
Create a directory /.github/workflows directly under the root directory (not .git).
Inside that directory, create a new file named pr-auto-comment.yml and copy the following content:
name: PR Auto Comment
on:
pull_request:
types: [opened]
permissions:
issues: write
pull-requests: write
jobs:
comment:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "@codex review",
});
Code explanation
- We avoid sending auto-review comments on PRs created by external forks or bots.
- To do this, we restrict the execution condition with
${{ github.event.pull_request.head.repo.full_name ==github.repository }}.
After pasting, don't forget to run git commit and git push.
4. Setup complete!
From now on, simply creating a pull request in the corresponding repository will automatically post an "@codex review" comment, and Codex will automatically review the pull request content.
② Receive review completion notifications via email to reduce decision lag!
To eliminate cases of "I didn't notice the review finished and left it unattended!", configure Codex to send you an email when a review completes.
Steps
Configure your GitHub notification settings.
- From your GitHub account settings, select "Notifications"
- Under the "Email" section, verify that email notifications are enabled
- In the "Email notification preferences" section below, check the following items:
- "Pull request reviews"
- "Pull request comments"
That's it — the setup is complete.
From now on, you will automatically receive an email when a review finishes, eliminating the need to periodically check the PR page.
③ Automatically handle fixes for review comments with AI!
Automate the review and fix workflow after creating a PR.
Codex has a feature where, if you comment @codex fix comments on a PR review, Codex Cloud will automatically fix and even push the changes.
However, when multiple solution approaches involve trade-offs, a human who understands the unspoken requirements must choose the optimal method.
Therefore, I limit this feature to only small, simple tasks.
On the other hand, for substantial tasks, I pass the issue content to Codex CLI in a local IDE, first asking it to evaluate whether the issue is valid, and only if judged valid, do I proceed with the fix.
By combining this with GitHub MCP, you can have Codex CLI automatically execute the entire flow: "Issue evaluation → Fix → Commit → Push → Review request" in one go.
1. Create an Access Token on GitHub
Follow the same steps as in 1-1-1 to create an access token on GitHub.
- Log in to GitHub, click your profile icon in the top right, and select "Settings".
- In the left sidebar, click "Developer settings".
- Select "Personal access tokens" and then click "Tokens (classic)".
- Click "Generate new token".
- Configure the following:
- Note: Enter a description that clarifies the token's purpose (e.g., "For GitHub MCP")
- Expiration: Set an appropriate expiration (recommended for security)
-
Scopes: Check the
reposcope (full access to all repositories, including private ones). If you only need public repositories,public_repois sufficient.
- Click "Generate token".
- Copy the generated token and save it in a secure place.
2. Register GitHub MCP with Codex CLI
Codex CLI's configuration file is located at ~/.codex/config.toml in the home directory.
Add the following content to that ~/.codex/config.toml file.
(Replace github_pat_xxxxxxxxxxxxxxxxxxxxxx with the access token you just created)
[mcp_servers.github]
command = "mcp-proxy"
args = ["--transport", "streamablehttp", "-H", "Authorization", "Bearer github_pat_xxxxxxxxxxxxxxxxxxxxxx", "https://api.githubcopilot.com/mcp/"]
3. Verify Connection and Start Using
- Run
codexin the terminal to start Codex CLI. - While it's running, enter
/mcpat the prompt to see a list of connected MCP servers. Ifgithub(the name you registered) shows as "Ready", it's successful. - To test, enter something like "List the issues in this repository" in the Codex prompt. It will execute the operation via GitHub MCP.
4. Automate Fixes and Re-review Using GitHub MCP
Here's how to use GitHub MCP in an actual workflow:
First, copy and paste the issues pointed out in the PR review into Codex CLI, and ask it to judge whether those comments are valid and how they should be resolved.
Example prompt I actually use:
{I've copied the review content here}. We received this review. Is it valid? If valid, tell me the implementation approach.
If there are multiple approaches, explain the pros and cons, risks, whether it's a common approach, whether you recommend it, and in which cases each approach should be chosen.
Then, if multiple approaches are proposed, select the best one and ask for implementation.
Example prompt I actually use:
Then, implement approach X, commit it, run npm run quality, and if there are no problems, push it.
If there are problems, fix them and run the command again, repeating until there are no problems, then push.
After pushing, use GitHub MCP to comment "@codex review".
With this, Codex will automatically execute the entire flow: "Issue evaluation → Fix → Commit → Push → Review request".
Then, once the review is complete, you'll receive an email notification as configured in ②.
When the email arrives, check the PR status. If everything is fine, merge and move to the next task. If there are issues, repeat the workflow in ③.
Summary
In this article, I explained three methods to automate and accelerate AI-driven development with Codex:
-
Automating review requests on PR creation: Use GitHub Actions to automatically comment
@codex reviewwhen a PR is created. - Setting up email notifications: A mechanism to be immediately notified when a review is complete.
- Automating fixes and re-reviews: Use GitHub MCP to have Codex CLI automatically execute a series of processes.
By adopting these methods, you can automate simple operations that don't require human effort, increasing development efficiency. In AI-driven development, human effort is the biggest bottleneck, so even small efficiency gains in human tasks can lead to several times greater efficiency in the overall AI-driven development process.
And by making effective use of the freed-up time, development efficiency improves even further.
You could implement another feature using Git worktree, refactor code, write requirements documents for the next feature, tweak the UI/UX while debugging, or even work on other projects.
Let's make effective use of our limited human resources and pursue efficient AI-driven development! 🔥
Discussion