Claude Code Installation & Setup Guide: Build Your AI Coding Assistant from Scratch
Claude Code Installation & Setup Guide…
Complete guide to installing Claude Code and configuring it with domestic LLMs for AI-powered coding.
This tutorial walks you through setting up Claude Code from scratch, including installing Git and Node.js prerequisites, configuring system environment variables, bypassing connection verification for users in China, and connecting free domestic LLMs like Qwen via Alibaba Cloud's DashScope platform as an alternative to paid Claude subscriptions.
What Is Claude Code?
Claude Code is an AI coding assistant developed by Anthropic. Unlike traditional AI chat tools such as ChatGPT or DeepSeek, it doesn't just chat — it can directly take action on your computer. You simply describe what you need in natural language, and it understands your project structure to automatically carry out operations.
Think of it this way: traditional AI chat is like calling a remote consultant for advice, while Claude Code is like having an assistant sitting next to you who can browse through your folders and modify code on their own.
From a technical standpoint, Claude Code belongs to the emerging "Agentic Coding" paradigm. Unlike traditional code completion tools (like GitHub Copilot) or conversational AI, Agentic Coding tools possess capabilities for autonomous planning, tool invocation, and environment interaction. Anthropic positions it as an AI Agent that runs in the terminal, powered by Claude's large language model (currently primarily Claude 4 Sonnet/Opus). It can understand complex instructions and break them down into multiple executable steps. The core breakthrough of this paradigm is that AI is no longer passively answering questions — it actively perceives its environment, formulates plans, and executes actions, forming a complete "perceive-reason-act" loop.
Five Key Differences Between Claude Code and Regular AI Chat
Different Interaction Methods
Traditional AI chat requires you to copy-paste code into the chat box and then copy answers back to your editor — a tedious workflow. Claude Code operates directly in your project directory, eliminating the back-and-forth.
Deeper Contextual Understanding
Regular AI only knows what you explicitly tell it, whereas Claude Code can automatically read your entire project's code, proactively search related files, and maintain a holistic understanding of the project.
Stronger Execution Capabilities
Regular AI can only provide code snippets or suggestions and often struggles with complex multi-file projects. Claude Code can directly create files, modify code, run commands, and execute tests — offering complete execution capability.
Persistent Memory
Regular AI treats each conversation independently — close the window and it loses all memory. Claude Code uses configuration files to remember your project rules and coding preferences, maintaining consistent style throughout.
Flexible Tool Integration
Web-based AI can barely call external tools. Claude Code connects directly to browsers, databases, GitHub, and other external services through the MCP protocol, offering exceptional extensibility.
MCP (Model Context Protocol) is a standardized protocol open-sourced by Anthropic in late 2024, designed to solve the connection problem between large language models and external tools/data sources. Before MCP, integrating each AI tool with external services required developing separate adapters, leading to severe ecosystem fragmentation. MCP adopts a design philosophy similar to USB ports — defining a unified communication standard that allows any protocol-compliant tool to be plug-and-play. In Claude Code, MCP enables AI to directly operate browsers (via Puppeteer/Playwright MCP Server), query databases (via PostgreSQL/MySQL MCP Server), manage GitHub repositories, and more, greatly expanding AI's capability boundaries. Developers can also write their own MCP Servers to integrate custom tools.
Claude Code Core Capabilities Overview
Based on real-world usage experience, Claude Code can handle the following tasks:
- Code Operations: Read, edit, and create files; search code content; refactor code; add comments and documentation
- Project Management: Git operations, task list management, running long-duration tasks in the background
- Information Retrieval: Scraping and analyzing web pages, web search, fetching real-time information
- Advanced Features: Scheduling timed reminders, creating dedicated agents for complex tasks
For front-end developers, Claude Code is more token-efficient compared to Cursor, and its outputs often better match expectations. The differences between the two are worth elaborating: Cursor is a deeply customized AI code editor based on VS Code with a graphical interface, featuring built-in code completion, chat, and code editing functionality. The core difference lies in the interaction paradigm — Cursor is IDE-centric, with AI embedded as an enhanced editor feature; Claude Code is terminal-centric, with AI running as an independent Agent that interacts with the development environment through the command line. Regarding token consumption, Cursor's Composer mode automatically sends extensive context (including open files, cursor position, etc.) to the model, easily resulting in higher token usage; Claude Code reads files more precisely on-demand, making it generally more economical for large projects. However, Cursor has clear advantages in visual experience and low barrier to entry, making it more suitable for developers unfamiliar with the command line.
Installing Prerequisites: Git and Node.js
Claude Code supports multiple usage modes including terminal, IDE integration, web interface, and desktop app. This guide uses the terminal approach, which best aligns with developer workflows.
Installing Git
- Visit the Git official website to download the installer
- Follow the installation wizard, clicking Next through each step
- Verify installation: open the command line and type
git— no error means success
Installing Node.js
- Visit the Node.js official website and download the Windows installer
- Follow the wizard as well; keeping the default C drive path is recommended
- Verify installation: type
node -vin the command line — a version number confirms success
Installing Claude Code
Open Windows PowerShell (standard permissions are fine — no admin privileges needed) and run the following command:
npm install -g @anthropic-ai/claude-code
npm (Node Package Manager) is the default package manager for Node.js and the world's largest open-source software registry, hosting over 2 million JavaScript packages. The -g flag means global installation, which installs Claude Code to a system-level directory rather than the current project directory, making it callable from any path via the command line. Globally installed packages are typically CLI (command-line interface) tools, while project dependencies use local installation without -g. For users in China, npm connects to overseas registry servers by default. You can switch to the Taobao mirror with npm config set registry https://registry.npmmirror.com to significantly improve download speeds.
The installation takes a few minutes. Seeing version information (e.g., 2.1.104) indicates successful installation. After completion, you can find the claude.exe executable at C:\\Users\\your-username\\.local\\bin\\.
Three Configuration Steps to Get Claude Code Running
Step 1: Configure Environment Variables
Some users encounter a "command not found" error when running claude because the system's environment variables are missing Claude Code's path.
Environment variables are key-value pairs used by the operating system to store configuration information, loaded into memory when a process starts. The Path variable is particularly special — it tells the OS which directories to search for executable files. When you type claude in the terminal, the system searches each directory listed in Path for a file named claude.exe. This also explains why you must reopen the terminal after modifying environment variables: running terminal processes loaded the old environment variable copy at startup and won't automatically detect subsequent changes.
Solution:
- Search for "environment variables" in the Windows search bar and open "Edit the system environment variables"
- Find
Pathunder User variables and double-click to edit - Click "New" and add the path:
C:\\Users\\your-username\\.local\\bin - Save and confirm, then reopen the terminal to verify
Step 2: Bypass Connection Verification
Due to network restrictions, users in China may encounter authorization connection failures.
Solution:
- Locate the
C:\\Users\\your-username\\.claude.jsonconfiguration file - Open it with a text editor
- Add the bypass verification configuration (pay attention to JSON formatting with commas between fields)
- Save and run
claudeagain
Step 3: Connect to a Domestic LLM
Claude Code's built-in model requires a paid subscription. Users in China can connect to Alibaba Cloud's Bailian (DashScope) platform for free models as an alternative.
Alibaba Cloud Bailian (DashScope) is Alibaba's large model service platform, providing API access to the Qwen series models. Its /compatible-mode/v1 endpoint implements compatibility with the OpenAI API format, meaning any tool supporting the OpenAI interface standard can connect to Qwen models by simply modifying the Base URL. This compatibility design has become standard practice among Chinese LLM providers — Baidu's ERNIE, Zhipu GLM, Moonshot Kimi, and others all offer similar compatible interfaces. Note that while the interface format is compatible, different models vary significantly in code generation capability, context window size, and reasoning depth. The original Claude model typically performs better on complex code reasoning tasks.
Setup Process:
- Register on Alibaba Cloud Bailian: After logging in, check "Model Usage" to confirm your account has free credits
- Create an API Key: Find "API Key" in the left menu and click to create one
- Set three environment variables:
# Set API Key
set ANTHROPIC_API_KEY=your-api-key
# Set API Base URL (Alibaba Cloud Bailian compatible endpoint)
set ANTHROPIC_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
# Set model name
set ANTHROPIC_MODEL=qwen-max
In Claude Code's configuration, ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, and ANTHROPIC_MODEL control authentication, API endpoint address, and model selection respectively. This is the standard configuration pattern for OpenAI-compatible interfaces, and nearly all tools supporting this standard follow the same variable naming conventions.
- Verify configuration: Use
echocommands to output each environment variable and confirm they match your settings
Recommended free models include GLM-5, Qwen 3.6 Plus, and others — choose based on personal preference.
Common Issues and Tips
- Environment variables not taking effect: You must reopen the terminal window after modifying environment variables — old windows won't auto-refresh
- Slow npm installation: Configure an npm mirror source first to switch to a domestic node for faster downloads. Run
npm config set registry https://registry.npmmirror.comto switch to the Taobao mirror, which typically improves download speeds by 10x or more - Model selection tips: Free models work well for daily development and learning. For higher-quality output, consider a paid subscription to the original Claude model. The original Claude significantly outperforms most free alternatives in code reasoning, long-context understanding, and complex refactoring tasks
Summary
While Claude Code's installation and setup involves multiple steps, none of them are complicated. The core process can be summarized as:
- Install Git and Node.js as prerequisites
- Install Claude Code globally via npm
- Configure environment variables, bypass verification, and connect to a domestic LLM
Once configured, you'll have an AI coding assistant that can directly read and write files and execute commands within your project. Compared to tools like Cursor, Claude Code performs well in both token efficiency and output quality — definitely worth trying for developers.
Related articles

Claude Code for Test Development in Practice: An AI Programming Workflow That Doubles Your Efficiency
A practical guide to Claude Code for test development: auto-generating test scripts, Plan Mode workflows, MCP + Playwright integration, and Subagent parallel tasks to build systematic AI-assisted workflows.

Hermes Agent Hands-On Review: An AI Efficiency Revolution for Indie Game Developers
Indie game developer reviews Hermes Agent vs OpenClaude: intelligent context compression, real-time Memory, remote control via Telegram, and practical use cases in game dev, social media, and email.

Vibe Coding Beginner's Guide: Tool Selection Across Three Categories with Practical Examples
A comprehensive guide to Vibe Coding's three tool categories: Agent frameworks, CLI Coding, and IDE tools, with practical examples including Snake game and data analysis workbench.