Finish Part 2. Check the random-user change, let Codex build Slice 2 (post an auction) and Slice 3 (bids), learn to read and shrink the context window, and prove the bid rules yourself in two browser tabs.
/compact and understand what that does to Codex's memory of the conversation.http://localhost:5102. If you closed the browser, open that URL again. If the page does not load, run the “Then run it” command from the Stuck box at the bottom of this guide.First, wait for Codex to finish the follow-up you sent at the end of guide 9. You will know it is done when the spinner under the message box stops and a final summary message appears. Read that summary before you touch the browser; it tells you what Codex believes it changed, and your job is to confirm it.
Then go to Chrome and open two brand-new tabs (Cmd+T twice) with the Part 2 URL below. Look at the top-right corner of each tab. In guide 9 that corner said “10 Demo users”. Now it should show a real person's name and initial, and the two tabs should usually show two different people.
http://localhost:5102
Codex's reply, similar to: “Updated. New browser tabs receive a random seeded user. Identity stays stable through navigation and reloads within that tab. The footer switcher updates both footer and header immediately. The top-right now shows the active user's name and initial. The old “10 Demo users” label is gone. Tests and TypeScript checks pass.”
In Chrome, each new tab shows a user's initial in a circle and the user's name at the top right. In my run the first tab showed Marcus Green and a later tab showed Jordan Lee. Both are from the 10 seeded users you saw in the migration in guide 9.
What it means: each tab now gets its own random user and keeps it. Later, when several tabs bid against each other, you can tell at a glance who is who.
Reloading a tab keeps the same user on purpose. The browser gives every tab its own small storage area, and the app saves the chosen user there, so a reload reads the same name back. Only a new tab picks a fresh random user. With 10 users, two new tabs will sometimes land on the same person by chance; just open a third tab if that happens.
Slice 1 works, so save it as a checkpoint before we ask for the next slice. A commit is a saved snapshot of the whole project (guide 1). If Slice 2 goes badly, you can always come back to exactly this state instead of untangling two slices at once. Use any Git tool you like: VS Code's Source Control panel (the branch icon in the left bar, or Ctrl+Shift+G) with a message and the ✓ Commit button, or the single Terminal command below.
cd ~/codex-course/workshop && git add -A && git commit -m "part 2 slice 1"
What the three parts do, joined by && (which means “only continue if the previous part succeeded”):
cd ~/codex-course/workshop moves into your workshop folder, the root of your Git repository.git add -A stages every new, changed and deleted file, so all of Codex's Slice 1 work is included in the snapshot.git commit -m "part 2 slice 1" saves the snapshot with that message. Keep the messages boring and predictable: “part 2 slice 1”, “part 2 slice 2”, and so on. You will thank yourself when you scroll the history later.A line like [master 1a2b3c4] part 2 slice 1 followed by a count such as 42 files changed. The seven-character code is the commit's id; yours will be different. node_modules (the installed packages, thousands of files) is not included because the project's .gitignore file tells Git to skip it. That is correct.
Why this matters: committing after every slice keeps each diff small enough to review, and lets you throw away one bad slice without touching the ones before it.
In guide 8, Codex agreed to build Part 2 in three slices and to stop after each one for your review. You have now reviewed Slice 1. Tell Codex it is good and it may move on. The message is deliberately casual; Codex still has the full plan from the grilling session in this chat, so a short nudge is all it needs.
yep this looks good move onto the next slice
A slice is one thin, complete piece of a feature that goes all the way through the stack: the database change, the server code, the web page, and the tests for it. “Post an auction” is a slice: a form in the browser, a server route that receives the form, a row written to the database, and a page that shows the new auction. The alternative, building the whole database first, then the whole server, then the whole frontend, means you cannot click anything until the very end. With slices you can check something real in the browser after every step, which is exactly how I want you to work with an agent: build a little, verify, commit, repeat.
A reply similar to: “I'm starting Slice 2: a complete “post an auction” path. I'll add the validated Fastify endpoint, derive artwork and seller ownership server-side, add the Sell navigation and /auctions/new page, redirect successful posts to their database-backed detail page, and verify that the new auction survives refresh and appears in catalog/search. I'll stop again after this slice for your review.”
A new to-do list appears above the message box showing Step 1/3. In my run this slice took about 7 minutes. Let it work; the next step shows you what to look at while you wait.
“Derive seller ownership server-side” is a small but important phrase. It means the server decides who the seller is (the currently active user) instead of trusting a value sent from the browser. Anything the browser sends can be edited by a user, so the server must never trust it for ownership or money.
While Codex builds, I like to watch the list of files it is touching. You do not need to read every line; you want to know which files change, and whether that matches what Codex said it would do. Any Git view works: VS Code's Source Control panel (Ctrl+Shift+G) lists changed files live, or run this command in Terminal every minute or so.
cd ~/codex-course/workshop && git status --short
git status --short prints one line per changed file. The two letters at the start tell you the kind of change: M means an existing file was modified, ?? means a new file that Git has not seen before, D means deleted. Because you committed in Step 2, everything listed now belongs to Slice 2 only.
The browser and the server talk over HTTP. The server exposes a list of addresses it answers to, called routes or endpoints, each with a method. GET /api/auctions means “give me the auctions”; POST /api/auctions means “here is a new auction, save it”. The web page calls these endpoints behind the scenes when you click. Our server is written with Fastify, a Node.js library whose job is to receive these HTTP requests, run our code, and send back a response. When you see “a new create-auction route” in the diff, that is a new POST /api/auctions handler being added to app.ts.
Changed files inside part-2-create-auction-and-bid, similar to server/src/app.ts (the new create-auction route), server/src/app.test.ts (a test for it), web/src/catalog.ts, a new web/src/components/NewAuctionPage.tsx (the Sell form), web/src/App.tsx (the new page wired into the app's navigation) and web/src/style.css.
Notice the pattern: one server file, one server test, a few web files. That is the shape of a slice.
How closely should you watch? My rule: the riskier or more important the feature, the more closely I follow along. Money, permissions and anything concurrent get my full attention. A plain create-and-list slice like this one only needs a quick look at the file list and a proper check in the browser afterwards.
When Codex says Slice 2 is done, read its summary, then go to Chrome. There is now a Sell link in the header. Click it (or open the URL below) and fill in the form. Post something simple so you recognise it later; in my run I posted a GPU:
Then click Post auction.
http://localhost:5102/auctions/new
Two things from Codex's summary deserve a word. Validation means the server checks every incoming field before it touches the database: is the title non-empty, is the price a positive whole number, is the closing time in the future. Zod is the library our server uses to describe those rules and reject bad input with a clear error. Integer cents means a price of $20,000 is stored as the whole number 2000000, not as 20000.00. Computers cannot store most decimal fractions exactly (0.1 + 0.2 is not quite 0.3), so every serious money system stores the smallest unit as a whole number and only formats it as dollars for display. This was your Q6 answer from the grilling session.
Codex's message, similar to: “Slice 2 is complete. The persisted QA auction is open at Mellanox ConnectX-7 400Gb Adapter.” It lists what it built: a Sell link and the /auctions/new form, the active user becomes the seller, Zod validation, prices stored in integer cents, new listings appear in search. Then a diagram (Sell form → POST /api/auctions → Fastify API with Zod validation → PostgreSQL, then a redirect to the detail page) and Server: 5 tests passed · Web: 3 tests passed.
In Chrome, the form says Posting as followed by your current user's name. After you click Post auction you land on /items/<your-title> showing $20,000, 0 bids, No bids yet, about 23h 59m left, and Sold by your user. Reload the page: the auction is still there, because it is now a row in PostgreSQL, not something held in the browser's memory.
Codex posts its own test auction while it checks its work (mine was the Mellanox ConnectX-7 adapter). That is normal and a good sign: it verified the form end to end. If test data piles up, npm run db:reset in the Part 2 folder restores the original 10 users and 6 auctions.
Slice 2 is checked in the browser, so take another checkpoint. Same command as Step 2, only the message changes. If you prefer VS Code's Source Control panel, type the message there and click Commit.
cd ~/codex-course/workshop && git add -A && git commit -m "part 2 slice 2"
A line like [master 5e6f7a8] part 2 slice 2 and the number of files changed. If instead you see nothing to commit, working tree clean, Codex's changes were already committed (some runs commit on their own); that is fine, move on.
Now the last and most interesting slice: placing bids. This is where the rules you decided during grilling (Q11 to Q15) become real code. Ask for it with another short message.
continue to the last slice
A business rule is a rule of the product, not of the programming language: “a seller cannot bid on their own auction”, “a bid must be at least $1 above the current price”, “no bids after the auction ends”. The server must enforce every one of them, because the browser can be bypassed by anyone with a terminal and curl. Rules can be enforced in two places. In code: the route handler reads the auction, checks the rule, and rejects the request if it fails. Or as a database constraint: a rule written into the table itself, such as “this column cannot be empty” or “this pair of values must be unique”, which the database refuses to break no matter who writes to it. Slice 3 enforces its rules in code. In Part 3 you will see why some rules also need help from the database.
A reply similar to: “I'm starting the final slice on the existing ConnectX-7 auction. I'll add the sequential bid endpoint and domain checks, return auditable bid history with auction details, wire the active-user bid form with seller/ended/minimum-bid states, and browser-test rejected self/low bids plus accepted bids from multiple users. Simultaneous-bid locking will remain intentionally out of Folder 2, as agreed.”
Soon app.ts gets a new POST /api/auctions/:slug/bids route (the :slug part is a placeholder for the auction's URL name). Inside it you will find checks such as “Sellers cannot bid on their own auctions” returning HTTP status 409, an ended-auction check, and a minimum-bid check.
HTTP 409 Conflict is the status code a server uses to say “your request is well-formed, but it clashes with the current state of things”. It is the right code for a rejected bid: the request was fine, the rules said no. Compare with 400 (you sent garbage) and 404 (that auction does not exist).
“Out of Folder 2, as agreed” is your Q13 answer at work. Two people bidding at the exact same instant is a hard problem, and we deliberately pushed its fix to Part 3. Guide 11 shows you exactly what goes wrong when we do not handle it.
While Slice 3 builds, let's answer a question every learner asks me: “when should I start a fresh chat?” Codex can show you a meter for how full the current chat is. Turn it on:
The model does not remember your chat the way you do. Every time you send a message, Codex sends the whole conversation so far (your prompts, its replies, the files it read, the command output it saw) to the model again, and the model answers from that. The amount it can take in one go is the context window, measured in tokens, which are word-pieces of roughly three-quarters of an English word each. A long build like Part 2 fills the window fast because every file Codex reads and every test run it watches is added to it. When the window is nearly full, two bad things happen: older details get pushed out, and the model's answers get vaguer. That is why you want to see the meter.
A small donut chart next to the model picker. Hovering shows something like Context window: 74% full, 190k / 258k tokens used. Mine was at 74% after almost three slices of work in one chat, which is a lot.
The underlying model can take close to a million tokens, but Codex caps a chat at about 258k, because models start to drift with very long context. When a chat gets close to the cap, Codex compacts it automatically (Step 9 shows you how to do it yourself). My habit: one chat per feature, a new chat for the next feature, and a new chat any time the agent starts giving odd answers.
The Speed setting higher up on the same page (Fast shows a ⚡ next to the model name) can stay as it is.
Wait for Slice 3 to finish (about 4 minutes in my run) and read its summary. Then shrink the chat before we do anything else in it. Type /comp in the message box; a small menu of slash commands pops up above it. Pick Compact. Codex writes a summary of the chat so far, and from then on sends that short summary to the model instead of the full history.
/comp
Compaction replaces the long transcript with a condensed version of it: what the task is, what decisions were made, which files were changed, what is still open. Think of it as a hand-over note you would write for a colleague taking over your work. The model keeps the important facts and loses the noise (every test log, every file it skimmed). The trade-off is real: anything not in the summary is gone for the model, so compact at a natural pause, after a slice is finished and committed, not in the middle of a fix.
The menu shows Compact – Compact this chat's context (76% full). After you pick it, Codex shows Compacting context for a few seconds, and the donut drops a lot. In my run it went from about 190k tokens down to about 8k. The chat looks the same to you; only what gets sent to the model has changed.
The Codex app has no /clear command. To start completely fresh, click New chat. Also, since you are signed in with an API key, every message re-sends the chat's context and you pay for those tokens. Cached tokens are cheaper than fresh ones, but a 10k-token context still costs far less than a 190k one. Compacting saves money as well as quality.
Codex says it browser-tested the bid rules. Now you check them yourself; never take an agent's word for a business rule. You need two users, so you need two tabs with two different identities:
20000, in the bid box and click Place bid.20001, and place the bid again.Codex's summary, similar to: “Minimum bid is current amount plus $1.00. Ended auctions reject bids. Accepted bids update price, bidder, and count immediately. Newest-first bid history with bidder, amount, and timestamp…”, ending with “The intentional boundary remains: ordinary sequential bids are correct, while simultaneous-bid locking is deferred to Folder 3.”
In Chrome:
20000 shows Enter at least $20,001. The bid is rejected because it does not beat the current price by at least $1.20001 shows Bid accepted. You are the highest bidder. The price becomes $20,001 · 1 bid, and the bid appears under Bid history with the bidder's name, the amount and the time.“Duplicate Tab” copies the tab's saved storage, including the chosen user, so you would still be the seller. That is why I open a plain new tab instead.
I would rather let the very first bid equal the starting price exactly, but I leave it as it is for now. It is a product decision, not a bug.
Part 2 is done: a database-backed marketplace, posting auctions, and sequential bidding with its rules. Commit it so Part 3 starts from a clean, known-good point.
cd ~/codex-course/workshop && git add -A && git commit -m "part 2 slice 3"
From guide 11 onwards we work in a new chat. The Part 2 chat holds a long story about users, forms and bids; Part 3 is about a different problem (two bids at the same instant). If we continued in the old chat, the model would carry all that unrelated history, pay for it on every message, and sometimes mix old decisions into new work. A new chat starts clean, and Codex still knows the project because the facts that matter are written down in files: AGENTS.md, GRILL.md and the code itself. Rule of thumb: one task, one chat. That is also why we write decisions into files rather than leaving them only in a conversation.
A line like [master 9b0c1d2] part 2 slice 3 and the number of files changed. Run git status afterwards and it says nothing to commit, working tree clean, which means every change is saved. Leave the app running at http://localhost:5102; guide 11 uses it.
If Slice 2 or 3 went wrong (a test failed, the Sell page is missing, bids are not accepted), first tell Codex exactly what you see, in the same chat, and let it fix its own work. That is the normal loop and it usually takes one message.
If you would rather catch up and move on, replace your Part 2 with the version from the reference project. Note that it is the end state of the whole part: all three slices, the random user per tab, and a bidding-war Playwright test that we add ourselves in guide 12. After copying, run it and do Steps 5 and 10 of this guide in the browser so you still see the rules in action.
cd ~/codex-course/workshop && rm -rf part-2-create-auction-and-bid && cp -R ../reference/part-2-create-auction-and-bid ./ && git add -A && git commit -m "Catch up: part 2 from reference"
That command deletes your Part 2 folder (rm -rf), copies the reference's Part 2 folder in its place (cp -R), and commits the result.
cd ~/codex-course/workshop/part-2-create-auction-and-bid && npm install && npm start
npm install downloads the project's packages; npm start starts the API on port 3102 and the web app on port 5102. Keep that Terminal window open.