getting started

Installing Claude Code: Complete Setup Guide 2026

Quick Answer

Install Claude Code with `npm install -g @anthropic-ai/claude-code`, then run `claude` and follow the OAuth flow or set ANTHROPIC_API_KEY in your environment. The tool requires Node.js 18+ and works on macOS, Linux, and Windows (via WSL2).

Claude Code is Anthropic's official agentic CLI. It runs in your terminal, reads your codebase, calls tools (file read/write, bash, search), and can autonomously complete multi-step engineering tasks. As of April 2026 it ships as an npm package — no separate binary download required.

Prerequisites: Node.js 18 or later (check with `node --version`). On macOS, install Node via Homebrew (`brew install node`) or nvm. On Ubuntu/Debian, use `curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -`. Windows users must run Claude Code inside WSL2 — the native Windows terminal is not supported.

The global install takes under 30 seconds on a fast connection. After running `npm install -g @anthropic-ai/claude-code`, the `claude` binary is available system-wide. Run `claude --version` to confirm. The first time you run `claude` interactively it will open a browser window for OAuth login with your Anthropic account — no manual API key copy-paste needed for personal use.

For CI, scripts, or headless environments you'll want a static API key. Create one at console.anthropic.com under API Keys. Set `ANTHROPIC_API_KEY=sk-ant-...` in your environment or `.env` file. Claude Code reads this automatically — it does not need a `claude login` step when the env var is present.

Enterprise teams on Claude for Work (Teams/Enterprise plan) should also set `ANTHROPIC_AUTH_TOKEN` to a service-account token instead of a personal API key. This lets you share a single billing identity across all CI runs without distributing personal credentials.

After installation, run `claude doctor` to check that all dependencies are satisfied and the API connection is live. Common failure modes: Node version too old (upgrade to 18+), corporate proxy blocking api.anthropic.com (add proxy settings via `HTTPS_PROXY` env var), or rate-limit errors on the free tier (upgrade plan or set `CLAUDE_MODEL=claude-haiku-4-5` for cheaper exploration).

Examples

Install Claude Code globallybash
# Install
npm install -g @anthropic-ai/claude-code

# Verify
claude --version
# claude-code 1.x.x

# First run — opens browser OAuth
claude

# Or authenticate with API key directly
export ANTHROPIC_API_KEY="sk-ant-api03-..."
claude --print "Hello, Claude"
Set API key in shell profilebash
# Add to ~/.zshrc or ~/.bashrc
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"

# Optional: default model override
export CLAUDE_MODEL="claude-sonnet-4-5"

# Reload
source ~/.zshrc
Install in a Docker image (CI use)bash
FROM node:20-slim

# Install Claude Code
RUN npm install -g @anthropic-ai/claude-code

# API key passed at runtime via --env
# docker run -e ANTHROPIC_API_KEY=sk-ant-... my-image claude --print "..."  
Diagnose installation issuesbash
# Check Node version (need 18+)
node --version

# Check claude is on PATH
which claude

# Test API connectivity
claude doctor

# Upgrade to latest version
npm update -g @anthropic-ai/claude-code

Tips

  • Use nvm to manage Node versions — `nvm use 20` before installing ensures you're on a supported version without affecting your system Node.
  • Pin the Claude Code version in CI with `npm install -g @anthropic-ai/claude-code@1.x.x` to avoid unexpected breaking changes on automated runs.
  • On corporate networks, set `NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.crt` if you get SSL errors — Claude Code uses the Node HTTP stack which respects this env var.
  • If `claude` is not found after install, run `npm bin -g` to see where npm puts global binaries and add that directory to your PATH.
  • Set `CLAUDE_MODEL=claude-haiku-4-5` during initial exploration — Haiku is 10-20x cheaper than Sonnet and fine for orientation tasks.
  • Run `claude --help` to see every flag without opening a session — useful for scripting.

FAQ

Does Claude Code work on Windows?+

Claude Code does not support the native Windows command prompt or PowerShell. You must use WSL2 (Windows Subsystem for Linux). Install WSL2 from the Microsoft Store, then install Node.js inside the Linux environment, and run `npm install -g @anthropic-ai/claude-code` from within WSL.

Is an Anthropic API key required or can I use Claude.ai login?+

For interactive sessions you can log in with your Claude.ai account via the browser OAuth flow that launches on first run — no API key needed. For CI/CD, headless scripts, or the --print flag you must have ANTHROPIC_API_KEY set as an environment variable.

What does the installation actually download?+

The npm package is roughly 15–25 MB and includes the Claude Code binary, a small Node runtime wrapper, and bundled system-prompt assets. It does NOT bundle a local model — all inference happens via Anthropic's API over HTTPS.

How do I update Claude Code?+

Run `npm update -g @anthropic-ai/claude-code`. Claude Code also prompts you to upgrade when a new version is available at the start of an interactive session. You can suppress this with --no-update-check.

Can I install Claude Code without internet access (air-gapped)?+

The npm install requires internet to download the package. In fully air-gapped environments you can use `npm pack` on a connected machine to produce a .tgz, then install from that tarball offline with `npm install -g claude-code-1.x.x.tgz`. However, runtime API calls still require connectivity to api.anthropic.com — a local proxy or VPN tunnel is needed for actual usage.

Related Guides