Claude Code is a command-line agent from Anthropic. It runs in your terminal, reads your codebase, edits files, and executes shell commands when you give it tasks. This is the install guide: what you need before you start, how to get the binary on your system, and what to do when the setup fails.
Before you install
Three things you need:
An Anthropic account with API access. Claude Code runs against the Anthropic API, not the Claude.ai browser product. If you have only used Claude through the browser, you will need to add billing to your account at console.anthropic.com before Claude Code will run.
Node.js 18 or higher. Claude Code ships as an npm package, and the Node requirement is enforced at runtime. Check your current version with node --version before you start.
A terminal. On macOS: Terminal, iTerm2, Ghostty, Warp, or any shell emulator you already use. On Linux: any standard terminal. On Windows: WSL2 is the recommended path. Native PowerShell or Git Bash also work but involve more setup friction.
Install
npm install -g @anthropic-ai/claude-code
That is the command. If it finishes without errors, the binary is on your system.
On macOS with a Homebrew-managed Node install, global npm packages may fail with a permissions error. Two options: run with sudo, or configure npm to write to a user-writable location:
npm config set prefix ~/.npm-global
export PATH="$HOME/.npm-global/bin:$PATH"
Add the export line to your ~/.zshrc or ~/.bashrc, then reload your shell and run the install again without sudo.
On Linux with nvm, global packages install into your nvm directory, which is already writable. The install usually works without changes.
On Windows, if you are running inside WSL2, install there rather than on the Windows host. If you are in native PowerShell, run as administrator if you see EPERM errors.
First launch and authentication
After install, navigate to a project directory and run:
claude
On first launch, Claude Code opens an authentication flow. It will attempt to open a browser window so you can authorize the CLI against your Anthropic account. After you complete the authorization, control returns to the terminal with an active session.
If the browser does not open, copy the URL printed in the terminal and open it manually. After authorizing, return to the terminal.
Once authenticated, you are in an interactive session in your current directory. Type a task and the agent responds, reads files as needed, and calls tools.
To verify the install worked before starting a session:
claude --version
A version number means the binary is on your PATH and setup completed correctly. "Command not found" means the npm global bin directory is not in your PATH. Run npm config get prefix and add <that prefix>/bin to your PATH.
CLAUDE.md
Claude Code reads a file named CLAUDE.md at your project root at the start of every session. This is the right place to put context the agent would otherwise need re-explaining each time: how to run tests, what the main directories contain, naming conventions, anything you would tell a new developer on day one.
Example:
# This project
Run tests: npm test
Build: npm run build
API routes: /src/api
Models: /src/models
Do not edit: /src/generated
You can also create ~/.claude/CLAUDE.md for settings you want across all projects on this machine: editor preference, general conventions, personal workflow rules.
Keep it short and factual. It loads on every session and occupies context on turns where that content is not relevant.
Choosing a model
Claude Code defaults to Claude Sonnet. You can switch models inside a session using the /model command, or set a default in your config file.
The practical breakdown:
Sonnet is the default. Fast enough for interactive use, capable enough for most coding tasks. Start here.
Opus is the stronger model on reasoning-heavy tasks: architecture decisions, large-context analysis, cases where Sonnet's first pass was clearly inadequate. It runs slower and costs more per token.
Haiku is the fastest option, useful when you are running repetitive tasks and want to control spending. Less accurate on complex multi-step work.
Switch based on whether the model's output quality is the constraint. If Sonnet's result is good enough, there is no reason to switch.
Common failures
"command not found: claude": the npm global bin directory is not in your PATH. Check npm config get prefix, add <prefix>/bin to your PATH.
Node version error on first run: you are on Node older than 18. Upgrade with nvm: nvm install 18 && nvm use 18.
Auth loop does not return: copy the URL from terminal output and open it manually in your browser. After authorizing, return to the terminal.
EPERM error on Windows: your terminal session does not have administrator permissions. Open the terminal as administrator and retry.
Rate limit errors immediately: a newly funded Anthropic account can take a few minutes for billing to activate. Wait a couple of minutes and try again.
When Claude Code is not enough and the problem is bigger than the tool, you can bring in a senior engineer for a week to finish it.