Install Claude Code and Codex, Then Run a First Task
A coding agent is worth installing when 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: install, sign in, give each one the same failing test, and read what it changed before you keep it.
Everything here comes from the vendors' own docs, read on September 26, 2026. The scratch repo and its test output were run on Node 22. The agent's patch is the one part you won't see reproduced, because a model writes it fresh each time. The test tells you whether that patch 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 designed around a repository and you will review through
git diff. - 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).
The account choice is also a cost choice. A subscription gives you a plan allowance. An API key bills every token at API rates, which the Codex authentication docs spell out for Codex. If you are unsure which is cheaper for your volume, the coding agent cost calculator puts a month of API usage next to the subscription price.
Step 1: install Claude Code
The native installer is Anthropic's recommended path. On macOS, Linux, or WSL:
curl -fsSL https://claude.ai/install.sh | bash
On Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
Homebrew users can run brew install --cask claude-code instead. The quickstart notes that native installs update themselves in the background, while Homebrew and WinGet installs need a manual upgrade.
Open a new terminal and confirm:
claude --version
You should see a version number followed by (Claude Code). If the shell says claude isn't found, the install directory isn't on your PATH yet. 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. Two copies on the PATH means you can end up running the older one without noticing, which is 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. A scratch repo with one failing test gives you a finished task you can judge by a single command.
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 bug is deliberate: replace with a string pattern 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, so every change the agent makes shows up as a diff against a 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. Codex's own getting-started page recommends a Git checkpoint before and after each task so you can revert, and it applies to 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. Specific beats clever here:
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 auto mode, where a classifier reviews actions instead of prompting you, is the built-in start for interactive terminal sessions. In Manual mode (config value default) only reads run 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 the working-tree changes, including everything Claude edited, without leaving the session.
Step 5: reset and run the same task with Codex
Throw away the first agent's fix so Codex starts from the same failing 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 CI 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 under version control. In a Git repo it recommends the Auto preset, which is workspace-write with on-request approvals. Outside one it recommends read-only (Codex approvals and security). In Auto, Codex can edit and run commands inside the folder, and it asks before touching anything outside it or using the network. Network access is off by default. Type /status to see the active model, approval policy, and writable roots.
Paste the same prompt. When it's done, type /diff. Codex's version includes staged changes, unstaged changes, and files Git isn't tracking yet.
Step 6: read the diff before you believe the summary
Both agents end with a confident summary. 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 editing the test, and it's worth checking for 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 patch 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 the current diff for correctness bugs. Codex's /review starts a separate reviewer that reports findings without touching your working tree (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
Make one change to the task and run it again. Delete the Do not edit anything under test/ line and see whether either agent reaches for the test file. The difference between those two runs is the case for writing project instructions down, which is the next step in this series.
The same habit, a failing test first and then a patch 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.
