Claude Code for Windows

Complete installation guide for Windows using Windows Subsystem for Linux (WSL). Choose your experience level to get started.

Intermediate Setup Required

Very Quick Installation

For experienced users - get Claude Code running in 4 commands

Windows Quick Setup
# Install WSL (if not already installed)
wsl --install

# Install Node.js in WSL
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# Install Claude Code
npm install -g @anthropic-ai/claude-code

# Run Claude Code
claude

Beginner Path

Step-by-Step Guide

New to WSL or command line? Follow our detailed, beginner-friendly guide with explanations for each step.

  • WSL installation and setup
  • Node.js installation explained
  • Basic terminal usage
  • Troubleshooting common issues
Start Beginner Guide

Professional Path

Advanced Setup

Experienced with WSL and development tools? Jump to advanced configurations and enterprise features.

  • Quick installation commands
  • Performance optimizations
  • Enterprise configurations
  • CI/CD integration
Advanced Setup

Important: WSL Required

Claude Code does not run natively on Windows. You must use Windows Subsystem for Linux (WSL) to create a Linux environment within Windows.

Why WSL?

  • Claude Code requires a Unix-like environment
  • WSL provides full Linux compatibility
  • Seamless integration with Windows
  • Access to both Windows and Linux tools

What You'll Get

  • Full Claude Code functionality
  • Linux terminal within Windows
  • Access to Windows files from WSL
  • Best of both operating systems

Beginner Installation Guide

Follow these detailed steps to install Claude Code on Windows. Each step includes explanations and troubleshooting tips.

1 Enable Windows Subsystem for Linux

5-10 minutes

First, we need to enable WSL on your Windows system. This creates a Linux environment within Windows.

Option A: Automatic Installation (Windows 10 version 2004+ or Windows 11)

Open PowerShell or Command Prompt as Administrator and run:

wsl --install

This command will enable WSL, install Ubuntu as the default distribution, and restart your computer.

Option B: Manual Installation (Older Windows versions)

If the automatic installation doesn't work:

  1. Open PowerShell as Administrator
  2. Enable WSL feature:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  1. Enable Virtual Machine Platform:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  1. Restart your computer
  2. Download and install the WSL2 Linux kernel update package
  3. Set WSL2 as default:
wsl --set-default-version 2

Tip: After installation, you can access WSL by typing "Ubuntu" in the Start menu or opening Windows Terminal.

2 Install Ubuntu Distribution

5 minutes

Install Ubuntu as your Linux distribution. This provides the environment where Claude Code will run.

Install from Microsoft Store

  1. Open Microsoft Store
  2. Search for "Ubuntu"
  3. Install "Ubuntu" (latest LTS version)
  4. Launch Ubuntu from Start menu
  5. Create a username and password when prompted

Alternative: Command Line Installation

# List available distributions
wsl --list --online

# Install Ubuntu
wsl --install -d Ubuntu

Note: The first launch will take a few minutes as Ubuntu sets up the environment. You'll be asked to create a username and password.

3 Update Ubuntu System

5-10 minutes

Update the Ubuntu system to ensure you have the latest packages and security updates.

In your Ubuntu terminal, run these commands:

# Update package list
sudo apt update

# Upgrade installed packages
sudo apt upgrade -y

# Install essential build tools
sudo apt install build-essential curl git -y

What These Commands Do:

  • sudo apt update - Downloads the latest package information
  • sudo apt upgrade -y - Installs available updates
  • build-essential - Provides compilation tools
  • curl - Tool for downloading files
  • git - Version control system

Terminal Tip: You can paste commands in WSL terminal using Ctrl+Shift+V or right-click.

4 Install Node.js

5 minutes

Claude Code requires Node.js 18 or higher. We'll install the latest LTS version using NodeSource repository.

Install Node.js 20 LTS

# Add NodeSource repository
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

# Install Node.js
sudo apt-get install -y nodejs

# Verify installation
node --version
npm --version

Configure npm for Global Packages

To avoid permission issues when installing global packages:

# Create directory for global packages
mkdir -p ~/.npm-global

# Configure npm to use this directory
npm config set prefix ~/.npm-global

# Add to PATH in your shell profile
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc

# Reload shell configuration
source ~/.bashrc

Important: Never use sudo with npm install for global packages. This can cause permission issues and security risks.

5 Install Claude Code

2 minutes

Now we can install Claude Code using npm. This will download and install the latest version.

# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

# Verify installation
claude --version

Test the Installation

# Check if Claude Code is in PATH
which claude

# Should output something like: /home/username/.npm-global/bin/claude

Success! If you see a version number, Claude Code is installed correctly.

6 Authenticate with Anthropic

3 minutes

Set up authentication to use Claude Code. You can use either Claude Max subscription or an API key.

Option A: Claude Max (Recommended)

  1. Navigate to a project directory
  2. Run claude
  3. Follow OAuth prompts in browser
  4. Complete authentication
# Navigate to your project
cd /mnt/c/Users/YourUsername/Projects/your-project

# Start Claude Code
claude

Option B: API Key

  1. Get API key from Anthropic Console
  2. Set environment variable
  3. Add to shell profile
# Set API key
export ANTHROPIC_API_KEY=your_key_here

# Add to shell profile
echo 'export ANTHROPIC_API_KEY=your_key' >> ~/.bashrc
source ~/.bashrc

Tip: Claude Max subscription ($20/month) is more economical for regular users than pay-per-use API.

7 First Use and Testing

5 minutes

Test Claude Code with your first project and learn basic commands.

Access Your Windows Projects

Your Windows files are accessible from WSL at /mnt/c/:

# Navigate to your Windows projects
cd /mnt/c/Users/YourUsername/Projects

# Or create a new project
mkdir claude-test
cd claude-test

# Initialize a simple project
echo "console.log('Hello Claude!');" > hello.js

Start Claude Code

# Start Claude Code in your project
claude

# Try some basic commands
> "Explain what this JavaScript file does"
> "/init"  # Generate project documentation
> "/help"  # See all available commands

Congratulations! You've successfully installed Claude Code on Windows. You're ready to start AI-powered coding!

Professional Installation Guide

Quick setup for experienced developers with advanced configurations and enterprise features.

Quick Installation Script

5 minutes

Automated installation script for experienced users. Assumes WSL2 is already configured.

# One-line installation (run in WSL)
curl -fsSL https://raw.githubusercontent.com/anthropics/claude-code/main/install.sh | bash

# Or manual quick setup
sudo apt update && sudo apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential curl git
mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc && source ~/.bashrc
npm install -g @anthropic-ai/claude-code

Performance Optimization

Optimize WSL2 performance for better Claude Code experience.

WSL Configuration

Create %USERPROFILE%\.wslconfig:

[wsl2]
memory=8GB
processors=4
swap=2GB
localhostForwarding=true

[experimental]
sparseVhd=true
autoMemoryReclaim=gradual

Environment Variables

# Add to ~/.bashrc
export ANTHROPIC_API_KEY=your_key
export CLAUDE_MODEL=claude-sonnet-4
export MCP_DEBUG=false
export NODE_OPTIONS="--max-old-space-size=4096"

# Windows integration
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

Enterprise Configuration

Advanced configurations for enterprise environments and team deployments.

Global Configuration

Create ~/.claude.json:

{
  "defaultModel": "claude-sonnet-4",
  "permissions": {
    "allowedTools": ["Edit", "Bash(git*)"],
    "deniedTools": ["Bash(rm*)"]
  },
  "preferences": {
    "autoCompact": true,
    "compactThreshold": 50000
  },
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "~/Projects"]
    }
  }
}

CI/CD Integration

# GitHub Actions workflow
name: Claude Code CI
on: [push, pull_request]

jobs:
  claude-review:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v3
      with:
        node-version: '20'
    - run: npm install -g @anthropic-ai/claude-code
    - run: claude --dangerously-skip-permissions -p "review this PR"
      env:
        ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

Docker Integration

Use Claude Code in containerized environments for isolation and reproducibility.

# Dockerfile for Claude Code
FROM node:20-slim

RUN apt-get update && apt-get install -y \
    git \
    curl \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

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

WORKDIR /workspace
VOLUME ["/workspace"]

ENV ANTHROPIC_API_KEY=""
CMD ["claude"]

Usage

# Build and run
docker build -t claude-code .
docker run -it --rm -v $(pwd):/workspace -e ANTHROPIC_API_KEY=your_key claude-code

# Or use dangerous mode for automation
docker run --rm -v $(pwd):/workspace -e ANTHROPIC_API_KEY=your_key claude-code \
  claude --dangerously-skip-permissions -p "fix all linting errors"

Windows-Specific Troubleshooting

Common issues and solutions specific to Windows and WSL environments.

Common Issues

WSL not found or not working

# Check WSL status
wsl --status

# Update WSL
wsl --update

# Restart WSL
wsl --shutdown
wsl

Node.js version conflicts

# Check which npm is being used
which npm
which node

# Should show /usr/bin/npm, not /mnt/c/...

Permission denied errors

# Fix npm permissions
sudo chown -R $(whoami) ~/.npm-global
npm config set prefix ~/.npm-global

Performance Issues

Slow file access

Work within WSL filesystem, not Windows drives:

# Instead of /mnt/c/Users/...
# Use ~/projects/ or /home/username/projects/

# Copy project to WSL
cp -r /mnt/c/Users/YourName/project ~/project
cd ~/project

Memory issues

Increase WSL memory allocation in .wslconfig:

[wsl2]
memory=8GB
processors=4

Network connectivity

# Reset WSL network
wsl --shutdown
# Restart WSL and try again

🎉 Windows Installation Complete!

You've successfully installed Claude Code on Windows. Here's what to explore next:

Need help? Check our troubleshooting guide or visit the community resources.

All Claude Commands