Claude Code Setup Guide
Install Claude Code
Installation
All three systems use the same npm command:
npm install -g @anthropic-ai/claude-codeVerify:
claude -vA 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:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc # zsh users: ~/.zshrc
source ~/.bashrcQ: permission denied error (Windows)
Run PowerShell as administrator:
npm config set prefix "$env:APPDATA\npm"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserQ: 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
cc-switch (recommended)
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:
setx ANTHROPIC_BASE_URL "your-API-address"
setx ANTHROPIC_AUTH_TOKEN "your-Key"Close and reopen the terminal, then verify:
# 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):
vim ~/.zshrcAppend at the end:
export ANTHROPIC_BASE_URL="your-API-address"
export ANTHROPIC_AUTH_TOKEN="your-Key"Save, apply, and verify:
source ~/.zshrc
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKENStart Using It
Open a terminal in any project directory (on Windows, right-click → "Open in Terminal" or "Git Bash Here"), then run claude:
cd your-project-directory
claudeOn 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 WorldHandy shortcuts:
/help: list all commands/clear: clear the current session/exitor pressCtrl + Ctwice: quit