Claude Code is an AI development assistant created by Anthropic that runs in the terminal. On Windows, Claude Code requires Windows Subsystem for Linux (WSL) to function properly.
Open PowerShell as Administrator and run:
wsl --install
This command will:
# Enable WSL dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart # Enable Virtual Machine Platform dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart # Set WSL2 as default version (after restart) wsl --set-default-version 2
# List available distributions wsl --list --online # Install Ubuntu wsl --install -d Ubuntu
In the Ubuntu terminal, run:
# Update package list sudo apt update # Install updates sudo apt upgrade -y # Install essential tools sudo apt install build-essential curl git -y
# 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
# Create directory for global packages mkdir -p ~/.npm-global # Configure npm to use this directory npm config set prefix ~/.npm-global # Add to PATH echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc # Reload shell configuration source ~/.bashrc
sudo
with npm install
for global packages! This can cause permission issues and security risks.
# Install Claude Code globally npm install -g @anthropic-ai/claude-code # Verify installation claude --version
# Check if Claude Code is in PATH which claude # Should output: /home/username/.npm-global/bin/claude
# Navigate to a project cd /mnt/c/Users/YourName/Projects/your-project # Start Claude Code claude # Follow OAuth prompts in browser
# Set API key export ANTHROPIC_API_KEY=your_key_here # Add to shell profile echo 'export ANTHROPIC_API_KEY=your_key' >> ~/.bashrc source ~/.bashrc
# Update via npm npm update -g @anthropic-ai/claude-code # Or complete reinstall for latest version npm install -g @anthropic-ai/claude-code
# Check current version claude --version # Check location which claude
#!/bin/bash # Save as upgrade-claude.sh echo "🔄 Updating Claude Code..." # Check current version echo "Current version:" claude --version # Update npm update -g @anthropic-ai/claude-code # Check new version echo "New version:" claude --version echo "✅ Upgrade complete!"
# Check WSL status wsl --status # Update WSL wsl --update # Restart WSL wsl --shutdown wsl
# Check which npm is being used which npm which node # Should show /usr/bin/npm, NOT /mnt/c/...
# Fix npm permissions sudo chown -R $(whoami) ~/.npm-global npm config set prefix ~/.npm-global
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
Create file %USERPROFILE%\.wslconfig
:
[wsl2] memory=8GB processors=4 swap=2GB localhostForwarding=true [experimental] sparseVhd=true autoMemoryReclaim=gradual
# Windows files are accessible at /mnt/c/ cd /mnt/c/Users/YourName/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 in project claude # Basic commands > "Explain what this JavaScript file does" > "/init" # Generate project documentation > "/help" # See all available commands
Create file ~/.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"] } } }
Add to ~/.bashrc
:
# Claude Code configuration 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
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"]
# 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"
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 }}
{ "team": { "name": "Development Team", "defaultModel": "claude-sonnet-4", "sharedSettings": { "codeStyle": "prettier", "testFramework": "jest", "linting": "eslint" } }, "security": { "allowedDomains": ["github.com", "gitlab.com"], "restrictedCommands": ["rm", "sudo", "chmod 777"] } }
A: No, Claude Code requires a Unix-like environment. You must use WSL on Windows.
A: Claude Max ($20/month) is more economical for regular users than pay-per-use API pricing.
A: Use npm update -g @anthropic-ai/claude-code
or reinstall with npm install -g @anthropic-ai/claude-code
.
A: Configure npm to use a user-writable directory and never use sudo
with npm global installs.
A: Yes, Claude Code integrates with various IDEs and can be used alongside VS Code through the terminal.