[KongchangAI]
Tutorials· 3 min read· 1,955 words

Claude Code Installation Guide: Terminal Setup from Scratch + Budget-Friendly Alternatives in China

Claude Code Installation Guide: Terminal Setup from Scratch + Budget-Friendly Alternatives in China

Complete Claude Code installation guide with budget-friendly domestic model alternatives for beginners.

This article systematically introduces Claude Code — a terminal-based AI coding agent — for complete beginners. It covers core concepts, the full installation process (Node.js setup, npm global installation, API Key configuration), common troubleshooting, and four usage options at different price points: Anthropic's official API, domestic model APIs (like DeepSeek), API proxy services, and local open-source model deployment with Ollama, helping users get started with AI coding at minimal cost.

Recently, Claude Code accidentally leaked approximately 510,000 lines of source code due to a packaging mishap, giving the industry its first real glimpse into the evolution of this AI coding tool. But for most regular users, the core questions remain: What exactly is it? How can a complete beginner get started? Are there more affordable alternatives?

This article starts from the most basic concepts, walking you through Claude Code's terminal installation, verification, and first run step by step. We'll also cover domestically available model alternatives to help you get started with AI coding at minimal cost.

For most regular people

What Is Claude Code? What Can It Do for You?

Not Just a Chatbot — It's an AI Programmer in Your Terminal

Many people still think of Claude as a "web-based chatbot." But Claude Code is entirely different — it's an AI coding agent that runs in your terminal (command line), capable of directly reading your project files, understanding code context, executing commands, modifying files, and even building a complete application from scratch.

For users who have never touched a terminal before, here's a quick primer: A terminal is a text-based interaction interface provided by your operating system where users type commands to control the computer, rather than clicking through a graphical interface. In software development, the terminal is one of the most fundamental and powerful tools — from installing packages and running programs to managing servers, virtually all professional development work involves it. Think of it as "controlling your computer by typing instead of clicking." Claude Code runs in the terminal precisely because the terminal can directly access the file system and execute system commands, giving AI the ability to truly "get hands-on."

The term "AI coding agent" mentioned here involves one of the most important concepts in current artificial intelligence — AI Agent (intelligent agent). Unlike traditional chatbots that can only "answer questions," an Agent possesses the ability to autonomously plan, invoke tools, and interact with environments. It can break down a complex task into multiple steps and sequentially call different tools to complete them. Claude Code is a quintessential coding Agent — when you describe a requirement, it autonomously decides which files to create, what code to write, which commands to execute, and automatically debugs and fixes errors when they occur, all without manual step-by-step guidance.

In short, it's not an assistant that makes you copy-paste code — it's an AI coding tool that can directly work in your development environment.

Who Should Use Claude Code?

  • Complete beginners who can't code: Describe requirements in natural language and let Claude Code generate complete projects for you
  • Developers with some experience: Use it to accelerate development, debug issues, and refactor code
  • Product managers/designers: Quickly build prototypes and validate ideas

Helping you understand what Claude Code can actually do for you

From the leaked 510,000 lines of source code, Claude Code has internally integrated extremely sophisticated toolchain invocation, file system operations, and multi-turn conversation context management capabilities — far more powerful than what we see on the web interface.

Complete Claude Code Installation Guide (Mac/Windows/Linux)

Step 1: Set Up Terminal Environment and Node.js

Before starting the installation, confirm that you have a usable terminal tool on your computer:

  • Mac users: Open the built-in "Terminal" application
  • Windows users: Install Windows Terminal or use PowerShell
  • Linux users: Any terminal emulator will work

You also need to ensure Node.js is installed (version 18.0 or above recommended).

Node.js is a JavaScript runtime environment built on Chrome's V8 engine that allows JavaScript to run on servers and local machines, not just in browsers. Claude Code requires Node.js because it's a command-line tool written in JavaScript/TypeScript that needs the Node.js environment to execute. npm (Node Package Manager) is Node.js's built-in package manager and the world's largest open-source software registry, hosting over 2 million packages. Developers can install and manage various tools and libraries through simple npm commands. Claude Code is distributed via npm because the Node.js ecosystem has extremely high adoption among developers, and npm's global installation mechanism allows command-line tools to be invoked from anywhere on the system.

Check your version by entering the following command in the terminal:

node -v

If not installed or the version is too old, download the latest LTS version from the Node.js official website.

Step 2: Install Claude Code with One Command

Once your environment is ready, installing Claude Code requires just one command:

npm install -g @anthropic-ai/claude-code

This command globally installs Claude Code via npm. The -g flag means "global installation," meaning once installed, you can use the claude command from any directory on your computer, not just a specific project folder. If you encounter permission issues during installation, Mac/Linux users can prefix the command with sudo.

Installation command

Step 3: Verify Installation and Configure API Key

After installation, type in the terminal:

claude

If you see Claude Code's interactive interface launch, the installation was successful. On first run, the system will ask you to configure an API Key — which brings us to the next critical question: the cost of the official solution and more affordable alternatives.

4 Common Pitfalls During Installation

  1. Node.js version too old: Claude Code requires Node.js 18+; older versions will throw errors directly — upgrade first
  2. Unstable network connection: npm installation may fail due to network issues; try switching to a mirror (e.g., Taobao mirror: npm config set registry https://registry.npmmirror.com)
  3. Insufficient permissions: Global installation requires admin privileges; add sudo when encountering EACCES errors
  4. API Key format confusion: Be aware of format differences between official Anthropic Keys and third-party proxy Keys

Cost Comparison and Domestic Model Alternatives

Claude Code Official API Pricing

Claude Code uses Anthropic's API, billed per token. First, let's understand what a token is: a token is the basic unit through which large language models process text. One token doesn't equal one character or one word — in English, a common word usually corresponds to 1 token, while longer or less common words may be split into 2-3 tokens; in Chinese, one character typically corresponds to 1-2 tokens. LLM APIs charge separately for "input tokens" (content you send to the model) and "output tokens" (the model's generated response), with output tokens typically costing 3-5x more than input because generating content requires more compute than understanding it.

Taking Claude 3.5 Sonnet as an example, input costs approximately $3/million tokens and output approximately $15/million tokens. Claude Code is particularly token-intensive in coding scenarios because it needs to read large amounts of project files as context input while generating complete code files as output. For frequent users, spending tens of dollars per day is not uncommon.

Anthropic also offers Max subscription plans (approximately $100-200/month) that include a certain quota of Claude Code usage, suitable for heavy users.

For beginners who just want to try it out, this pricing is admittedly not very friendly.

Can we use it more affordably?

Three Budget-Friendly Alternatives Explained

Claude Code supports configuring custom API endpoints through environment variables, meaning you can replace the underlying model with domestic LLM services to dramatically reduce costs.

Option 1: Connect to DeepSeekAd, Qwen, and Other Domestic Model APIs

Many domestic LLMs (such as DeepSeek, Qwen, Zhipu GLM, etc.) provide interfaces compatible with the OpenAI API format. Here's what this "compatibility" means: When OpenAI launched the ChatGPT API, it defined a set of HTTP interface specifications including request formats, parameter naming, and response structures. Due to OpenAI's first-mover advantage, this API format has become the de facto industry standard for LLMs. Numerous model providers both domestically and internationally have chosen to be compatible with this format, meaning client tools developed for one API can seamlessly switch to other models by simply changing the API address and key. This compatibility is the technical foundation that enables Claude Code to connect to domestic models.

By configuring environment variables, you can have Claude Code call these models:

export ANTHROPIC_BASE_URL="your API proxy address"
export ANTHROPIC_API_KEY="your Key"

This approach has the lowest cost — DeepSeek's API pricing is approximately one-tenth of Anthropic's official rates.

Option 2: Use API Proxy Services to Call Claude Models

There are many API aggregation/proxy platforms available that let you call Claude series models at lower prices — essentially "group buying" to reduce costs. These platforms typically purchase API quotas in bulk for discounts, then resell to individual users at slightly above cost. Suitable for users who want the original Claude experience while saving money.

Option 3: Deploy Open-Source Coding Models Locally with Ollama

If your computer is powerful enough (at least 16GB VRAM), you can also try using tools like Ollama to locally deploy open-source coding models (such as CodeLlama, DeepSeek-Coder) — completely free but with some performance trade-offs.

Ollama is an open-source local LLM runtime framework that greatly simplifies deploying and running open-source large language models on personal computers. Traditionally, locally deploying a large model required manually configuring Python environments, downloading model weights, handling quantization conversion, and other complex steps. Ollama packages all of this into simple Docker-like commands — a single ollama run downloads and launches a model. Note that model performance is directly related to VRAM: a 7B (7 billion) parameter model needs approximately 8GB VRAM, while a 33B (33 billion) parameter model requires about 24GB VRAM. Larger parameter counts mean better results but higher hardware requirements. For most consumer-grade GPUs, running 7B-13B parameter coding models is the realistic choice.

Cost and Performance Comparison of All Four Options

OptionMonthly CostCoding PerformanceDifficulty
Anthropic Official APIHigh ($100+)BestLow
Domestic Model APIs (DeepSeek, etc.)Low (¥10-50)GoodMedium
API Proxy ServicesMedium ($30-80)GoodLow
Local Open-Source Models (Ollama)FreeFairHigh

Running Your First Task: From Requirement Description to Code Generation

After completing installation and configuration, verify everything works with a simple task:

  1. Navigate to an empty folder in your terminal: mkdir my-first-project && cd my-first-project
  2. Launch Claude Code: type claude
  3. Describe your requirement in natural language, for example: "Create a Python script that implements a simple to-do list command-line tool"

Claude Code will automatically analyze the requirement, create files, and write code — you can watch its thinking process and operation steps in real time. This process fully demonstrates how an AI Agent works — it doesn't output all code at once, but rather works like a real programmer: first planning the project structure, then progressively creating files, writing functions, handling edge cases, and even debugging on its own when issues arise. Once complete, simply run the generated script to verify the results.

If this step runs successfully, congratulations — you've successfully set up your own AI coding environment.

Conclusion: Get It Running First, Then Optimize

The 510,000-line source code leak incident has, in a way, accelerated public understanding of Claude Code's capability boundaries. This tool is no longer "future technology" — it's a productivity tool you can use right now to boost efficiency.

For zero-experience users, the most important thing isn't pursuing the optimal configuration from the start, but getting your first task to run successfully. Whether you choose Anthropic's official solution or domestic alternatives like DeepSeek, once it's running in your terminal, you've already taken the most critical step.

Next, you can try using Claude Code to build your own small tool or integrate it into your daily development workflow — once you actually start using it, you'll find that the productivity boost from AI coding far exceeds imagination.

#Claude Code installation#AI coding agent#Claude Code tutorial#DeepSeek alternative#terminal AI programming#npm install Claude Code#budget AI coding tools
Share:

Related articles