How to Install and Configure Claude Code AI Programming Assistant

This guide walks through installing Claude Code, an Anthropic AI programming assistant, covering prerequisites, npm installation, authentication, optional proxy setup for Unix and Windows, MCP server configuration, common commands, and troubleshooting tips.

Tech Ocean
Tech Ocean
Tech Ocean
How to Install and Configure Claude Code AI Programming Assistant

Prerequisites

Node.js 18+ is required; see the fnm installation guide.

Installation

npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com
claude --version  # verify installation

First login

Run authentication:

claude auth login
# or run <code>claude</code> and follow the prompts

If using a proxy or API proxy, set environment variables:

export ANTHROPIC_BASE_URL="https://api.minimaxi.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="<API_KEY>"
claude

Proxy configuration (optional)

Only needed when direct network access fails.

Unix-like systems (macOS/Linux)

Add the following functions to ~/.zshrc or ~/.bashrc:

proxy_on() {
    export https_proxy=http://127.0.0.1:7897
    export http_proxy=http://127.0.0.1:7897
    export all_proxy=socks5://127.0.0.1:7897
}
cc() {
    proxy_on
    # bypassPermissions skips confirmation prompts
    claude --ide --permission-mode bypassPermissions "$@"
}

Windows (PowerShell)

Profile file location:

echo $PROFILE
# Common paths:
# PowerShell Core: ~/.config/powershell/Microsoft.PowerShell_profile.ps1
# Windows PowerShell: ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1

Add the following functions to the profile:

function proxy_on {
    $env:HTTPS_PROXY="http://127.0.0.1:7897"
    $env:HTTP_PROXY="http://127.0.0.1:7897"
    $env:ALL_PROXY="socks5://127.0.0.1:7897"
}
function cc {
    proxy_on
    # bypassPermissions skips confirmation prompts
    claude --ide --permission-mode bypassPermissions @args
}
# Use:
. $PROFILE && cc "task description"

MCP server configuration

# Install MCP servers
claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
claude mcp add deepwiki -- npx -y mcp-deepwiki@latest
claude mcp add chrome-devtools -- npx -y chrome-devtools-mcp@latest

# Management commands
claude mcp list          # list installed servers
claude mcp remove <name> # remove a server

Common commands

claude

: start interactive session claude "task": execute a task directly cc "task": start in proxy mode claude mcp list: list MCP servers claude --version: view version npm update -g @anthropic-ai/claude-code: update the tool npm uninstall -g @anthropic-ai/claude-code: uninstall the tool

FAQ

npm install fails (ECONNRESET)

Configure a domestic mirror:

npm config set registry https://registry.npmmirror.com
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

command not found

export PATH="/usr/local/bin:$PATH"

MCP fails to start

claude mcp remove <name>
claude mcp add <name> -- npx -y @package@latest

Proxy port

Clash default is 7890; other proxy software may use different ports.

Related links

Claude Code official website

Official documentation

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ProxyMCPNode.jsInstallationAI assistantClaude Code
Tech Ocean
Written by

Tech Ocean

Focused on AI programming, sharing ready-to-use development efficiency solutions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.