Complete practical guide Β· Claude Code & Codex
Same agent.
Three places to
put it to work.
Claude Code and Codex each run as an editor extension, a terminal process, and a standalone desktop app. Most people install one, use it like autocomplete, and never find out what the other two are for. This page fixes that. π
You watch the code change. Tight loop, small diffs, you review every line.
Longer autonomous runs, scripts, CI β anything not tied to one open file.
Work spanning files, docs and tools rather than a repo. Runs while you do something else.
Who this is for: a developer with VS Code or Visual Studio already open, who wants to stop guessing which tool to reach for. Every command below is one you can actually paste.
02 Β· The differences, up front
β‘ Claude Code vs Codex
They solve the same problem and they've converged hard. The differences that actually affect your day are in how you configure them, how they handle permissions, and what happens when you want to step away.
π Claude Code
Anthropic
Its strength: configurability. Fine-grained per-tool permission rules, custom slash commands, named subagents, and lifecycle hooks all live as files in your repo β so a team can share one agent setup the way they share a lint config.
Its shape: deepest in the terminal, with the editor extension as a viewer and context source layered on top.
π’ Codex
OpenAI
Its strength: the sandbox and the handoff. Approval modes are a single clear dial rather than a rules file, and local work can be pushed to a cloud container that keeps running and opens a PR when it's done.
Its shape: the IDE extension is the front door, with the CLI and cloud as the same session viewed from elsewhere.
π Side by side
| What | π Claude Code | π’ Codex | Why it matters to you |
|---|---|---|---|
| Made by | Anthropic | OpenAI | Determines which subscription covers it. |
| How you pay | Claude Pro / Max / Team plan, or Anthropic API billing | ChatGPT Plus / Pro / Business plan, or OpenAI API billing | The single biggest decider. Use what you already pay for before comparing anything else. |
| Terminal | claude | codex | Both are the full-power surface. Neither is a cut-down version. |
| Editor support | VS Code + JetBrains extensions | VS Code and its forks (Cursor, Windsurf) | If you're a JetBrains/Rider shop, that narrows it fast. |
| Away-from-desk mode | Claude desktop app (Code tab + Cowork), plus the mobile app | Codex cloud tasks β runs in a container, opens a PR | Different philosophies: one gives you a workspace, the other gives you a build server. |
| Project memory file | CLAUDE.md | AGENTS.md | Same job. Keep both if your team is mixed. |
| Config file | .claude/settings.json | ~/.codex/config.toml | Claude's is per-repo and committable; Codex's is per-machine. |
| Permission model | Allow/deny rules per tool and per command pattern | Three approval modes + an OS-level sandbox | Claude = precise but you write rules. Codex = simpler, safer default. |
| Custom commands | Markdown files in .claude/commands/ become slash commands | Reusable prompt files | Claude's version is shared via git, which is why teams standardise on it. |
| Subagents & hooks | Yes β named subagents, lifecycle hooks | Not in the same form | Only matters once you're automating the agent itself. |
| MCP servers | Yes | Yes | Both can reach your DB, Jira, Sentry, docs. No differentiator. |
This table ages fast. Both tools ship near-weekly and feature gaps close within a release or two. Treat it as a snapshot for orientation, not a purchasing decision β and check the docs for anything you'd actually bet on.
03 Β· The straight answer
π What a developer should actually use
If you want to skip the deliberation: pick the one your subscription already covers, install both its CLI and its editor extension, and commit a memory file to the repo. That's 90% of the value. Everything else is refinement.
π₯ Minimum
15 minutes
- Editor extension installed
- Signed in
- You use it to ask questions about code you're looking at
Real but small gains. This is where most people stop.
π₯ The 80% setup
One afternoon
- CLI and extension, connected
CLAUDE.md/AGENTS.mdcommitted- Permissions set to workspace-only
- Plan-before-code as a habit
- Clean git status before every run
π Power
Ongoing
- Custom slash commands in the repo
- MCP servers for your DB and tracker
- Desktop app for parallel background work
- Git worktrees so two agents can run at once
ποΈ What that looks like on a normal day
| When | What you do | Where |
|---|---|---|
| β 9:00 | Hand off the boring chore you've been avoiding β dep bumps, a mechanical refactor | Desktop / CLI |
| π» 9:15 | Feature work. Ask questions, plan, edit, review each diff as it lands | Extension |
| π 11:30 | Check the morning's delegated branch, review it properly, finish the last 10% | Extension |
| π§ͺ 14:00 | Big cross-cutting change β commit-per-package, unattended | CLI |
| π 16:30 | Self-review the whole diff before opening the PR | Extension |
The pattern to internalise: mechanical work goes where nobody is watching; judgement work stays where you can see the diff. Almost every "the agent wrecked my codebase" story is someone who put the second kind in the first place.
04 Β· Decide per task
π§ Pick a surface by the shape of the task
Once both are installed, the live question is "how much of this do I need to watch?" That one answer picks your surface, and it changes several times a day.
| What you're doing | Where it belongs | Why |
|---|---|---|
| π Fixing a bug in a file that's open | Extension | It inherits your selection and the errors already on screen. |
| π "Why does this module exist?" | Extension | Answers land right next to the code you're pointing at. |
| βοΈ Rename a concept across 40 files | CLI | Long run, many edits, nothing gained by watching one tab. |
| ποΈ Migration + tests + changelog | CLI | Multi-step, and it will want to run commands repeatedly. |
| π¦ Same fix across three repos | Desktop | Parallel sessions, no single project root. |
| π Turn a spec doc into a plan and a sheet | Desktop | Not a repo task at all β files and documents, not code. |
| π± Kick off work from your phone at 11pm | Desktop | The editor isn't open. That's the whole point. |
Don't run two agents on the same files at once. Two processes editing one working tree makes conflicts that cost more to untangle than the task was worth. Give each a separate branch or git worktree.
05 Β· Before you install
π¦ Versions & requirements
Most failed installs are one of three things: Node too old, a global npm install fought with permissions, or the account doesn't actually have access. Check these first.
| Requirement | Version | Notes |
|---|---|---|
| π© Node.js | 18 or newer 20 or 22 LTS recommended | Needed for the npm install route for both tools. node --version to check. |
| π macOS | 10.15+ | Fully supported. Homebrew install also available for Codex. |
| π§ Linux | Ubuntu 20.04+ / Debian 10+ | Equivalent distros fine. |
| πͺ Windows | Windows 10+ | Runs natively now; WSL2 still works and is sometimes smoother for POSIX-heavy repos. |
| π§ RAM | 4 GB+ | The model runs remotely β this is just for the local process. |
| πΏ Git | 2.23+ | Optional but strongly recommended. Your undo button is git checkout . |
| π§© VS Code | Keep it current | Extensions target recent releases; a year-old VS Code will fight you. |
| π Account | Paid plan or API billing | Claude: Pro/Max/Team. Codex: ChatGPT Plus/Pro/Business. Free tiers generally don't include agentic coding. |
π§ Install, check and update
# --- Claude Code --- npm install -g @anthropic-ai/claude-code # install claude --version # check claude update # update claude doctor # diagnose a broken install # --- Codex --- npm install -g @openai/codex # install (brew also available) codex --version npm install -g @openai/codex@latest # update # --- sanity check your Node --- node --version # must be v18.x or higher
Never install these with sudo. A root-owned global npm directory causes permission errors on every later update and is a genuine security footgun. If npm install -g gives you EACCES, fix the npm prefix instead:
npm config set prefix ~/.npm-global then add ~/.npm-global/bin to your PATH.
π‘ Version numbers here reflect what was current in mid-2026 and requirements do get raised β claude doctor and the official install docs are the authority if something won't start.
06 Β· Setup
π§© Getting both running in VS Code
Fifteen minutes, once. The install is the boring part β the habits at the end are where the value is.
β Claude Code
Install the CLI first β the extension talks to it.
# 1 Β· install the CLI npm install -g @anthropic-ai/claude-code # 2 Β· go to your project root β this defines the workspace cd ~/code/my-project # 3 Β· first run signs you in claude
Now install the Claude Code extension from the VS Code marketplace β or just run claude in VS Code's integrated terminal and it'll offer to install it for you. Then connect the two:
/ide # attach this session to the editor /init # scan the repo and write a CLAUDE.md /status # confirm the IDE shows as connected
Press Ctrl+Esc (β+Esc on Mac) to open the panel from anywhere. With the IDE connection live you get three things a bare terminal can't:
- β Your current selection is passed as context automatically
- β Edits open in VS Code's native diff view instead of scrolling past as text
- β Lint and type errors from the Problems panel are visible without pasting
β Codex
Install the Codex extension from the marketplace (it also works in Cursor and Windsurf), then sign in with your ChatGPT account or an API key. For long runs, add the CLI too:
npm install -g @openai/codex cd ~/code/my-project codex
Codex's defining setting is its approval mode. Set it deliberately on day one rather than clicking through prompts:
| Mode | It can | Use it when |
|---|---|---|
| π Read only | Read files and answer. Nothing else without asking. | Unfamiliar repo, or anything near production config. |
| β‘ Auto | Read, edit and run commands inside the workspace. Asks before leaving it or hitting the network. | Your default. Covers ~90% of real work. |
| π Full access | Everything β network calls, writes outside the project. | Rarely. Never in a repo holding live credentials. |
π Make the editor part actually pay off
- Select before you ask. Highlight the function, then open the panel. "Why is this slow?" with a selection beats a paragraph describing where the code lives.
- Use
@to attach files instead of pasting β@src/auth/session.tsgives the live file, not a stale copy. - Let it read your errors. If the Problems panel is red, say "fix the type errors in the Problems panel" rather than copying them one by one.
07 Β· The Windows / .NET case
πͺ Visual Studio 2022 is a different story
Worth being blunt: Visual Studio and VS Code are unrelated products, and the extensions above are VS Code only. As of writing there's no first-party Claude Code or Codex extension for Visual Studio 2022. If you live in VS for .NET or C++, here's what works.
π °οΈ CLI in the integrated terminal
The pragmatic answer, and it loses less than you'd think. View β Terminal, then run claude or codex from your solution folder.
You keep the agent's full capability. You lose the inline diff β but VS reloads changed files automatically and Git's own diff covers review.
π ±οΈ Side-by-side windows
Run the agent in Windows Terminal (or WSL) beside VS. Snap them left and right.
Better for long runs β you can scroll the agent's output without stealing focus from the editor.
# from the folder containing your .sln claude # give it the build commands up front β it can't discover MSBuild alone > Build with: dotnet build MySolution.sln > Test with: dotnet test --no-build
Turn off the file-changed prompts first. Tools β Options β Environment β Documents β tick "Detect when file is changed outside the environment" and "Auto-load changes". Without this, every agent edit throws a modal dialog and the run stalls waiting on you.
π‘ GitHub Copilot's agent mode is the natively integrated option inside Visual Studio if you want inline review without leaving the IDE. Extension availability moves fast β check the Visual Studio Marketplace before assuming the above still holds.
08 Β· Configuration
π Every file that matters, and why
This is the part that separates people who get a lot out of these tools from people who don't. The agent reads a handful of files at startup β and once you own those files, you're configuring behaviour instead of re-explaining yourself in every prompt.
π³ What a well-set-up repo looks like
my-project/ βββ CLAUDE.md β project memory (Claude) Β· commit β βββ AGENTS.md β project memory (Codex) Β· commit β βββ .mcp.json β shared MCP servers Β· commit β βββ .claude/ β βββ settings.json β team permissions + env Β· commit β β βββ settings.local.json β your personal overrides Β· gitignore β β βββ commands/ β β βββ review-pr.md β becomes /review-pr Β· commit β β β βββ add-endpoint.md β becomes /add-endpoint Β· commit β β βββ agents/ β βββ test-writer.md β a named subagent Β· commit β βββ .gitignore β must list the local files βββ src/ # and on your machine, outside any repo: ~/.claude/CLAUDE.md β your preferences, every project ~/.claude/settings.json β your global permissions ~/.codex/config.toml β Codex model, sandbox, approvals ~/.codex/AGENTS.md β your global Codex instructions
| File | What it does | Commit? | Why it's important |
|---|---|---|---|
| CLAUDE.md | Read at the start of every session. Commands, conventions, warnings. | Yes | The highest-leverage file in the repo. Everything you'd otherwise retype daily. |
| AGENTS.md | Same, for Codex. Nested copies in subfolders apply to that subtree. | Yes | Lets a monorepo give different rules per package. |
| .claude/settings.json | Permission allow/deny rules, environment variables, hooks. | Yes | Guardrails become a team asset instead of each person's local habit. |
| .claude/settings.local.json | Your personal overrides on top of the shared file. | No | Lets you loosen things for yourself without loosening them for everyone. |
| .claude/commands/*.md | Each file becomes a slash command in the repo. | Yes | Turns your best prompts into shared tooling. Massively underused. |
| .claude/agents/*.md | Subagents with their own instructions and tool access. | Yes | For repeated specialist work β test writing, migration review. |
| .mcp.json | MCP servers available to anyone in this repo. | Yes | New teammate gets DB and tracker access with zero setup. |
| ~/.claude/CLAUDE.md | Your preferences across every project. | N/A | Style and tone that shouldn't be forced on your team. |
| ~/.codex/config.toml | Codex model, approval policy, sandbox, MCP servers. | N/A | Per-machine, so set your safe defaults here once. |
π CLAUDE.md β the one to write properly
Run /init for a first draft, then edit it hard. Generated versions describe the repo; useful versions describe your conventions and the traps.
# Project: payments-api ## Commands - Install: pnpm install - Test: pnpm test --filter=<package> (never the full suite β 20 min) - Lint: pnpm lint --fix - Typecheck: pnpm typecheck (must pass before you say you're done) ## Conventions - Money is always integer minor units. Never floats. Never a Number for a balance. - Errors: throw AppError from src/errors.ts. Never a bare Error. - New endpoints need a zod schema in src/schemas/ or the router won't register them. ## Do not touch - src/generated/** (codegen output) - migrations/*.sql (already applied β write a new migration instead) ## Notes - The "legacy" folder is still in production. It is not dead code. - If a test needs the DB, use the testcontainers helper, not a mock.
β Keep it short
It's prepended to every session, so a 500-line file quietly costs you context on every request. Ruthless beats thorough.
β Only write what was true when something broke
Aspirational style guides get ignored. "Never run the full suite" β written after it wasted 20 minutes β gets obeyed.
π .claude/settings.json β guardrails as code
Rules are matched by tool and command pattern. Deny rules win. This is how you stop an agent reading your .env without having to remember not to ask it to.
{
"permissions": {
"allow": [
"Bash(pnpm test:*)",
"Bash(pnpm lint:*)",
"Bash(git status)",
"Bash(git diff:*)",
"Read(src/**)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Bash(rm -rf:*)",
"Bash(git push:*)"
]
},
"env": { "NODE_ENV": "development" }
}
β‘ Custom slash commands β the underused one
Any markdown file in .claude/commands/ becomes a slash command for everyone on the repo. $ARGUMENTS picks up whatever you type after it.
--- description: Review staged changes like a senior reviewer --- Review the staged diff. Pay particular attention to: $ARGUMENTS Check for: - unhandled error paths - behaviour changes for existing callers - tests that assert less than they used to - new dependencies that weren't requested Rank findings by severity. Do NOT apply fixes.
Then anyone in the repo types /review-pr security and gets your review standard, not their own improvised one. This is how a team's review quality becomes consistent.
π .mcp.json β give it your real systems
MCP servers let the agent query your database, read tickets, or search internal docs directly instead of you copy-pasting.
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres",
"postgresql://localhost:5432/dev"]
}
}
}
Point MCP servers at dev, never production. A read-only replica is the most access an agent should ever have to a real database β and put the connection string in an env var, not the committed file.
βοΈ ~/.codex/config.toml
# model names change β check `codex --help` or the docs for current values model = "..." # safe default: can edit inside the workspace, asks for anything else approval_policy = "on-request" sandbox_mode = "workspace-write" [sandbox_workspace_write] network_access = false # turn on only when a task truly needs it
π .gitignore additions
# agent config β keep personal overrides out of the repo
.claude/settings.local.json
CLAUDE.local.md
If you do only one thing from this section: write a real CLAUDE.md / AGENTS.md and commit it. It costs twenty minutes and it's the difference between an agent that guesses your conventions and one that follows them.
09 Β· Workflow
π The loop that separates useful from annoying
A real sequence β each step exists because skipping it causes a specific failure. Use it for anything bigger than a one-line fix.
-
πΊοΈ Orient before you ask for code
Open with a question, not a task. "Read the checkout flow and tell me where discount codes are validated." You get a map β and you find out immediately whether it understands your codebase, cheaply, before it writes 300 lines on a wrong assumption.
-
π Get a plan in writing
Say "plan only, don't write code yet." In Claude Code, Shift+Tab cycles into plan mode, which enforces it. Read the plan properly: correcting a plan costs one sentence, correcting an implementation costs a review cycle.
-
π‘οΈ Set the blast radius
Decide now what it may do unattended. Claude Code:
/permissions. Codex: pick the approval mode. Familiar repo with clean git status β loosen it. Deploy scripts or real credentials β don't. -
π Let it run β read the diff, not the prose
The agent's summary of what it did is the least reliable artefact in the session. The diff is the truth. In the editor extensions that's one click β which is the main argument for working there.
-
π Review it like a stranger's pull request
Look specifically for: tests weakened to pass, error handling quietly swallowed, a new dependency you didn't ask for, and edits outside the scope you described. Those four cover most of what goes wrong.
-
π Write down what it got wrong
Corrected the same misunderstanding twice? That's a line in
CLAUDE.mdorAGENTS.md. Everyone skips this step, and it's the one that compounds.
10 Β· The other comparison
βοΈ In the IDE vs. the desktop app
Claude's desktop app bundles chat, Cowork (agentic work on files and documents) and Claude Code in one window. Codex has a comparable story with its cloud tasks. The temptation is to treat these as "the same thing, bigger window." They're not β they're built on a different assumption about whether you're watching.
π§© Stay in the IDE whenβ¦
- You'd need to review every line anyway
- The task is scoped to files you can name
- You're learning the codebase, not just shipping
- It's production code with real consequences
π₯οΈ Go to the desktop app whenβ¦
- The task is mechanical and long β bulk migrations, dep bumps
- You want three things running while you're in a meeting
- The work isn't a repo: a report, an analysis, a deck from a spec
- You want to start it from your phone
The genuinely productive pattern is both. Delegate the mechanical pass to the desktop app or CLI, then open that branch in your IDE and use the extension to review and finish it. Bulk work where supervision adds nothing; careful work where it adds everything.
11 Β· Copy these
π― Five prompts that work
Real prompts, not templates. The pattern behind all of them: state the goal, state the constraint, state how you'll know it worked.
βΆπ§Land in an unfamiliar codebaseEditor
Day one on a repo. Don't ask it to explain the whole thing β ask it to trace one real path, which is how you'd actually learn it.
Trace what happens when a user submits the signup form, from the HTTP handler down to the database write. List the files in order, one line each on what that layer is responsible for. Don't change anything. Flag anything that looks like it's there for a reason I wouldn't guess.
βΆπ§ͺFix a failing test without letting it cheatEditor
The failure mode here is famous: the agent makes the test pass by weakening the test. Close that door in the prompt.
`pnpm test auth` fails on "rejects expired tokens". Find the root cause in the source, not the test. Do not modify the test file, and do not add skips. Explain the cause in two sentences before you edit anything, then fix it and re-run that one test.
βΆβ»οΈRefactor across many filesCLI / Desktop
Too big for a supervised loop. Give it checkpoint discipline so a bad turn costs one commit, not the whole run.
Replace every direct `process.env.X` read with the typed config
object in src/config.ts. Work package by package. After each
package: run typecheck, then commit with message
"refactor(config): <package>". If typecheck fails, stop and tell
me β don't move to the next package.
βΆπReview your own work before the PREditor
The best use of an agent in the IDE, and the most underused. It reads the whole diff, which you won't.
Review the diff against main as if you were the reviewer who has to maintain this. Focus on: unhandled error paths, anything that changes behaviour for existing callers, and tests that assert less than the old ones did. Rank findings by severity. Suggest fixes but don't apply them.
π‘ Claude Code has /review as a shortcut β or use your own /review-pr command from the files section.
βΆπ§ΉThe chore you keep postponingDesktop
Perfect delegation candidate: mechanical, well-defined, verifiable, and boring enough that you'll never do it yourself.
Every file in src/routes/ has a copy-pasted try/catch block. Extract it into a single wrapper in src/lib/handler.ts and apply it everywhere. Keep behaviour identical β same status codes, same log lines. Run the full test suite at the end and show me the diff summary grouped by file.
12 Β· Learn these cheaply
β οΈ Things that go wrong
π§ Context rot
Long sessions get worse, not better. Once a conversation holds three abandoned approaches, the agent is reasoning over its own failed attempts. Start fresh at each new task β /clear, or a new conversation. Use /compact only when you genuinely need continuity.
π Never let it commit unreviewed
An agent that can run git commit unattended will eventually commit something you didn't read. Let it stage, let it write the message β keep the commit as your keystroke.
π£ The skip-permissions flag
Claude Code's --dangerously-skip-permissions (and Codex's full-access mode) exist for sandboxed containers and CI. On your laptop, in a repo whose .env talks to production, they're a genuinely bad idea. If a run needs that much freedom, run it in a container.
π It will confidently claim it's done
"All tests pass" is a claim, not a result. Put verification in the prompt β "run the tests and paste the output" β and actually read the output.
πΈ Cost tracks context, not messages
A 40-message session on a small file is cheap. One message that pulls in a 4,000-line file isn't. Attach the specific file, not the folder. /cost shows where a session went.
The habit that beats all of the above: commit before you let an agent start. A clean git status means the worst outcome of any run is git checkout . β and knowing that changes how boldly you'll use it.
13 Β· Reference
ποΈ Cheat sheet
β¨οΈ Claude Code β in-session
| Command | Does |
|---|---|
/init | Generate a starter CLAUDE.md from the repo |
/ide | Connect the session to your editor |
/clear | Wipe context β do this between tasks |
/compact | Summarise the session to free context but keep the thread |
/review | Review the current changes |
/permissions | See and edit what it's allowed to do |
/agents | Manage subagents |
/model | Switch model mid-session |
/cost | Token and cost usage for this session |
/mcp | Manage connected MCP servers |
@path/to/file | Attach a file as live context |
!command | Run a shell command directly |
# note | Append a line to CLAUDE.md without leaving the session |
πΉ Keys worth memorising
| Keys | Does |
|---|---|
| Ctrl/β + Esc | Open the Claude Code panel in VS Code |
| Shift + Tab | Cycle modes β plan mode, auto-accept edits |
| Esc | Interrupt. Use it early and often. |
| Esc Esc | Go back and edit an earlier message |
| Ctrl + C | Quit the session |
π₯οΈ Terminal
| Command | Does |
|---|---|
claude / codex | Start an interactive session in the current folder |
claude --continue | Resume the most recent session here |
claude --resume | Pick from previous sessions |
claude -p "..." | One-shot, non-interactive β good for scripts and CI |
claude mcp add | Connect an MCP server |
claude doctor | Diagnose install problems |
claude update | Update to the latest version |
codex resume | Resume a previous Codex session |
π Files at a glance
| Path | Scope | Commit? |
|---|---|---|
| CLAUDE.md | Project memory (Claude) | Yes |
| AGENTS.md | Project memory (Codex) | Yes |
| .claude/settings.json | Team permissions | Yes |
| .claude/settings.local.json | Personal overrides | No |
| .claude/commands/*.md | Shared slash commands | Yes |
| .mcp.json | Shared MCP servers | Yes |
| ~/.claude/CLAUDE.md | Your global preferences | N/A |
| ~/.codex/config.toml | Codex machine config | N/A |