Put your workshop on GitHub, create the two issues I give you below, and let a Codex /goal pull an issue with the GitHub CLI, work on it in its own worktree and open a pull request. This is how agents work from a ticket queue in a real team.
gh) and push your workshop to your own private GitHub repo./goal in a new local worktree that reads issue #2 and keeps working until it is done.gh login can write to. Steps 1–5 give you exactly that, with the same issue numbers the prompts below use.Git tracks the history of your code on your own machine. GitHub is a website that stores a copy of that Git repository online, so other people (and other machines, and AI agents) can read it, propose changes to it and discuss it. Think of it as a shared drive for code, with full history and a discussion board attached. Until now everything we built lived only on your Mac. In this guide we put it on GitHub so that Codex can treat it the way a developer treats a team project.
Codex needs a way to talk to GitHub: read an issue, push a branch, open a pull request. It does all of that through gh, the GitHub command line tool. In this step you install it if it is missing, and log in once. After that, any command that runs on your Mac under your user, including the commands Codex runs, is allowed to act on your GitHub account.
Paste the block below into the Terminal app and press Enter. Line by line:
gh --version || brew install gh prints the version of gh if it is already installed. The || means “or else”: if the first command fails because gh is missing, Terminal runs the second one, which installs it with Homebrew. If gh is there, the install part is skipped.gh auth login starts a short question-and-answer wizard that logs you in.Answer the wizard like this: GitHub.com → HTTPS (how Git will talk to GitHub) → Yes when it asks to authenticate Git with your GitHub credentials (this is what lets git push work without a password later) → Login with a web browser. It then prints a one-time code that looks like XXXX-XXXX. Copy the code, press Enter, and your browser opens a GitHub page asking for it. Paste the code, click Continue, then Authorize github. Come back to Terminal.
gh --version || brew install gh gh auth login
Everything you can do on the GitHub website by clicking, you can also do by typing a command: create a repo, open an issue, list pull requests. gh is the official tool for that. It matters for us because Codex cannot click around a website, but it is very good at running commands. So gh issue view 2 is how Codex “reads a ticket”, and gh pr create is how it “submits work for review”. Your login is stored once on your Mac, and every gh command reuses it.
✓ Logged in as <your-username> as the last line of the wizard. You can confirm at any time with gh auth status.
No Homebrew on your Mac? Download the macOS installer from cli.github.com, run it, then paste only the second line (gh auth login).
“Here be dragons.” This login lets any program on your Mac, including Codex, act on every repo in your GitHub account, not only the course one. That is the price of convenience. So, always name the exact repo in your prompt, as I do in steps 7 and 11, and never leave a goal running on a repo you did not mean to touch.
GitHub only receives commits, the saved snapshots of your project. Any file that you have changed but not committed stays on your Mac and never reaches GitHub. So before we upload anything, save Parts 1–6 as one commit. Line by line:
cd ~/codex-course/workshop moves Terminal into your workshop folder. Every Git command works on the folder you are standing in, so this line matters.git add -A stages every new, changed and deleted file, meaning “include all of this in the next snapshot”.git commit -m "Parts 1-6 done" saves the snapshot with that message.git branch --show-current prints the name of the branch you are on. You need this name in step 6.cd ~/codex-course/workshop git add -A git commit -m "Parts 1-6 done" git branch --show-current
A branch is a named line of history inside a repo. The main line is usually called master or main; that is where the “official” version of the project lives. When you want to try a change without disturbing the main line, you create a second branch, work there, and merge it back only when it is ready. In this guide Codex will create its own branch for the issue it works on, so your master stays clean until you decide to accept the change.
A commit summary such as [master a1b2c3d] Parts 1-6 done followed by a count of files changed, or nothing to commit, working tree clean if you had already committed everything. Both are fine. The last line prints your branch name: master or main. Remember which one you have; the Codex chips in step 6 will show the same name.
Older Git versions name the first branch master, newer ones main. Nothing in this guide depends on which one you have. Wherever I write master, read it as “your main branch”.
Now we create the online copy. One gh command creates a private repo called codex-course-workshop in your account, connects your local folder to it, and uploads your commits. Line by line:
cd ~/codex-course/workshop: make sure you are in the workshop folder.gh repo create codex-course-workshop --private --source . --push: codex-course-workshop is the name of the new repo on GitHub. --private means only you can see it. --source . means “the code is the folder I am standing in” (the dot is the current folder). --push means “upload my commits right now”. Without --push you would get an empty repo online.gh repo view --json url -q .url asks GitHub for the repo's details in JSON format and picks out only the url field. The result is the web address of your repo. You will paste that address into two prompts later, so keep this Terminal window open or copy the URL somewhere.cd ~/codex-course/workshop gh repo create codex-course-workshop --private --source . --push gh repo view --json url -q .url
Your local repo can remember the address of an online copy. That saved address is called a remote, and by convention the main remote is named origin. Push means “send my local commits to the remote”, and pull means the opposite, “fetch commits from the remote into my local copy”. So after this step you have two copies of the same history: one in ~/codex-course/workshop and one on GitHub, and git push is how you keep the online one up to date. When Codex finishes its work later, it will push its branch to this same origin.
Three green ticks: ✓ Created repository <you>/codex-course-workshop on GitHub, ✓ Added remote … origin, ✓ Pushed commits to …. Then the last command prints the URL on its own line, for example https://github.com/<you>/codex-course-workshop. Open it in your browser if you like: you will see all eight part-* folders and your commit message “Parts 1-6 done”.
If GitHub says a repo with that name already exists in your account, pick another name (for example codex-course-workshop-2) and use it everywhere this guide says codex-course-workshop, including inside the two prompts.
Now we set up a small office drama in your issue tracker, because it makes a real point about how agents respond to tickets. Issue #1 is a concrete ticket: the CTO wants the whole app moved from hand-written SQL to Drizzle, an ORM, and the acceptance criteria say exactly when the work is done. Then the CEO cancels it, so we close the issue with a comment. Later, in step 10, we reopen it. Run this from inside the workshop folder, so gh knows which repo the issue belongs to. Line by line:
gh issue create --title "…" --body "…" creates the issue. --title is the headline you see in the issue list. --body is the description. The body spans several lines inside one pair of quotes; ## Acceptance Criteria is a Markdown heading, so it shows as a bold heading on GitHub.gh issue close 1 --comment "…" closes issue number 1 and adds the CEO's comment at the same time.cd ~/codex-course/workshop gh issue create --title "Refactor application to use Drizzle instead of raw Postgres" --body "CTO looked at the repo, decided that raw SQL isn't good, and wants to refactor to use Drizzle as an ORM. ## Acceptance Criteria No more raw SQL in the application - only using Drizzle across all services." gh issue close 1 --comment "Closed as not doing - CEO got wind of this and thought we'd be burning too many tokens that we get for basically free anyways."
An issue is a ticket attached to a repo: a bug report, a feature request or a task, with a number, a title, a description and a comment thread. Teams use issues as their to-do list, and “issue #1” becomes the shared name for a piece of work. An issue can be open (still to do) or closed (done, or decided against). Good issues have acceptance criteria: a short, checkable statement of what “done” means. You will see in this guide that an agent treats a ticket with clear acceptance criteria very differently from a ticket that only asks a question.
Until now our app talks to PostgreSQL with hand-written SQL strings, such as SELECT * FROM auctions WHERE id = $1. An ORM (object-relational mapper) is a library that lets you describe your tables in code and then write database operations as normal function calls, for example db.select().from(auctions).where(eq(auctions.id, id)). The ORM turns that into SQL for you. The benefit is type safety: if you misspell a column or pass a string where a number belongs, the TypeScript compiler catches it before the code runs. The cost is one more layer to learn and debug. Drizzle is a popular, lightweight ORM for TypeScript that stays very close to SQL. Part 6's rules currently say “use plain pg”, meaning the raw driver, so this ticket asks for a real change of direction.
First the new issue's URL, ending in /issues/1. Then ✓ Closed issue <you>/codex-course-workshop#1 (Refactor application to use Drizzle instead of raw Postgres). The number is 1 because this is the first issue ever created in this repo; that is why we create the issues in this exact order.
While the paste runs, Terminal may show dquote> at the start of the lines inside the quotes. That is Terminal telling you “I am still inside a double-quoted string”. It is normal and the command completes once the closing quote arrives.
Issue #2 is the one we point the goal at first. Notice the difference from issue #1: it does not ask for code. It asks a question, “should we use an ORM?”, and its acceptance criterion is “figure it out”. I want you to see what an agent does with a ticket like this. Stay in the workshop folder from the previous step. Line by line:
gh issue create --title "…" --body "…" creates the second issue, exactly as before.gh issue list --state all lists the repo's issues. By default gh issue list shows only open issues; --state all includes the closed one too, so you can check both numbers at once.gh issue create --title "Feature request: should we use an ORM instead of raw SQL?" --body "## Acceptance criteria Figure out if we should replace the SQL in this application with an ORM so that we get better safety throughout." gh issue list --state all
A URL ending in /issues/2, then a table with both issues: #2 OPEN Feature request: should we use an ORM instead of raw SQL? and #1 CLOSED Refactor application to use Drizzle instead of raw Postgres. Your numbers now match the numbers used in the prompts below, so the only thing you need to change in those prompts is your GitHub username.
Why this matters: in a real team the ticket is the contract between the person who asks and the person (or agent) who builds. The clearer the acceptance criteria, the less guessing happens. Keep that in mind while you watch what Codex does with issue #2 versus issue #1.
Switch to the Codex app. Click New chat in the sidebar and check that the project shown at the top is workshop. Above the message box there is a row of small chips, something like workshop · Local · master. The middle chip says where the chat's code lives. Click Local: a small menu opens. Choose New local worktree. A branch picker may appear; leave it on master (or main, whatever step 2 printed). Nothing is created yet; the worktree appears when you send your first message.
Normally one repo folder shows one branch at a time. If you switch branches, the files in the folder change under your feet. A worktree is a second folder, linked to the same repo and the same history, checked out on its own branch. So your ~/codex-course/workshop folder stays on master exactly as it is, while Codex works in a separate folder on its own branch. Two benefits: Codex cannot accidentally break the copy you are using in other chats, and you can run Part 7 in one chat while the goal edits Part 6 in another, at the same time. When the goal is done, its work reaches you as a pushed branch and a pull request, not as surprise edits in your folder.
The chips above the message box now read workshop · New local worktree · No environment · master. The model picker still shows 5.6 Sol Medium.
If your Codex version does not offer New local worktree, stay on Local. The goal then works in your normal workshop folder and creates its branch there. Because you committed in step 2, you can always return to that commit if something goes wrong. The only real difference is that you should not run Part 7 in a second chat at the same time.
Copy the prompt below, paste it into the message box, and replace YOUR-GITHUB-USERNAME with your GitHub username (the one gh auth status printed). Then send. The prompt starts with /goal. When you type /goal in Codex, a small menu pops up showing Goal: Set a goal to keep pursuing; that is the command we want. Let me explain the prompt phrase by phrase, because every part is there for a reason:
gh issue view 2 to do this.gh login from step 1 lives outside that sandbox. This phrase gives Codex permission to step outside for the GitHub commands. Without it, gh would fail with “not logged in”./goal pull in issue 2 from github (use the gh credentials outside of the sandbox) for this repo (https://github.com/YOUR-GITHUB-USERNAME/codex-course-workshop) and please start work on it OR grill me (minimally) with questions
A normal Codex message is one turn: you ask, it answers, it stops. A goal is different. You give Codex an outcome, and it keeps working, planning its own steps, running commands, checking results and re-planning, until it believes the outcome is reached. Under the hood it keeps its own task list and updates that list as it learns more about the code. While a goal runs you can still type in the same chat; your messages are read and folded into the plan without stopping the work. Goals shine for big, broad outcomes with a clear finish line (“close this ticket and open a PR”). They are a poor fit for step-by-step instructions, where a normal chat gives you more control.
/goal) and a Save button. You can change the goal text here while it runs; we don't need to.gh issue view 2 --repo <you>/codex-course-workshop --json number,title,body,… and sums the ticket up: issue #2 asks whether an ORM would improve safety.part-6-async-close-rabbitmq, the newest part) and carry on without waiting for you.If Codex asks permission to run gh outside the sandbox, approve it. That is exactly what “use the gh credentials outside of the sandbox” asked for.
If you don't see /goal in your Codex version, send the same prompt without the /goal prefix. Codex does the same work as a normal chat; it just will not keep a goal running in the background.
A goal keeps working until it is done, so it can use many tokens with no further input from you. This first goal is small: about 4 minutes in my run. The second one, in step 11, is much bigger, and I give you a cheaper option there.
Read the prompt from step 7 again. It never said “open a pull request”. That is deliberate, because I want to show you that a running goal can be steered. While the Pursuing goal bar is still showing, paste this message into the same chat and send it. Codex reads it without stopping and adds “open a PR” to its plan.
open a PR when you're confident you're done with the issue
A pull request is how a change gets from a branch into the main line in a team. You push your branch to GitHub and open a PR that says “please pull these commits into master”. The PR page shows a description, the full list of changed lines (red for removed, green for added), the commits, and a comment thread where teammates review the work. Nothing is merged until a human clicks Merge. For an AI agent this is the perfect hand-off point: the agent proposes, you review, you decide. In guide 24 you will review a PR properly; here you only need to see one get created.
Codex replies with something like “I'll carry this through to a PR…”. A step counter appears on the goal bar (Step 1 / 4, later Step 3 / 4). Watching the activity, you will see it read Part 6, notice that Part 6's AGENTS.md requires plain pg (so an ORM would break the part's own rules), write a short decision record instead of changing code, run the server and web tests to prove nothing broke, then push a branch and open the PR.
If Codex pauses to ask approval for git push or gh pr create, approve it. Both need your GitHub login, which is why they may trigger a prompt even with “Approve for me” on.
Why this matters: in a real team, work does not land by an agent editing master directly. It lands through a PR that a person reads. Getting into the habit of saying “open a PR” keeps you in control.
When the Pursuing goal bar disappears, the goal is finished. Scroll to the bottom of the chat and read Codex's summary. Below it there is a file card for the file it changed; click Review on that card and a side panel opens showing the diff, with added lines in green. Read the decision record; it is short and it explains why Codex chose not to add an ORM.
Then open the PR on GitHub. Line by line:
cd ~/codex-course/workshop: into the workshop folder, so gh knows the repo.gh pr list lists the open pull requests with their numbers and titles.gh pr view 3 --web opens PR number 3 in your browser. Use the number that gh pr list shows you; in my run it was #3, because issues and PRs share one numbering sequence in a GitHub repo and we already used #1 and #2.cd ~/codex-course/workshop gh pr list gh pr view 3 --web
An ADR is a short Markdown file that records one technical decision: what we decided, what the alternatives were, and why. It lives in the repo, usually under docs/adr/, numbered in order (0001-…, 0002-…). The point is memory: six months later nobody remembers why the team kept raw SQL, but the ADR does. Codex writing an ADR instead of code here is the correct response to a question-type ticket: the deliverable is a decision, not a feature.
In Codex, something like: PR opened: #3 — Document the ORM decision for Part 6, Recommendation: keep plain pg, Changed: ADR 0002, a list of the checks that passed (server tests, web tests, TypeScript checks), a Mermaid architecture diagram, a card Edited 0002-keep-plain-pg-instead-of-an-orm.md +29 -0, and at the very end Goal achieved in … (3m 53s in my run).
On GitHub: an open PR whose Files changed tab shows one new file in Part 6's docs/adr/ folder. The PR wants to merge a branch into master. Do not merge it; we leave it open as a record.
Codex can run several chats at once, and goals are made for that. I usually start Part 7 in a second chat while a goal is still working. That Part 7 prompt is in the next guide (step 2, after a one-minute setup step). You can start it now or after this guide finishes; either order works.
Look at what happened: the vague question in issue #2 got an answer (an ADR saying “keep plain pg”), not code. That is fine and honest, but our story needs code. So we make the concrete ticket live again: the CTO overrules the CEO and issue #1 is back on. First run the command below; it opens issue #1 in your browser (--web means “open in the browser instead of printing in Terminal”). On the issue page, scroll to the bottom to the comment box, paste the comment text, then click Reopen with comment. The button reads Reopen issue while the box is empty and changes its label as soon as you type.
cd ~/codex-course/workshop && gh issue view 1 --web
CTO overrode CEO, we're goin' live!
Issue #1 now shows a green Open badge at the top, and your comment “CTO overrode CEO, we're goin' live!” sits at the bottom of the thread, under the earlier “Closed as not doing” comment. The full history stays visible: the decision trail is never lost.
Go back to the goal chat in Codex. In the sidebar it has been given a name based on its first message, something like Pull GitHub issue 2. Paste the prompt below, replace YOUR-GITHUB-USERNAME again, and send. We give it the direct link to issue #1 this time, and we tell it plainly what to do: refactor to Drizzle. Starting the message with /goal makes sure it runs as a new goal, with its own plan and its own Pursuing goal bar, rather than as a normal chat message.
/goal check out issue https://github.com/YOUR-GITHUB-USERNAME/codex-course-workshop/issues/1, we're doing it anyways. please refactor to use Drizzle.
Sent as goal and a new Pursuing goal check out issue … bar. Codex reads issue #1 and restates the acceptance criteria in its own words (“Drizzle across every service with no application-level raw SQL”), makes a plan (Step 1 / 5) and checks which Drizzle versions are current.
It may stop and ask you to approve creating the local branch issue-1-drizzle-refactor from master. Leave it waiting; guide 23 has the reply and the right moment to send it. If yours doesn't ask, it simply keeps going, and that is fine too.
This is a real refactor of all of Part 6: every service, every worker, every test. In my run it took about 17 minutes and about 332,000 tokens. If you want to save money, click the trash icon on the Pursuing goal bar now to clear the goal instead. In guide 24 you can then review your small ADR PR (#3) in place of the Drizzle one; I mark which steps to skip there.
Part 6 isn't finished? The goal works on Part 6, so catch up before step 2. The reference folder holds the end state of the whole part (all slices done). The first line below replaces your Part 6 with the reference copy and commits it. The second line pushes that commit to GitHub if you already created the repo in step 3; if you haven't yet, it fails quietly (2>/dev/null hides the error, || true stops it from counting as a failure) and you simply continue with step 3.
Want to redo the goal? Clear it with the trash icon on the Pursuing goal bar, then close its PR and delete its branch with gh pr close 3 --delete-branch (use your own PR number). Then start again from step 6.
cd ~/codex-course/workshop && rm -rf part-6-async-close-rabbitmq && cp -R ../reference/part-6-async-close-rabbitmq ./ && git add -A && git commit -m "Catch up: part 6 from reference" git push 2>/dev/null || true
gh says “not logged in” inside Codex? Your prompt must contain “use the gh credentials outside of the sandbox”, and you must approve the request when Codex asks. Check gh auth status in Terminal as well.
gh CLI here; an MCP server for Jira) and access to the code (a repo it can push to)./goal keeps Codex working until the outcome is met, planning and re-planning on its own. It suits big, broad goals with clear success criteria, not step-by-step instructions. You can steer a running goal by just typing in the chat.master. Always ask for a PR, and always name the exact repo, because your GitHub login gives Codex access to every repo you own.