How to Install and Optimize Claude Code for Chinese Users
This guide walks you through installing Claude Code on macOS and Windows, configuring it for mainland China using proxy‑free alternatives like OpenRouter, SiliconFlow, DeepSeek, DashScope or Ollama, and provides detailed tips on model selection, Skills, MCP setup, performance tuning, security, and troubleshooting.
What is Claude Code?
Claude Code is Anthropic’s command‑line AI programming assistant that runs directly in a terminal to write code, debug issues, and execute project‑level tasks.
Installation Guide
macOS
Method 1 (recommended): npm install -g @anthropic-ai/claude-code (a proxy may be required for fast download).
Method 2: brew install claude-code Method 3: curl -fsSL https://claude.ai/install.sh | bash (requires proxy to reach claude.ai).
Verify installation:
claude --versionWindows
Method 1 (npm): npm install -g @anthropic-ai/claude-code Method 2 (winget): winget install Anthropic.ClaudeCode Method 3 (manual): download the installer from https://claude.ai/download (proxy required), then run the installer.
Verify installation: claude -h (shows help information).
Domestic Alternatives (Proxy‑Free Options)
OpenRouter (recommended) – aggregates multiple models (Claude, Gemini, Qwen). Requires proxy for the website.
export ANTHROPIC_BASE_URL=https://openrouter.ai/api/v1
export ANTHROPIC_API_KEY=your-openrouter-key
# Example model usage
claude --model anthropic/claude-sonnet-4-20250514
claude --model google/gemini-2.5-pro-exp-03-25
claude --model qwen/qwen-max-2025-01-25Pros: single API key for many models, flexible pay‑per‑use, supports full Claude lineup. Cons: proxy needed, slightly higher price than official.
SiliconFlow (highly recommended in China) – domestic API service, no proxy needed.
export ANTHROPIC_BASE_URL=https://api.siliconflow.cn/v1
export ANTHROPIC_API_KEY=your-siliconflow-key
claude --model Qwen/Qwen2.5-Coder-32B-Instruct
claude --model deepseek-ai/DeepSeek-V3Pros: no proxy, affordable, supports many open‑source models. Cons: no official Claude models.
DeepSeek (domestic, free tier) – strong Chinese language capability.
export ANTHROPIC_BASE_URL=https://api.deepseek.com/v1
export ANTHROPIC_API_KEY=your-deepseek-key
claude --model deepseek-chatPros: no proxy, good Chinese performance, cost‑effective. Cons: no Claude models.
Alibaba Cloud DashScope – domestic service, no proxy.
export ANTHROPIC_BASE_URL=https://dashscope.aliyuncs.com/apps/anthropic
export ANTHROPIC_API_KEY=your-dashscope-key
claude --model qwen-maxPros: no proxy, moderate cost. Cons: does not provide Claude models.
Ollama (local) – runs models offline, no network required.
# Example with local Qwen2.5‑Coder
export ANTHROPIC_BASE_URL="http://localhost:11434/v1"
export ANTHROPIC_API_KEY="ollama"
claude --model qwen2.5-coderPros: completely offline, free, good privacy. Cons: requires strong hardware, model capability lower than cloud services.
Comparison Summary
Official API – must use proxy, medium cost, full Claude support.
OpenRouter – proxy required, medium‑high cost, full Claude support.
SiliconFlow – no proxy, low cost, no Claude models.
DeepSeek – no proxy, low cost, no Claude models.
Alibaba DashScope – no proxy, medium cost, no Claude models.
Ollama (local) – no proxy, free, no Claude models.
Model Configuration Guide
Proxy‑required scenarios: Anthropic official API, OpenRouter, any access to claude.ai.
No‑proxy scenarios: SiliconFlow, DeepSeek, DashScope, Ollama.
Recommended Configurations
Domestic (no proxy):
# SiliconFlow
export ANTHROPIC_BASE_URL="https://api.siliconflow.cn/v1"
export ANTHROPIC_API_KEY="your-siliconflow-key"
claude --model Qwen/Qwen2.5-Coder-32B-Instruct
# DeepSeek
export ANTHROPIC_BASE_URL="https://api.deepseek.com/v1"
export ANTHROPIC_API_KEY="your-deepseek-key"
claude --model deepseek-chat
# DashScope
export ANTHROPIC_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
export ANTHROPIC_API_KEY="your-dashscope-key"
claude --model qwen-maxProxy users:
# OpenRouter (Claude official model)
export ANTHROPIC_BASE_URL="https://openrouter.ai/api/v1"
export ANTHROPIC_API_KEY="your-openrouter-key"
claude --model anthropic/claude-sonnet-4-20250514
# OpenRouter (Gemini example)
claude --model google/gemini-2.5-pro-exp-03-25Product Comparison: Claude Code vs Cursor vs OpenCode
Claude Code – CLI tool, pay‑per‑use API, supports many models, requires proxy for official models, terminal‑native, full MCP support, rich Skills ecosystem, steep learning curve.
Cursor – GUI editor, $20 / month subscription, mainly Claude models, requires proxy, easy out‑of‑box experience, limited customisation, closed system.
OpenCode – CLI, free open‑source, domestic‑friendly, supports multiple models, minimal configuration, smaller ecosystem, fewer advanced features.
Selection Advice
Choose Claude Code if you prefer terminal work, need flexible model configuration, and are comfortable with some setup.
Choose Cursor for a plug‑and‑play GUI experience and are willing to pay a subscription.
Choose OpenCode for a free, open‑source solution that works well in China without a proxy.
Skills Configuration
List available Skills: claude skills list Install a Skill (recommended tool skillhub, fallback clawhub): skillhub install <skill-name> Commonly recommended Skills:
# GitHub integration (proxy needed)
skillhub install github
# File search (no proxy)
skillhub install ripgrep
# Weather query (no proxy)
skillhub install weather
# Code review (no proxy)
skillhub install code-review
# Database tools (no proxy)
skillhub install databaseEnable Skills via ~/.claude/settings.json:
{
"skills": {
"enabled": ["github","ripgrep","weather"],
"github": {"token": "your-github-token"}
}
}Create custom Skill by adding a folder under ~/.claude/skills/ with a skill.json describing name, description, and tool commands.
MCP (Model Context Protocol) Configuration
Install MCP CLI and servers (may need proxy for some servers):
# MCP CLI
npm install -g @modelcontextprotocol/cli
# Example servers
npm install -g @modelcontextprotocol/server-filesystem
npm install -g @modelcontextprotocol/server-postgres
npm install -g @modelcontextprotocol/server-github # proxy neededEdit ~/.claude/mcp.json to declare servers, e.g., filesystem and GitHub.
Verify MCP servers: claude mcp list Common servers: filesystem (no proxy), GitHub (proxy), PostgreSQL (no proxy), fetch (proxy).
Local Development Tips
Initialize a project:
cd my-project
claude
claude "help me initialise a Python project"Common commands:
claude --help
claude "explain this file" src/main.py
claude # interactive session
claude --print "fix this bug" < bug-report.txtUse a .clinerules file to enforce project conventions (e.g., TypeScript, ESLint, JSDoc, async/await).
Context management:
claude /add src/main.ts src/utils.ts
claude /remove src/old-file.ts
claude /contextSlash commands for quick actions:
/search functionName
/shell npm install
/exitMulti‑file editing:
"refactor the authentication module, update auth.ts and user.ts"Performance Optimisation
Reduce token usage by adding only necessary files: claude /add src/core/*.ts Use precise queries instead of broad searches.
Enable caching in ~/.claude/config.json:
{"cache":{"enabled":true,"maxSize":"1GB"}}Debugging Tips
Enable verbose logging:
export CLAUDE_DEBUG=true
claude --verboseShow current configuration: claude config show Reset configuration to defaults:
claude config resetSecurity Best Practices
Never commit API keys to Git; store them in environment variables or config files and rotate regularly.
Add Claude‑related files to .gitignore (e.g., .claude/config.json, .claude/settings.json, .claude/mcp.json, *.api.key).
Restrict MCP filesystem access to a safe directory in ~/.claude/mcp.json.
Troubleshooting
Invalid API key: check $ANTHROPIC_API_KEY, then run claude config to re‑enter.
Model unavailable in China: switch to a domestic service by updating ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY (e.g., SiliconFlow or DeepSeek).
Connection timeout: test network with curl -I https://api.siliconflow.cn/v1 and enable a proxy if needed.
MCP server fails to start: verify Node.js version, reinstall the server package.
Skills not working: list installed Skills with claude skills list and re‑enable with claude skills enable <skill>.
Resources
Claude Code documentation – https://docs.anthropic.com/claude-code/
MCP protocol spec – https://modelcontextprotocol.io/
Anthropic API docs – https://docs.anthropic.com/
SiliconFlow docs – https://docs.siliconflow.cn/
DeepSeek docs – https://platform.deepseek.com/api-docs/
Alibaba DashScope – https://help.aliyun.com/zh/dashscope/
Claude Code GitHub repo – https://github.com/anthropics/claude-code
MCP servers list – https://github.com/modelcontextprotocol/servers
Skills marketplace – https://clawhub.com/
Conclusion
Claude Code is a powerful CLI AI assistant; with appropriate configuration Chinese users can operate it without a proxy.
For full Claude model access, OpenRouter is the recommended bridge (proxy required).
For cost‑effective, proxy‑free usage, SiliconFlow, DeepSeek, or Ollama are optimal choices.
Leverage Skills and MCP to extend functionality, and follow security best practices to protect API keys.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
