Claude Code is Anthropic’s terminal-based AI coding assistant. It runs in your project directory, reads your codebase, and executes tasks through natural language commands.
This guide walks through every installation step so you can go from zero to your first session in under 10 minutes.
If you want context on what Claude Code does before installing, read what Claude Code is first.
Prerequisites
Node.js 18 or higher
Claude Code requires Node.js 18 or higher. To check your current version, run:
node --version
If you see v18.x.x or higher, you are ready. If you see a lower version or command not found, install Node.js before continuing.
The recommended approach is to use a version manager: nvm on Mac and Linux, or nvm-windows on Windows. Node.js 20 LTS is the recommended version for stability.
npm
npm comes bundled with Node.js. Verify it is available:
npm --version
Any npm version from 8 onward works. If your npm is older, run npm install -g npm to update.
An Anthropic account
You need one of the following:
- An Anthropic API account at console.anthropic.com with billing enabled
- A Claude Max subscription for flat-rate access
The difference between these two authentication paths is covered in Step 3. If you do not have either, create a free Anthropic account first.
Step 1: Install Claude Code via npm
Run the following command in your terminal:
npm install -g @anthropic-ai/claude-code
The -g flag installs Claude Code globally, making the claude command available in any directory on your system.
Installation typically takes 30 to 60 seconds depending on your connection speed.
Do this: If you see a permission error on Mac or Linux, fix your npm global directory permissions or switch to nvm, which installs Node in your home directory and avoids permission issues entirely.
Avoid this: Do not run sudo npm install -g, it causes permission problems that are harder to undo.
Step 2: Verify the Installation
After installation completes, confirm Claude Code is accessible:
claude --version
This should return a version number such as 1.x.x. If the command is not found, your npm global bin directory is likely not in your PATH.
On Mac and Linux with nvm, this is handled automatically. On a standard Node.js install, check that $(npm config get prefix)/bin is in your PATH.
Step 3: Authentication
Claude Code supports two authentication methods. Choose the one that matches your setup:
- Method 1: Anthropic API Key, pay-per-token billing, best for occasional use or cost-controlled evaluation
- Method 2: Claude Max Subscription, flat-rate access, best for frequent daily sessions
Method 1: Anthropic API Key
Get your API key from console.anthropic.com under API Keys. Set it as an environment variable:
export ANTHROPIC_API_KEY=your_api_key_here
To persist this across terminal sessions, add it to your shell configuration file. On zsh (default on Mac):
echo 'export ANTHROPIC_API_KEY=your_api_key_here' >> ~/.zshrc
source ~/.zshrc
On bash (default on most Linux):
echo 'export ANTHROPIC_API_KEY=your_api_key_here' >> ~/.bashrc
source ~/.bashrc
API key authentication uses pay-per-token billing. Usage is billed based on the number of tokens processed in each session.
The ANTHROPIC_API_KEY environment variable must be exported in any shell where you run claude.
Method 2: Claude Max Subscription
If you have a Claude Max subscription, authenticate through the browser OAuth flow:
claude auth login
This opens a browser window where you log in to your Anthropic account. Once authenticated, Claude Code stores a token locally and uses it for all subsequent sessions.
Claude Max provides flat-rate access without per-token charges, which is often more economical for developers who run frequent sessions.
If you are evaluating Claude Code before committing to a billing method, the API key path lets you start immediately with a pay-as-you-go model and control costs while you learn the tool.
Step 4: First Run
Navigate to any project directory and start a Claude Code session:
cd your-project
claude
Claude Code starts an interactive session. It reads your project structure and waits for your first instruction.
Type a task in plain English, for example: explain the main entry point of this project or add error handling to the fetchUser function.
For a project Claude Code has never seen, the first session may take a moment as it indexes the file structure.
Subsequent sessions in the same directory are faster because Claude Code builds context incrementally.
Step 5: Create Your First CLAUDE.md
CLAUDE.md is a markdown file in your project root that gives Claude Code persistent context about your project. Without it, Claude Code relies entirely on reading your files in each session.
With it, Claude Code knows your conventions, constraints, and preferences from the moment a session starts.
Create a file named CLAUDE.md in your project root:
# Project: [Your Project Name]
## Stack
- Language: [e.g. TypeScript, Python]
- Framework: [e.g. Next.js, FastAPI]
- Database: [e.g. PostgreSQL, MongoDB]
## Conventions
- [e.g. Use functional components, not class components]
- [e.g. Error messages go through the central logger]
- [e.g. All API routes return { data, error } shape]
## Commands
- Run tests: npm test
- Start dev server: npm run dev
- Lint: npm run lint
This file travels with your repository. Any developer who clones the project and runs Claude Code gets the same context immediately.
Read more about what CLAUDE.md does to get the most out of this file.
Platform-Specific Notes
- Mac. Claude Code works natively on macOS via Terminal, iTerm2, or the VS Code integrated terminal. No additional configuration is needed beyond Node.js and npm.
- Linux. Claude Code works natively on all major Linux distributions. Ubuntu, Debian, Fedora, and Arch are all supported. Use
nvmfor Node.js version management. - Windows. Claude Code does not run natively on Windows. It requires WSL2 (Windows Subsystem for Linux). Follow the Claude Code Windows WSL2 setup guide before running the
npm installcommand. The installation steps above are identical once you are inside a WSL2 Ubuntu session.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
EACCES: permission denied on npm install | npm global directory owned by root | Fix npm permissions or switch to nvm instead of system Node |
node: command not found | Node.js not installed or not in PATH | Install Node 18+ via nvm or nodejs.org, then reload shell |
Error: ANTHROPIC_API_KEY not found | Environment variable not set or not exported | Set export ANTHROPIC_API_KEY=... and reload shell, or run claude auth login |
claude: command not found after install | npm global bin directory not in PATH | Add $(npm config get prefix)/bin to your PATH in .zshrc or .bashrc |
429 Rate limit exceeded | Too many requests in a short window | Wait 60 seconds and retry; consider upgrading API tier if this recurs |
What to Do After Installation
Once Claude Code is running, the next step is configuring it for your workflow:
- Claude Code best practices, how to write effective prompts, structure sessions for complex tasks, and set up
CLAUDE.mdfor different project types - Claude Code pricing explained, cost management between API key and Claude Max options for teams
- Claude Code course, the full workflow from installation through advanced team usage
FAQ
Does Claude Code work with any programming language?
Yes. Claude Code reads any text-based file and works with any language. It has strong performance on TypeScript, JavaScript, Python, Go, Rust, Ruby, and Java. Less common languages work as well, though Claude’s training data coverage affects the depth of suggestions.
Can I install Claude Code without admin rights?
Yes, if you use nvm. nvm installs Node.js and npm in your home directory (~/.nvm), which requires no elevated permissions. The npm install -g command then installs Claude Code into your home directory as well.
Is my code sent to Anthropic?
Claude Code sends the content it needs to answer your queries to Anthropic’s API. This includes file contents you reference in your prompts and context Claude Code reads from your project.
Review Anthropic’s privacy policy and usage policies before using Claude Code on confidential codebases.
What happens if I switch machines?
Claude Code configuration lives in ~/.claude/settings.json on each machine. CLAUDE.md lives in your repository, so it travels with your code.
To replicate your setup on a new machine, run the npm install command, set your API key or log in via Claude Max, and your CLAUDE.md context is already present if you cloned the repo.
Phos AI Labs is a CCA-F certified Claude implementation partner with 400+ engagements. If your team is evaluating Claude Code as part of a broader AI tooling strategy, contact us to discuss what a structured rollout looks like for your organization.