Skip to content

Claude Code Setup Guide

Install Claude Code

Installation

All three systems use the same npm command:

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

Verify:

bash
claude -v

A version number means the install succeeded.

Common Issues

Q: permission denied / EACCES error (Mac / Linux)

Do not use sudo. Move npm's global directory to your user space:

bash
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc   # zsh users: ~/.zshrc
source ~/.bashrc

Q: permission denied error (Windows)

Run PowerShell as administrator:

powershell
npm config set prefix "$env:APPDATA\npm"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Q: command not found: claude

The npm global bin directory isn't in PATH. Run npm config get prefix, then add the corresponding /bin directory to your system PATH.

Configure the API Key

A GUI tool that supports one-click switching across providers and writes the ClaudeCode plugin config automatically — no manual environment variables needed.

Manual environment variables

Windows

Open PowerShell as administrator and run:

powershell
setx ANTHROPIC_BASE_URL "your-API-address"
setx ANTHROPIC_AUTH_TOKEN "your-Key"

Close and reopen the terminal, then verify:

powershell
# PowerShell
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN

# cmd
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%

Mac / Linux

Edit your shell config file (zsh: ~/.zshrc, bash: ~/.bashrc, bash on macOS: ~/.bash_profile):

bash
vim ~/.zshrc

Append at the end:

bash
export ANTHROPIC_BASE_URL="your-API-address"
export ANTHROPIC_AUTH_TOKEN="your-Key"

Save, apply, and verify:

bash
source ~/.zshrc
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN

Start Using It

Open a terminal in any project directory (on Windows, right-click → "Open in Terminal" or "Git Bash Here"), then run claude:

bash
cd your-project-directory
claude

On first launch you'll be prompted in order: pick a theme, trust the current directory, choose a login method (skipped automatically if cc-switch's "skip first-run confirmation" is on).

Once you see the > prompt, just describe what you want in English or Chinese, e.g.:

Create a hello.py in the current directory that prints Hello World

Handy shortcuts:

  • /help: list all commands
  • /clear: clear the current session
  • /exit or press Ctrl + C twice: quit