Beginner10 min1 prerequisite

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

Terminal
node --version
# Should show v18.0.0 or higher

If needed, install Node.js from nodejs.org or use nvm:

Terminal
# 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:

Terminal
# 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:

Terminal
npm install -g @anthropic-ai/claude-code

Verify Installation

Terminal
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:

Terminal
claude

On first run, Claude Code will:

  1. Open your browser to Anthropic's login page
  2. Ask you to authenticate
  3. Store credentials securely

Option 2: API Key

For automated setups or CI environments:

  1. Get your API key from console.anthropic.com

  2. Set the environment variable:

Terminal
# In your shell profile (~/.zshrc, ~/.bashrc)
export ANTHROPIC_API_KEY="sk-ant-api03-..."
  1. Reload your shell:
Terminal
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:

Terminal
{
  "model": "claude-sonnet-4-20250514",
  "maxTokens": 8192,
  "temperature": 0
}

Available Options

OptionDescriptionDefault
modelWhich Claude model to useclaude-sonnet-4-20250514
maxTokensMax response length4096
temperatureResponse randomness (0-1)0
autoApproveSkip confirmationsfalse

Model Selection

Available models:

Terminal
{
  "model": "claude-sonnet-4-20250514"  // Fast, cost-effective
}
Terminal
{
  "model": "claude-opus-4-20250514"  // Most capable, higher cost
}

First Run

Starting Claude Code

Navigate to a project directory:

Terminal
cd ~/projects/my-app
claude

The Welcome Screen

You'll see:

Terminal
╭──────────────────────────────────────────────────╮
            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:

Terminal
> 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:

Terminal
# 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.md format is deprecated. Use CLAUDE.md in your project root instead.

Shell Integration

Aliases

Add helpful aliases to your shell profile:

Terminal
# ~/.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:

Terminal
# 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:

Terminal
# 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:

  1. Clear stored credentials:
Terminal
rm -rf ~/.config/claude-code/credentials*
  1. Re-authenticate:
Terminal
claude --login

Permission Errors

On some systems:

Terminal
# 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:

Terminal
export HTTP_PROXY="http://proxy:port"
export HTTPS_PROXY="http://proxy:port"

Updating

Check Current Version

Terminal
claude --version

Update to Latest

Terminal
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:

Terminal
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 with CLAUDE.md
  • Project context: Use CLAUDE.md in project root for guidelines
  • Start with: claude in your project directory

Next Steps

With Claude Code installed, let's learn the basic commands and interactions you'll use daily.

Mark this lesson as complete to track your progress