Claude Code

Install and configure the Claude Code CLI (command-line tool) on your computer using a configuration file

If you run into any issues, you can take a screenshot of this entire page and your problem, then copy them to Doubao or deepseek or another AI, and follow its instructions to run the corresponding commands.

If the AI is also unable to resolve the issue, you can contact our engineers for technical support and assistance.

Windows

1. Install Node.js / Git

Go to the Node.js official website to download and install the LTS version. (If it is already installed, you can skip this step.)

Verify the installation:

node --version
claudecode windows step1 image1

Note that the Node.js version must be 18 or higher.

If your version is lower than this, you can ask the AI how to upgrade your Node.js version.

Go to the official Git website, download the installer, and just keep clicking Yes all the way through.

claudecode windows step1 image2

2. Install Claude Code CLI

Open PowerShell (it is recommended to run as administrator) and execute:

npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com/
claudecode windows step2 image1

If you encounter a restriction that prevents scripts from running on this system, run PowerShell with administrator privileges, then execute: Set-ExecutionPolicy Unrestricted

3. Create a configuration file

Open PowerShell (it is recommended to run as administrator) and execute:

# Target directory: C:\Users\<you>\.claude
$dir = Join-Path $env:USERPROFILE ".claude"
$settingsFile = Join-Path $dir "settings.json"
$claudeJsonFile = Join-Path $env:USERPROFILE ".claude.json"

# Create directory (no error if it already exists)
New-Item -ItemType Directory -Path $dir -Force | Out-Null

# 1. Write settings.json (API configuration)
$settingsJson = @'
{
 "env": {
 "ANTHROPIC_AUTH_TOKEN": "Replace this with your _API_KEY",
 "ANTHROPIC_BASE_URL": "https://api.aicodewith.com"
 }
}
'@
[System.IO.File]::WriteAllText($settingsFile, $settingsJson, (New-Object System.Text.UTF8Encoding($false)))

# 2. Write .claude.json (skip login) - note this file is in the user home directory
$claudeJson = @'
{
 "hasCompletedOnboarding": true
}
'@
[System.IO.File]::WriteAllText($claudeJsonFile, $claudeJson, (New-Object System.Text.UTF8Encoding($false)))

Write-Host "Configuration completed!"
Write-Host " - settings.json: $settingsFile"
Write-Host " - .claude.json: $claudeJsonFile"
claudecode windows step3 image1

4. Verify the installation

Reopen PowerShell or your IDE and run:

claude
claudecode windows step4 image1

If you see the following prompt, select the first "yes" option and then press Enter.

claudecode windows step4 image2

Next, you can enter: Hello! If you receive a normal reply and there is a correct invocation record in the backend, it means the configuration was successful.

claudecode windows step4 image3

macOS

1. Install Node.js

First, make sure you have Homebrew installed on your computer.

When installing Homebrew, some resources are hosted overseas, so you need to configure a TUN proxy.

claudecode macOS step1 image1

After the installation is complete, use Homebrew to install Node.js (you can skip this step if it is already installed).

brew install node
claudecode macOS step1 image2

Use the following command to verify the installation. If you see the following message, it means Node has been installed successfully.

node --version
claudecode macOS step1 image3

Note that the Nodejs version must be 18 or higher. If your version is lower than this, you can ask the AI how to upgrade your Node.js version.

2. Install Claude Code CLI

Open a new terminal, then run the following command:

npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com/
claudecode macOS step2 image1

3. Create a configuration file

Open a new terminal, then run the following command:

# Target directory: ~/.claude
dir="$HOME/.claude"
settingsFile="$dir/settings.json"
claudeJsonFile="$HOME/.claude.json"

# Create directory (no error if it already exists)
mkdir -p "$dir"

# 1. Write settings.json (API configuration)
cat > "$settingsFile" << 'EOF'
{
 "env": {
 "ANTHROPIC_AUTH_TOKEN": "Replace this with your _API_KEY",
 "ANTHROPIC_BASE_URL": "https://api.aicodewith.com"
 }
}
EOF

# 2. Write .claude.json (skip login) - note this file is in the user home directory
cat > "$claudeJsonFile" << 'EOF'
{
 "hasCompletedOnboarding": true
}
EOF

echo "Configuration complete!"
echo " - settings.json: $settingsFile"
echo " - .claude.json: $claudeJsonFile"

cat "$HOME/.claude/settings.json"
claudecode macOS step3 image1

4. Verify the installation

Reopen the terminal or IDE and run:

claude
claudecode macOS step4 image1
claudecode macOS step4 image2
claudecode macOS step4 image3

If you see the prompt, select the first "yes" option and then press Enter. Then type: Hello! If you receive a normal reply and there is a correct invocation record in the backend, it means the configuration was successful.

Linux

1. Install Node.js

Command to install Nodejs (you can skip this if it is already installed):

curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
node --version
claudecode linux step1 image1

Note that the Nodejs version must be 18 or higher.

2. Install Claude Code CLI

Run:

npm install -g @anthropic-ai/claude-code
claudecode linux step2 image1

That last message is just saying the current npm version is relatively low; you can ignore it.

3. Create a configuration file

Open a new terminal, then run the following command:

# Target directory: ~/.claude
dir="$HOME/.claude"
settingsFile="$dir/settings.json"
claudeJsonFile="$HOME/.claude.json"

mkdir -p "$dir"

cat > "$settingsFile" << 'EOF'
{
 "env": {
 "ANTHROPIC_AUTH_TOKEN": "Replace with your _API_KEY_ here",
 "ANTHROPIC_BASE_URL": "https://api.aicodewith.com"
 }
}
EOF

cat > "$claudeJsonFile" << 'EOF'
{
 "hasCompletedOnboarding": true
}
EOF

cat "$HOME/.claude/settings.json"
claudecode linux step3 image1

4. Verify the installation

Reopen the terminal or IDE and run:

claude
claudecode linux step4 image1
claudecode linux step4 image2
claudecode linux step4 image3

If you see the prompt, select the first "yes" option and then press Enter. Then type hi. If you receive a normal reply and there is a correct invocation record in the backend, it means the configuration was successful.

FAQ

1. Unable to connect to the Anthropic service

Error screenshot

claudecode faq1 screenshot1

Solution

In the ~/.claude.json file, add the following line: "hasCompletedOnboarding": true, (note the comma).

claudecode faq1 screenshot2

2. Invalid API key · Please run /login

Error screenshot

claudecode faq2 screenshot1

Solution

This issue occurs because the environment variables are not configured correctly. Mainly: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN.

3. 401 {\"error\":\"Invalid API key\"}

Error screenshot

claudecode faq3 screenshot1

Solution

This issue occurs because the key was set incorrectly. Generate a new key, then reset the environment variable ANTHROPIC_AUTH_TOKEN.

300+ AI Models for OpenClaw & AI Agents

Save 20% on Costs

Free $1 Tokens for New Members