← All guidesCodex for Backend Engineering · Future with Shivank
Hands-on guide

24. Reviewing the Pull Request

Review the Drizzle pull request your goal opened, catch the test it skipped, pay for a won auction through Mock Stripe with your own hands, and start Part 7's Slice 2. This guide is about trusting an agent's work the right way: verify, then accept.

Part 7 · slice 1 → 2≈ 30–45 min hands-onGitHub PR + local /review

What you'll do

Before you start

📘 Concept: reviewing a PR, what to look for

A pull request review is not “read every line and nod”. A good reviewer asks four questions, in this order. Does the description match the ticket? Read the PR summary against the issue's acceptance criteria. Is the change where I expect it? Skim the list of changed files; surprises (a file that has nothing to do with the ticket) are a red flag. Does the code do what the description claims? Open the three or four most important files and read them properly. Were the claims verified? “Tests pass” is a sentence in a text box until you see the tests run. With an AI author, the fourth question matters most, because agents are very good at writing confident summaries. That is the thread we pull on in this guide.

⚙ Codex settings for this guide
Project / folderworkshop
ModelGPT-5.6 Sol
ReasoningMedium
ApprovalsApprove for me
1

Open the pull request on GitHub

While you were working on Part 7, the goal pushed a branch called issue-1-drizzle-refactor to your GitHub repo and opened a PR from it. Let's look at it the way a teammate would see it. Paste the block into the Terminal app. Line by line:

  • cd ~/codex-course/workshop: into the workshop folder, so gh knows which repo you mean.
  • gh pr list prints the open pull requests: number, title, branch.
  • gh pr view 4 --web opens PR number 4 in your browser. Use the number gh pr list shows for the Drizzle PR; it was #4 in my run, because #1 and #2 are the issues and #3 is the ADR PR from guide 22.
❯Run in TerminalTerminal app · workshop folder · change 4 to your PR number
cd ~/codex-course/workshop
gh pr list
gh pr view 4 --web
✓ You should see

gh pr list shows two open PRs: Refactor Part 6 services to Drizzle (#4) and Document the ORM decision for Part 6 (#3).

The PR page in your browser: at the top, “wants to merge 1 commit into master from issue-1-drizzle-refactor”. Below it, a description that starts with Closes #1 (GitHub reads that phrase and will close issue #1 automatically if the PR is ever merged), then a Summary: a shared typed Drizzle schema, API, workers and tests moved to Drizzle, row locking and SKIP LOCKED kept (so the concurrency protection from guides 14 and 20 is still there), and the decision recorded in an ADR. Then a Validation list: server tests 21 passed, web tests 15 passed, typechecks passed. Keep that Validation list in mind; we come back to it in step 3.

💡 Tip

Three tabs matter on a PR page: Conversation (the description and comments), Commits (each saved snapshot on the branch), and Files changed (the full diff). Reviewers live in the last one.

2

Review the diff yourself

Click the Files changed tab. You get a long page: each changed file is a block, removed lines are red with a minus, added lines are green with a plus. Don't try to read all of it. Skim the file list on the left, then open these three places and read them properly:

  • part-6-async-close-rabbitmq/docs/adr/0002-use-drizzle-across-database-services.md: the decision and the reasoning. Read this first, because it tells you what the rest of the diff is trying to achieve.
  • server/src/db/schema.ts: the tables now defined in code with pgTable(…). Each table from the SQL migrations (auctions, bids, users, …) becomes a TypeScript object listing its columns and their types. This file is what gives the ORM its type safety: every query is checked against it.
  • Tests and services: raw SQL strings such as pool.query('DELETE FROM auctions …') replaced by calls like db.delete(auctions).where(like(…)) and db.insert(auctions).values(…). Pick one service file and compare one red line with the green line that replaced it; you will see the SQL verb (DELETE, INSERT, SELECT) has become a function name.

My point after skimming: it looks right. The description is tidy, the files are where I expect them, the tests are listed as passing. But did it actually work, in the sense of the app still running correctly with four users bidding at once? Nothing on this page proves that.

✓ You should see

About 29 files changed, around +950 / −730 (your numbers will differ). Old SQL lines in red, Drizzle calls in green. At the very top of the file list, the new schema.ts and a new drizzle.config.ts, and in package.json the new dependency drizzle-orm.

💡 Tip

GitHub also shows a Copilot reviewer button on the PR. That is GitHub's own feature, not Codex. Codex's own GitHub PR reviews need a ChatGPT plan, so with an API key we use the local /review in step 10 instead.

3

Ask whether it ran the bidding war

Part 6's most important check is not npm test. It is the headed Bidding Wars scenario: four real browsers bidding on one auction at the same time, the test that proves the row locking works. The PR's Validation list did not mention it. So go to the Pull GitHub issue 2 chat in Codex, scroll to the end of the goal's summary, and ask directly. Capitals and question marks are optional; a direct question is not.

✦Paste into CodexPull GitHub issue 2 chat
did you do the BIDDING WARS?????
✓ You should see

Before you send, look at how the summary ends: a commit hash, Goal usage: 331,965 tokens over approximately 17 minutes (yours will differ), a card Edited 30 files +822 −1,510, and Goal achieved in 16m 53s.

After you send, Codex admits, something like: “No—not the full headed Playwright Bidding Wars scenario… That was an omission; I shouldn't have implied the full scenario was verified.” Your Codex may answer differently. If it says it did run the scenario, and shows the command and output, skip the next step.

💡 Tip

Why this matters: the summary said “tests passed” and that was true. It just was not the whole truth, because the most important test is not part of npm test. An honest “no” to a direct question is worth more than a confident summary. Ask the question every time.

4

Make it run the test for real

Same chat. Now we tell Codex to run the real scenario and to verify it by driving a browser. With an API key you don't have the browser built into Codex, so this prompt asks for Chrome or Edge through Playwright, headed, meaning the windows are visible so you can watch too.

✦Paste into CodexPull GitHub issue 2 chat
WELL DO IT PLEASE!!!!!! and please verify everything with browser use (use Chrome or Edge with Playwright, headed)
✓ You should see

Something like: “You're right. I'm running the actual Bidding Wars scenario now… If anything fails, I'll fix it and update PR #4.” Four browser windows open for Part 6 (port 5106, Part 6's port) inside the worktree, and the familiar bidding plays out.

In my run, the real run found a real bug: “Good catch from the real run: it exposed a migration-adoption defect…”. In plain words, the Drizzle version of the database setup tripped over rows that the old setup had already inserted. Codex fixes it and pushes a second commit to the PR. Leave this chat running and go on to step 5; we come back in step 8.

⚠ Heads up

This run reinstalls packages, runs the migrations and tests Part 6 inside the worktree. It takes a few minutes and more tokens. It is worth it: this is the step that turns “probably works” into “works”.

5

Run Part 7's bidding war and keep the browsers open

Switch to the Define winner checkout flow chat. The bidding war you saw in guide 23 closed its windows the moment the auction ended, so you never got to pay. Ask for a run that leaves them open. This is a normal chat message; Codex works out how to hold the windows.

✦Paste into CodexDefine winner checkout flow chat
can you do bidding wars but NOT close the browsers so I can complete checkout?
📘 Concept: environment variable

An environment variable is a named setting handed to a program when it starts, from outside the code. Writing BIDDING_WAR_HOLD_MS=3600000 npx playwright test … sets the variable BIDDING_WAR_HOLD_MS to 3,600,000 milliseconds (one hour) for that one command only. Inside the test, the code reads that value and keeps the browser windows open for that long before closing them. Same test, different behaviour, no code change. Ports, database passwords and the mock's webhook secret are passed to our app the same way, through its .env file.

✓ You should see

“Yes. I'll run the headed Bidding War in Edge, tile the four user windows, and leave them open after the auction closes…” It runs BIDDING_WAR_HOLD_MS=3600000 npx playwright test tests/bidding-war.spec.ts ….

Four windows on http://localhost:5107/items/bidding-war-gpu-… (Codex picks the port; 5107 in my run). Bids climb to about $107 and the auction ends:

  • Seller (Avery Chen): Your auction has closed … “Theo Brooks won with $107.”
  • Winner: Congratulations … “You won … with a bid of $107”, with buttons Dismiss, View auction, Complete purchase.
  • The two losing bidders: a quieter “auction closed” message with no payment button, because only the winner may pay (round 1, Q4 in guide 23).

Codex: “Done. Four tiled Edge windows are open and being held. Theo won at $107, so use the bottom-left window…”. The winner's name and window position will differ in your run; use what Codex tells you.

6

Pay as the winner with the success card

Go to the winner's window, the one Codex named. You have two ways in, and both work: click Complete purchase straight from the popup, or do what I did: click View auction first, scroll to the Winner checkout · Payment required panel on the auction page, and click Complete purchase there. The second route is the one a winner who dismissed the popup would take.

The browser is redirected to the Mock Stripe page. Fill in the card number below, any future expiry (I used 03/55) and any 3-digit CVC (I used 333), then click Pay $107.00 (your amount is the winning bid).

≡Success test cardCard number field on the Mock Stripe page
4242 4242 4242 4242
📘 Concept: paying for a won auction, end to end

Follow what happens between your click and the “Paid” badge, because every piece of Part 7 is in that chain. (1) You click Complete purchase; the web app calls our API. (2) The API checks you are the winner and the auction is closed, creates a purchases row in pending state (or reuses the open one), and asks Mock Stripe to create a Checkout Session for exactly the winning bid. (3) The API sends your browser to the mock's hosted page on port 7107. (4) You enter the card; the mock decides success or decline. (5) On success, the mock sends a signed webhook to our API; the API verifies the signature, records the event id, and flips the purchase from pending to paid, once. (6) The mock redirects your browser back to the auction page with ?checkout=success, and the page asks our API for the real state and shows Paid. Note that step 6 only displays the state; step 5 is the only thing that changes it.

✓ You should see

The Mock Stripe page at http://127.0.0.1:7107/checkout/cs_test_… shows the item, $107.00, Winning Bid · USD, and a reminder of both test cards (the fix Codex made to the mock in guide 23). After paying you land back on …/items/bidding-war-gpu-…?checkout=success&session_id=cs_test_…, and the panel reads WINNER CHECKOUT · Payment received · Your purchase is paid. Click Complete purchase again if the button is still there: nothing happens, because the purchase is already paid.

💡 Tip

Want to see what Slice 1 protects against? Before paying, use the decline card 4000 0000 0000 0002: you get an error on the mock page and can retry. Or click Cancel: you return to the auction, still Payment required, and can click Complete purchase again, which reuses the same session (round 2, Q16).

7

Save Slice 1 and start Slice 2

Slice 1 works, and you have seen it work with your own eyes. Save it in Git before moving on; I do this at the end of every slice, so that if Slice 2 goes wrong I can always return to a known-good point. The command moves into the workshop folder, stages everything Codex created for Part 7 and commits it with a clear message. Run it in the Terminal app.

❯Run in TerminalTerminal app · workshop folder
cd ~/codex-course/workshop && git add -A && git commit -m "Part 7 slice 1: winner checkout"

Then tell Codex to start Slice 2, the seller's side: the seller sees Awaiting payment or Paid, and the system recovers if the mock restarts and forgets an unpaid session. Codex already has the full plan for this in GRILL.md, so a short message is enough.

✦Paste into CodexDefine winner checkout flow chat
start on slice 2 please
✓ You should see

A commit summary in Terminal. In Codex, something like: “Starting Slice 2 now. I'll add role-limited seller payment status, automatic seller convergence after payment, and recovery when an unpaid Mock Stripe Session disappears after a service restart…” and a counter like Step 1 / 6 · 7 files changed. “Convergence” means the seller's page catches up to the paid state on its own, without a manual refresh. Let it run. When it finishes it gives you browser steps for the seller's Awaiting payment / Paid view; try them.

💡 Tip

Codex may leave the four held browser windows open for up to an hour. Close them yourself when you are done, or ask Codex to close them.

8

See the fix land on the PR

Back in the Pull GitHub issue 2 chat, wait for the final answer about the real bidding-war run. Click Review on the file card to see the fix; it is one line. Then open the PR again with the command below (same as step 1, without the list) and click the Commits tab.

❯Run in TerminalTerminal app · change 4 to your PR number
cd ~/codex-course/workshop && gh pr view 4 --web
📘 Concept: migration, seed and ON CONFLICT DO NOTHING

A migration is a numbered SQL script that changes the database structure: create a table, add a column. They run in order, once each, so every copy of the database ends up with the same shape. A seed is the small set of starter rows (our demo users, for example) that a migration inserts so the app is usable on first run. The bug: when the Drizzle version re-ran the setup against a database that already had those seed rows, the INSERT failed because the rows existed. The fix, ON CONFLICT DO NOTHING, tells PostgreSQL “if a row with this key already exists, skip it quietly instead of erroring”. That makes the seed idempotent: safe to run any number of times. You met idempotency with webhooks in guide 23; here it is again, at the database level.

✓ You should see

Codex, something like: “YES — the actual Bidding Wars scenario is now done.” The full headed four-user scenario passed, accepted bids $101 → $102 → $103 → $106 → $107, exactly one winner, stale bids rejected. The diff panel shows server/migrations/001_marketplace.sql gaining ON CONFLICT DO NOTHING.

On GitHub, the Commits tab now lists two commits: refactor: use Drizzle across Part 6 services and fix: make legacy seed adoption idempotent. The PR header now says “wants to merge 2 commits”.

💡 Tip

Don't merge this PR. I leave it open so the repo stays the way the course built it; Parts 7 and 8 keep using plain pg. In your own projects, this is the moment you would click Merge: the claims are verified, the fix is in, the reviewer is satisfied.

9

Find out why Codex skipped the test

Was Codex careless? Let's check Part 6's package.json and AGENTS.md. The bidding war has its own npm script, but the checklist in AGENTS.md and the plain npm test command never mention it. Look for yourself. Line by line:

  • cd ~/codex-course/workshop/part-6-async-close-rabbitmq: into Part 6.
  • grep -n "bidding-war" package.json searches package.json for the text bidding-war and prints every matching line with its line number (-n).
  • grep -n -A2 "Stable root commands" AGENTS.md finds the heading Stable root commands in AGENTS.md and prints it plus the 2 lines after it (-A2), which is the list of commands Codex is told to rely on.
❯Run in TerminalTerminal app · Part 6 folder
cd ~/codex-course/workshop/part-6-async-close-rabbitmq
grep -n "bidding-war" package.json
grep -n -A2 "Stable root commands" AGENTS.md
📘 Concept: AGENTS.md as the agent's checklist

AGENTS.md is the instruction file Codex reads before it touches a folder: how the project is laid out, which commands are safe, what “done” means. An agent treats it as the definition of its job. If the file says “run npm test before claiming done”, the agent runs npm test, and nothing else, and reports honestly that tests passed. The lesson is not “agents cheat”. It is “agents do exactly what the checklist says”, which puts the responsibility for the checklist on you.

✓ You should see

One line from package.json with "test:bidding-war": "playwright test tests/bidding-war.spec.ts …", meaning the scenario exists as a separate script. Then the AGENTS.md list: npm run db:up, npm run db:down, npm run db:reset, npm run migrate, npm run dev, npm start, and npm test. No bidding war anywhere. Codex ran exactly what the instructions told it to run.

💡 Tip

The fix is a one-liner in AGENTS.md, for example “Before claiming done, also run npm run test:bidding-war.” I call this user error, and I mean mine, not Codex's: the agent is only as good as the checks you give it. If you want, add that line to Part 6's and Part 7's AGENTS.md now.

10

Optional: review the branch with local /review

Codex cannot review PRs on GitHub with an API key, but it can review the branch on your Mac, which is the same code. In the Pull GitHub issue 2 chat (it lives in the worktree, on the issue-1-drizzle-refactor branch), type /review in the message box. A small menu appears with review options; pick the one that reviews against a base branch, then choose master (or main). That tells Codex “compare this branch with master and review only the difference”, which is exactly what the PR contains.

📘 Concept: review findings and priorities

A code review tool lists findings, not opinions: each one names a file and line, says what is wrong and why it matters. Findings are ranked. A P1 is a blocker: a bug, a security hole, data loss; the PR must not merge until it is fixed. A P2 should be fixed but could ship; and lower levels are style or suggestions. When you read a review, deal with the P1s first and don't let a long list of small items hide one serious one.

✓ You should see

Codex reads the whole diff and lists findings, most important first, each with the file and line and a short explanation. Or it says it found no blocking issues. Compare its list with what you noticed yourself in step 2: did it flag anything about the migration, the schema or the tests that you missed?

💡 Tip

If your /review menu looks different, pick whichever option compares this branch with master.

⚠ Heads up

A review of a 30-file refactor reads a lot of code, so it costs tokens. Skip it if you are watching spend; you have already done the most important review yourself in steps 2–4.

Stuck or got a very different result?

Part 7 not working, or Slice 1 never got to checkout? Catch up to the finished Part 7 from the reference copy. The reference folder is the end state of the whole part (Slice 1 and Slice 2 done), and this also restores the finished stripe-service/. The first line replaces your Part 7 and mock with the reference copies and commits; the second installs packages and starts everything. Then play the winner yourself: open http://localhost:5107 (the URL npm start prints). Pick a user, click Sell and post an auction that closes in about two minutes. Switch to another user and bid. When it closes, the winner gets Complete purchase, and the steps from step 6 apply.

Skipped the Drizzle goal? Nothing to catch up. Steps 3, 4 and 8 only apply to that PR; do steps 1–2 on your ADR PR (#3) and everything else as written.

❯Run in TerminalTerminal app
cd ~/codex-course/workshop && rm -rf part-7-winner-checkout stripe-service && cp -R ../reference/part-7-winner-checkout ../reference/stripe-service ./ && git add -A && git commit -m "Catch up: part 7 from reference"
cd part-7-winner-checkout && npm install && npm start

Key takeaways