Installing Claude Code
Step-by-step guide to every installation method for Claude Code: npm CLI, VS Code extension, JetBrains plugin, web interface, and API key setup.
This lesson is original educational writing based on this video by Anthropic (published May 14, 2026). All credit for the original content goes to the creators.
1. Choosing your installation method
Claude Code ships in four distinct forms, and the right one depends on how you prefer to work. The CLI is the canonical version — everything else is built on top of it — but the IDE integrations are genuine first-class products, not thin wrappers. Understanding what each one offers helps you pick the setup you will actually use.
The npm CLI is the reference implementation. It runs in any terminal on macOS, Linux, or Windows (via WSL), requires no IDE, and gives you the full Claude Code experience including every tool, slash command, and configuration option. If you work across multiple editors, or if your workflow involves headless servers and CI environments, the CLI is the right anchor point.
The VS Code extension embeds Claude Code directly into your editor. The agent runs in an integrated panel, file diffs appear inline in the editor rather than in a diff viewer, and you can open files from the conversation with a single click. It is a meaningfully better experience if VS Code is your primary editor — the round-trip between terminal and editor disappears.
The JetBrains plugin provides the same embedded experience for IntelliJ IDEA, PyCharm, WebStorm, GoLand, and the rest of the JetBrains family. JetBrains users on Java, Kotlin, Python, or Go codebases often find this the most comfortable home for Claude Code.
The web interface at claude.ai lets you run Claude Code without installing anything locally. It is useful for quick one-off tasks from a machine you do not own, for evaluating Claude Code before committing to a full setup, or for sharing a session with someone who does not have the CLI. It has the same underlying capability as the CLI but lacks some power-user features like custom MCP server configurations.
2. Installing the CLI
The CLI requires Node.js 18 or higher. Check your version first:
node --version
If you are below 18, install Node via the official installer at nodejs.org or via a version manager like nvm or fnm. Version managers are recommended — they let you switch Node versions per project without touching your system Node installation.
Once you have a compatible Node version, install Claude Code globally:
npm install -g @anthropic-ai/claude-code
The -g flag installs it globally so the claude command is available in any directory. Verify the install worked:
claude --version
You should see a version string. If the command is not found, your npm global bin directory may not be on your PATH. Run npm config get prefix to find where npm installs global binaries, and add <prefix>/bin to your PATH in your shell profile (~/.zshrc, ~/.bashrc, etc.).
3. API key setup
Claude Code requires an Anthropic API key to work. If you do not have one, go to console.anthropic.com, create an account, and generate a key from the “API Keys” section. New accounts receive a small amount of free credits to get started.
The first time you run claude after installation, it will prompt you to enter your API key:
Welcome to Claude Code.
Please enter your Anthropic API key: sk-ant-...
Paste your key and press Enter. Claude Code stores it in your system’s secure credential store — macOS Keychain, the GNOME Keyring on Linux, or Windows Credential Manager — so you do not need to re-enter it for future sessions.
If you prefer to set it via environment variable (useful for CI environments or shared machines), export it before launching:
export ANTHROPIC_API_KEY="sk-ant-..."
claude
4. IDE extension setup
VS Code: Open the Extensions panel (Cmd+Shift+X on macOS), search for “Claude Code”, and install the extension published by Anthropic. After installation, a Claude Code icon appears in the Activity Bar on the left. Click it to open the panel. The extension will detect your API key from the CLI installation — you do not need to enter it again.
The VS Code extension adds a keyboard shortcut (Cmd+Shift+C by default) that opens the Claude Code panel pre-filled with the currently selected text or the file you have open. This is useful for quick targeted tasks like “explain this function” or “refactor this block to be more readable.”
JetBrains: Open Settings → Plugins → Marketplace, search for “Claude Code”, and install the Anthropic plugin. After restarting the IDE, a Claude Code tool window appears in the right sidebar. Like the VS Code extension, it picks up your existing API key from the system credential store.
JetBrains users benefit from tight integration with the IDE’s diff viewer — when Claude Code modifies a file, the change appears in the standard IntelliJ diff interface, making it easy to accept, reject, or partially apply changes using the review workflow you already know.
5. First verification
Once installed, run a quick check that confirms Claude Code can access your API key, read files, and execute commands. Navigate to any project directory and run:
claude "What Node version is installed on this machine, and what is the name of this project based on its package.json?"
If Claude Code responds correctly (correctly identifying your Node version from node --version output and your project name from package.json), your installation is fully working. It confirmed that bash execution and file reading both work, and that your API key is valid.
Check your understanding
4 questions · your answers are saved in this browser only
-
1. What is the minimum Node.js version required to install Claude Code via npm?
-
2. Where does Claude Code store your API key after the first login on macOS?
-
3. Which installation method is best suited for someone who wants to use Claude Code on a machine they do not own, without installing anything?
-
4. What does the -g flag do in npm install -g @anthropic-ai/claude-code?
Build it yourself
Follow these exact steps to reproduce it yourself · estimated time: ~20 min
Prerequisites
- Node.js 18+
- npm account (optional)
- Anthropic account at console.anthropic.com
Step 1 — Verify your Node version
node --versionIf below 18, install a newer version via nodejs.org or using nvm:
nvm install 20
nvm use 20Step 2 — Install Claude Code globally
npm install -g @anthropic-ai/claude-codeStep 3 — Generate an API key
Go to console.anthropic.com, sign in, navigate to “API Keys”, and click “Create Key”. Copy the key — it starts with sk-ant-. You can only view it once, so save it somewhere safe.
Step 4 — First launch and key setup
claudePaste your API key when prompted. Claude Code will store it securely and confirm the setup.
Step 5 — Verification test
Navigate to any project:
cd ~/projects/my-app
claude "What Node version is installed and what is the project name from package.json?"A correct answer confirms both bash execution and file reading are working.
Step 6 — Optional: Install the VS Code extension
Open VS Code → Extensions (Cmd+Shift+X) → search “Claude Code” → Install. Open the Claude Code panel from the Activity Bar and confirm it connects using the same API key.