- Learn
- AI Coding Agents
- Claude Code
- Installing Claude Code
Get Claude Code set up on your system with authentication configured and ready for development.
Installing Claude Code
Claude Code runs on macOS, Linux, and Windows (via WSL). This lesson walks through installation and initial configuration.
Prerequisites
Before installing, ensure you have:
- Node.js 18+: Required runtime
- npm or yarn: Package manager
- Terminal access: Command line interface
- Anthropic account: For API access
Checking Node.js
node --version
# Should show v18.0.0 or higher
If needed, install Node.js from nodejs.org or use nvm:
# Install nvm (macOS/Linux)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Install Node.js
nvm install 20
nvm use 20
Installation
Install via Native Installer (Recommended)
The recommended installation method uses the native installer:
# macOS / Linux
curl -fsSL https://claude.ai/install.sh | bash
# Windows (PowerShell)
irm https://claude.ai/install.ps1 | iex
Alternative: Install via npm
For environments where the native installer isn't suitable:
npm install -g @anthropic-ai/claude-code
Verify Installation
claude --version
You should see the version number displayed.
Authentication
Claude Code needs API access. You have two options:
Option 1: Interactive Login
The simplest method:
claude
On first run, Claude Code will:
- Open your browser to Anthropic's login page
- Ask you to authenticate
- Store credentials securely
Option 2: API Key
For automated setups or CI environments:
-
Get your API key from console.anthropic.com
-
Set the environment variable:
# In your shell profile (~/.zshrc, ~/.bashrc)
export ANTHROPIC_API_KEY="sk-ant-api03-..."
- Reload your shell:
source ~/.zshrc
Configuration
Config File Location
Claude Code stores configuration in:
- macOS/Linux:
~/.config/claude-code/config.json - Windows:
%APPDATA%\claude-code\config.json
Basic Configuration
Create or edit the config file:
{
"model": "claude-sonnet-4-20250514",
"maxTokens": 8192,
"temperature": 0
}
Available Options
| Option | Description | Default |
|---|---|---|
model | Which Claude model to use | claude-sonnet-4-20250514 |
maxTokens | Max response length | 4096 |
temperature | Response randomness (0-1) | 0 |
autoApprove | Skip confirmations | false |
Model Selection
Available models:
{
"model": "claude-sonnet-4-20250514" // Fast, cost-effective
}
{
"model": "claude-opus-4-20250514" // Most capable, higher cost
}
First Run
Starting Claude Code
Navigate to a project directory:
cd ~/projects/my-app
claude
The Welcome Screen
You'll see:
╭──────────────────────────────────────────────────╮
│ Welcome to Claude Code │
│ │
│ I'm an AI assistant that can help you with: │
│ • Understanding your codebase │
│ • Writing and modifying code │
│ • Running commands and tests │
│ • Debugging and fixing issues │
│ │
│ Type your request or /help for commands. │
╰──────────────────────────────────────────────────╯
>
Basic Test
Try a simple command:
> What files are in this directory?
Claude Code should list your project files, confirming everything works.
Project-Specific Setup
Project Configuration with CLAUDE.md
Create a CLAUDE.md file in your project root for project-specific guidance:
# Project Context
This is a Next.js 15 e-commerce application.
## Tech Stack
- Next.js 15 with App Router
- TypeScript
- Tailwind CSS v4
- Prisma with PostgreSQL
- Stripe for payments
## Conventions
- Use Server Components by default
- API routes in /app/api
- Shared components in /components
- Use Zod for validation
## Important Files
- /prisma/schema.prisma - Database schema
- /lib/stripe.ts - Payment integration
- /middleware.ts - Auth middleware
## Commands
- `npm run dev` - Start development server
- `npm run build` - Production build
- `npm test` - Run tests
Claude Code automatically reads CLAUDE.md and follows these guidelines.
Note: The
.claude/instructions.mdformat is deprecated. UseCLAUDE.mdin your project root instead.
Shell Integration
Aliases
Add helpful aliases to your shell profile:
# ~/.zshrc or ~/.bashrc
# Quick start
alias cc="claude"
# Start with specific model
alias cco="claude --model claude-opus-4-20250514"
# Start in current directory
alias cchere="claude --cwd ."
Path Considerations
Ensure Claude Code can find your tools:
# Add common paths if needed
export PATH="$PATH:./node_modules/.bin"
export PATH="$PATH:$HOME/.local/bin"
Troubleshooting
"Command not found"
If claude isn't recognized:
# Check npm global install location
npm list -g --depth=0
# Add to PATH if needed
export PATH="$PATH:$(npm config get prefix)/bin"
Authentication Issues
If login fails:
- Clear stored credentials:
rm -rf ~/.config/claude-code/credentials*
- Re-authenticate:
claude --login
Permission Errors
On some systems:
# Fix npm permissions
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) $(npm config get prefix)/lib/node_modules
Or use nvm instead of system npm.
Network Issues
If you're behind a proxy:
export HTTP_PROXY="http://proxy:port"
export HTTPS_PROXY="http://proxy:port"
Updating
Check Current Version
claude --version
Update to Latest
npm update -g @anthropic-ai/claude-code
Automatic Updates
Claude Code will notify you of updates when they're available.
Uninstalling
If you need to remove Claude Code:
npm uninstall -g @anthropic-ai/claude-code
rm -rf ~/.config/claude-code
Summary
- Install: Use native installer (
curl -fsSL https://claude.ai/install.sh | bash) or npm - Authenticate: Interactive login or API key
- Configure: Global in
~/.config/claude-code/or per-project withCLAUDE.md - Project context: Use
CLAUDE.mdin project root for guidelines - Start with:
claudein your project directory
Next Steps
With Claude Code installed, let's learn the basic commands and interactions you'll use daily.