Lesson 2 of 8 · 15 min · Checked on 6 October 2026
Install and sign in: Claude Code and Codex on Windows, Mac and Linux
By the end of this lesson you will be able to:
- Create the throwaway folder experiencias and always work inside it
- Install Claude Code, Codex or both, with the commands from the official page
- Sign in with an account or with an API key, setting a spending cap first
- Confirm that the agent answers, and leave it
Rita is a teacher and wants to try a coding agent before Christmas. A quarter of an hour later the agent is answering in her terminal, in a folder with nothing to break, and her account is protected against surprises. That is what you do in this lesson.
This is how it looks on 6 October 2026; your screen may differ. Look for the button with the same name. The commands below were copied from the official pages that day; if a page now says otherwise, the page wins.
Before you start
- An account. For Claude Code, a Claude account or a Claude Console account (pay per use). For Codex, a ChatGPT account or an OpenAI API key. Which plans give access: see the Current state page.
- A recent computer. The minimum requirements are on each agent's official page.
- Node.js? Usually not. You only need it if you install with
npm(for Claude Code, version 22 or newer). - On Windows: Claude Code installs from PowerShell (lesson 0/01); in this course, Codex installs inside WSL (lesson 0/02).
First: the throwaway folder
Create the folder for this course's experiments (or go into it, if you created it in lesson 0/01). experiencias is Portuguese for “experiments”; the name stays the same in every lesson so the commands match.
mkdir experiencias
cd experiencias
Always open the agent from here. But note: starting in this folder does not lock the agent inside it. It is the starting point, not a wall: a command you accept can touch other folders on the computer. So read every permission request before you say yes, and never open an agent, while learning, in the folder with your documents, photos or accounts.
Tip
You do not need to install both agents. Pick one to start; the lessons always show both side by side.
Install Claude Code
Official page: Set up Claude Code
On Mac, Linux or WSL:
curl -fsSL https://claude.ai/install.sh | bash
On Windows, in PowerShell:
irm https://claude.ai/install.ps1 | iex
The same page also covers Homebrew and WinGet. On Windows you do not need to be an administrator.
To confirm, close the terminal, open a new one and type:
claude --version
A version number should appear. If something looks odd, claude doctor runs a diagnosis.
Install Codex
Official page: Codex CLI. The code lives in the Codex repository on GitHub.
On Mac, Linux or inside WSL:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
On Windows, install Codex inside WSL, as the official Codex on WSL page shows. If you do not have WSL yet (lesson 0/02), open PowerShell as administrator, type wsl --install and restart if it asks. Then type wsl to enter Linux and, in there, run the command above. WSL has its own folders: create an experiencias there too and open Codex in it.
Alternatives on the same official page: npm install -g @openai/codex (needs Node.js) or brew install --cask codex.
Watch out
These commands download a program and run it straight away. Copy them only from the official page and check the address letter by letter: claude.ai for Claude Code, chatgpt.com for Codex. Never from a video, an email or a message from a stranger.
Sign in: account or key
Claude Code (guide: Claude Code authentication). Inside experiencias, type claude. The first time, the browser opens for you to sign in. If it does not, press c to copy the address and paste it into the browser. If a code appears, paste it into the terminal. At “Login successful”, press Enter.
Codex (guide: Signing in to Codex). Inside experiencias, type codex. On the sign-in screen choose Sign in with ChatGPT (opens the browser) or Use API Key (you paste a key created on the OpenAI API keys page). To see how you are connected: codex login status.
Two ways to pay, and the difference matters:
- Subscription account: you pay a monthly fee and your use has limits inside it.
- API key: you pay for each use, according to what the agent spends.
Watch out
If you choose the API key, turn on a spending cap in the provider's console before you use it. An agent works alone in back-to-back turns and every turn costs: an error that makes it repeat can spend a lot in one afternoon.
- Alert: warns you when spending reaches an amount, but the agent keeps spending.
- Blocking cap: at the amount, requests are refused and the agent stops.
Turn on the cap; the alert is an extra. Leave some margin: OpenAI warns that enforcement is not instant and spending can go slightly over. With the cap on, the bill stays close to the amount you chose, instead of growing without end.
- Claude Console: Settings > Billing, Spend limits section, Set limit button (or Adjust limit). Guide: Anthropic spend limits.
- OpenAI: in the organisation or project limits, under Spend, Edit spend limit: enter the monthly amount and turn on Enforce a hard limit, the option that makes requests fail at the limit. Guide: OpenAI spend limits.
Tip
The API key is a secret. Do not paste it into files you will share, messages or screenshots. Lesson 1/06 explains where to keep it.
The first conversation
Inside experiencias, the agent may ask whether you trust this folder. It is yours and empty: yes. Then type:
What folder are we in and what is inside it? Do not change anything.
To leave: in Claude Code, exit (or Ctrl + D twice); in Codex, /quit or /exit. To see the available commands: /help in Claude Code; in Codex, type just / and the list appears.
Exercise
How I know it worked the agent answers with a path that ends in experiencias, says the folder is empty (or lists what you put there) and does not ask permission to change anything.
If it didn't work
- “not recognised” or “command not found”: close the terminal and open a new one. If it persists, reinstall from the official page; in Claude Code,
claude doctorhelps. - On Windows, “'irm' is not recognized”: you are in CMD, not in PowerShell. Open PowerShell (
Win + X). - On Windows, a guide tells you to change PowerShell's “execution policy”: do not touch that protection here. Install Codex inside WSL, as above.
- HTML code appears, or “syntax error near unexpected token '<'”: the address returned a web page instead of the installer. Check the address and your Internet connection.
- The browser did not open for you to sign in: copy the address shown in the terminal and paste it into the browser yourself.
- The account has no access: see the Current state page for which plans include the agent.
Videos
Shows in 6 minutes how to install Claude Code in VS Code, the terminal and the Desktop app, and which one to choose.
An official Anthropic video on installing Claude Code in the terminal, VS Code, JetBrains, Desktop or the web.
Test what you learned
Corrections to this lesson (1)
- : After an external review: the instruction to bypass the Windows execution policy was removed (the official installation stays); the folder is no longer presented as isolation; the spending cap is now a hard limit that blocks, separate from the alert, with a note that the cut-off is not instant; button names and official links corrected; the sentence «the worst that happens is it stops» was removed. Quiz options were reordered.