C.W.K.
Stream
Lesson 08 of 11 · published

Code Review Workflows

~14 min · codex, review, diff, pr-review

Level 0🌱 Novice
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Codex as the second pair of eyes

Codex's pipe-friendly nature makes it a natural code reviewer. git diff main...HEAD | codex exec reviews a PR diff in seconds. --ask-for-approval never --sandbox read-only guarantees no edits — pure review. Combine with --output-format json for downstream parsing in CI.

Two review depths to know: (1) diff review — Codex sees only the patch, fast and tight, good for "obvious bug" detection; (2) diff-in-context review — Codex reads the full file plus the diff, slower but catches issues a patch alone won't (e.g., the patch is fine, but the function it sits in is now redundant).

Code

Diff review in one command·bash
# Fast: review the patch alone
git diff main...HEAD | codex exec \
  --ask-for-approval never --sandbox read-only \
  "Review for bugs, security, and missing tests. Format:
   [SEVERITY] desc (file:line)" \
  --output-last-message > review.md

# In-context: full file + diff
codex exec --ask-for-approval never --sandbox read-only \
  "Read src/auth.ts in full, then review the staged changes
   in context. Flag any newly-introduced inconsistencies." \
  > review.md
GitHub Action posting reviews·yaml
name: Codex Review
on:
  pull_request: { types: [opened, synchronize] }

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - run: npm install -g @openai/codex
      - name: Run review
        env: { OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} }
        run: |
          git diff origin/main...HEAD | codex exec \
            --ask-for-approval never --sandbox read-only \
            "PR review: bugs, security, perf, style." \
            --output-last-message > review.md
      - uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const review = fs.readFileSync('review.md', 'utf8');
            github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: '## Codex Review\n' + review
            });

External links

Exercise

Wire Codex review into a real repo — either a shell script run before pushing, or a GitHub Action. Test it on a real PR. Capture the review comment it produces.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.