- Step 1 of 12 in the series "Claude Code and Codex, in order"
Install Claude Code and Codex, Then Run a First Task

A coding agent is worth installing once you can hand it a small job and check the result in under five minutes. This lab gets you there with both Claude Code and OpenAI's Codex CLI, which are coding agents you run in the terminal. You'll install each one, sign in, give both the same broken test to fix, and read what they changed before you keep it.
The install and sign-in steps come from the vendors' own docs, read on September 26, 2026. The practice project and its test output were run on Node 22. The one thing you won't see here is the agent's fix, because the model writes a new one every time. The test tells you whether that fix works.
What you need
- A terminal on macOS, Linux, or Windows. Claude Code also runs under WSL.
- Node 22 or later for the scratch repo. The agents don't need Node if you use their native installers.
- Git, because both agents are built to work inside a Git repository, and you'll check their work with
git diff, which shows every line that changed. - An account for each tool. Claude Code accepts a Claude Pro, Max, Team, or Enterprise subscription, a Claude Console account billed per token, or a supported cloud provider (Claude Code quickstart). Codex accepts a ChatGPT sign-in on Plus, Pro, Business, Edu, or Enterprise, or an OpenAI API key (Codex README).
Which account you use also decides how you pay. A subscription gives you a set amount of use for a monthly price. An API key charges for every token, the small chunks of text the model reads and writes, at API rates. The Codex authentication docs spell this out for Codex. If you're not sure which is cheaper for how much you'll use it, the coding agent cost calculator puts a month of API usage next to the subscription price.
Step 1: install Claude Code
Anthropic recommends its own installer. On macOS, Linux, or WSL:
curl -fsSL https://claude.ai/install.sh | bash
On Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
If you use Homebrew, you can run brew install --cask claude-code instead. The quickstart notes one difference: the official installer keeps itself updated in the background, while Homebrew and WinGet installs need you to upgrade them by hand.
Open a new terminal and confirm:
claude --version
You should see a version number followed by (Claude Code). If the terminal says claude isn't found, it doesn't know where the program was installed yet. That list of places it looks is called your PATH. The troubleshooting page covers that fix.
Step 2: install Codex
The Codex CLI has four documented install paths (Codex CLI docs):
# macOS or Linux, standalone installer
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# npm
npm install -g @openai/codex
# Homebrew
brew install --cask codex
On Windows, the standalone installer runs from PowerShell:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Pick one install method per tool. With two copies installed, you can end up running the older one without noticing. That's why Claude Code's /doctor checkup looks for duplicate or leftover installs.
Step 3: build the scratch repo
Don't point a new agent at real work on day one. Build a tiny practice project with one broken function and a test that catches it. Then one command tells you whether the agent finished the job.
mkdir agent-scratch && cd agent-scratch
git init -b main
mkdir src test
Create package.json:
{
"name": "agent-scratch",
"version": "1.0.0",
"type": "module",
"scripts": {
"test": "node --test"
}
}
Create src/slugify.js. The function should turn a title into a URL-friendly slug, like coding-agents-in-order. The bug is on purpose: replace with a plain string only swaps the first space.
export function slugify(title) {
return title.toLowerCase().replace(" ", "-");
}
Create test/slugify.test.js:
import test from "node:test";
import assert from "node:assert/strict";
import { slugify } from "../src/slugify.js";
test("lowercases a single word", () => {
assert.equal(slugify("Agents"), "agents");
});
test("joins words with hyphens", () => {
assert.equal(slugify("Coding Agents In Order"), "coding-agents-in-order");
});
test("drops punctuation and extra spaces", () => {
assert.equal(slugify(" Plan first, then edit! "), "plan-first-then-edit");
});
Commit it. Now every change the agent makes will show up as a difference from this clean starting point:
git add -A
git commit -m "Scratch repo with a failing slugify test"
npm test
Expected output, trimmed to the lines that matter (Node 22.23.1, September 26, 2026):
ok 1 - lowercases a single word
not ok 2 - joins words with hyphens
not ok 3 - drops punctuation and extra spaces
# pass 1
# fail 2
That commit is your checkpoint, a saved state you can always go back to. Codex's own getting-started page recommends a Git checkpoint before and after each task, and the advice works for both tools. The git workflows guide later in this series turns that into a routine.
Step 4: sign in and run the task with Claude Code
From inside agent-scratch, start a session:
claude
On first use Claude Code opens a browser sign-in for a subscription or Console account. If ANTHROPIC_API_KEY is set, it asks you to approve that key instead. Type /login later to switch accounts.
Now give it the task. Be specific. Say what to run, what to fix, what not to touch, and what to show you:
Run npm test. Two tests fail. Fix slugify in src/slugify.js so all three
tests pass. Do not edit anything under test/. Show me the final test output.
Watch how it asks for permission. Which mode a session starts in depends on your version, plan, and settings.
The docs say that from v2.1.283, interactive terminal sessions start in auto mode. In auto mode, a separate checker model reviews each action instead of asking you. In Manual mode (config value default), only reading files happens without asking (permission modes).
For a first task, press Shift+Tab until you see a mode that asks before editing. You learn more from approving three edits than from watching them fly past.
When it finishes, type /diff. It shows every file change since your last commit, including everything Claude edited, without leaving the session.
Step 5: reset and run the same task with Codex
Throw away Claude's fix so Codex starts from the same broken state:
git restore src/slugify.js
npm test # back to 1 pass, 2 fail
codex
The first time Codex runs, choose Sign in with ChatGPT or use an API key. For scripts and automated builds, the documented way to use a key is to pipe it in: printenv OPENAI_API_KEY | codex login --with-api-key. Run codex login status to see which method is active.
Codex checks whether the folder is a Git repository. If it is, Codex recommends the Auto preset. If not, it recommends read-only (Codex approvals and security).
In Auto, Codex can edit files and run commands inside the folder, and it asks before touching anything outside it or going on the internet. Internet access is off by default. Type /status to see the active model, the approval setting, and which folders it can write to.
Paste the same prompt. When it's done, type /diff. Codex's version shows every change since your commit, including brand-new files Git isn't tracking yet.
Step 6: read the diff before you believe the summary
Both agents finish with a confident summary of what they did. Skip it, and check three things in this order.
- Run the test yourself.
npm testshould now print# pass 3and# fail 0. If the agent said it passed and your run says otherwise, the agent's summary is wrong, not your terminal. - Check which files changed.
git status --shortshould list exactly one modified file,M src/slugify.js. A change undertest/means the agent made the test pass by changing the test. Check for that on every task, not just this one. - Read the function. Any correct fix has to handle three things: repeated spaces, leading and trailing spaces, and punctuation. Here is one reference fix that passes all three tests:
export function slugify(title) {
return title
.toLowerCase()
.replace(/[^a-z0-9\s-]/g, "")
.trim()
.replace(/\s+/g, "-");
}
With that fix, git diff --stat reports 1 file changed, 5 insertions(+), 1 deletion(-). Your agent's fix will look different, and that's fine. What matters is that the tests pass, only src/slugify.js changed, and you can explain each line.
If you want a second opinion before you commit, both tools have a review command. Claude Code's /code-review (alias /review) checks your current changes for bugs. Codex's /review starts a separate reviewer that reports what it finds without changing your files (Claude Code commands, Codex slash commands).
Where each tool put you
| Claude Code | Codex CLI | |
|---|---|---|
| Install | Native installer, Homebrew, WinGet, Linux package managers | Standalone installer, npm, Homebrew |
| Sign-in | Claude subscription, Console account, cloud provider, or ANTHROPIC_API_KEY | ChatGPT plan, or API key through codex login --with-api-key |
| Starting permissions | Depends on version, plan and settings. Cycle with Shift+Tab | Auto in a Git repo, read-only outside one. Change with /permissions |
| See the diff | /diff | /diff |
| Built-in review | /code-review or /review | /review |
| Undo inside the tool | /rewind restores Claude's file edits to a checkpoint | Revert with Git |
Sources: the Claude Code quickstart, permission modes, and commands pages, and the Codex CLI, auth, approvals, and slash-command pages, all read September 26, 2026. Both tools ship often, so check claude --version and codex --version against the docs if a command here doesn't match.
What to try next
Change one thing about the task and run it again. Delete the Do not edit anything under test/ line and see whether either agent goes for the test file. If the two runs behave differently, that's the reason to write your project's rules down where the agent reads them every time, which is the next step in this series.
The same habit, a failing test first and then a fix you read, runs through the Copilot lab on this site, fixing a stale-delete bug you can verify. For how the two terminal agents differ from an editor assistant, see Claude Code vs GitHub Copilot.
Next in the series: CLAUDE.md and AGENTS.md for coding agents.


