Prerequisites
- Operating system: macOS, Linux, or Windows (with WSL or natively).
- Anthropic account — a Claude subscription or a console account (console.anthropic.com).
- Node.js 20+ — only if you install via npm. Not required with the native installer (recommended).
Step 1: Install Claude Code
Open your terminal and use the native installer (recommended; it doesn't require Node.js and updates automatically):
# macOS, Linux o WSL curl -fsSL https://claude.ai/install.sh | bash # Windows (PowerShell) irm https://claude.ai/install.ps1 | iex
On Mac you can also use Homebrew:
brew install --cask claude-code
Alternative: via npm
If you prefer npm (requires Node.js 20+):
npm install -g @anthropic-ai/claude-code
Any of these methods installs the claude command. Verify that it was installed correctly:
claude --version
Step 2: Get your API key
- Go to console.anthropic.com and create an account if you don't have one.
- Go to API Keys in the side panel.
- Click Create Key and copy the generated key.
- Store it in a safe place — it is only shown once.
Step 3: Configure the API key
You have two options to configure your key:
Option A: Environment variable (recommended)
Add this to your ~/.zshrc, ~/.bashrc, or equivalent:
export ANTHROPIC_API_KEY="sk-ant-xxxxxxxxxxxxxxxxxxxxxxxx"
Then reload your shell:
source ~/.zshrc # o ~/.bashrc
Option B: On first launch of Claude Code
If you didn't set the environment variable, Claude Code will prompt you for the key the first time you run it and will save it automatically.
Step 4: First run
Navigate to a working directory and run:
cd mi-proyecto claude
The first time, it may ask for permissions or ask you to confirm your key. After that, you'll see the Claude Code interactive prompt ready to use.
Installing on Windows
On Windows you have two paths:
- Native (simpler): open PowerShell and run irm https://claude.ai/install.ps1 | iex. It is recommended to have Git for Windows installed so Claude can use Bash.
- With WSL2: install WSL with wsl --install and then install Claude Code inside WSL the same way as on Linux.
Updating Claude Code
With the native installer, it updates automatically in the background: you don't have to do anything. Check your version with:
claude --version
With Homebrew: brew upgrade claude-code. If you installed via npm:
npm update -g @anthropic-ai/claude-code
Uninstalling
Depending on how you installed it:
# Homebrew brew uninstall --cask claude-code # npm npm uninstall -g @anthropic-ai/claude-code