Claude Code is Anthropic's terminal-based AI programming assistant that can read code, write code, run tests, and fix bugs directly from your command line. Paired with DeepSeek V4's compatible API, costs drop by 50x — and Chinese developers can get started with ease.
1. Why Claude Code + DeepSeek V4?
The AI programming landscape has fundamentally shifted in 2026. Terminal AI tools are becoming the new standard for developers, and Claude Code is one of the best experiences available.
What Is Claude Code?
Claude Code is not a chat window in your browser or an IDE plugin — it's an AI Agent running in your terminal with file system read/write access and shell execution privileges. You can:
- Let it read your project code: Automatically understand the entire codebase structure
- Modify files directly: No copy-pasting — it edits your source files right in place
- Run commands: Execute tests, builds, linting, and more
- Multi-step reasoning: Break down tasks like a real engineer and work through them step by step
In short, Claude Code turns a large language model into a "junior engineer sitting next to you at the terminal."
Why Pair It with DeepSeek V4?
Claude Code natively calls Anthropic's Claude models (Opus/Sonnet), but access from China can be inconvenient and the costs are relatively high. DeepSeek officially provides an API fully compatible with Anthropic's API, letting you swap Claude Code's backend to DeepSeek V4:
| Comparison | Anthropic Claude Opus | DeepSeek V4 Pro |
|---|---|---|
| Input price | ~$15/million tokens | ~$0.28/million tokens |
| Context window | 200K | 1M (1 million tokens) |
| Max output | 8K | 384K |
| Cache hits | Paid | Nearly free |
| Chinese language support | Excellent | Excellent |
Key number: costs drop by roughly 50x, while you get a much larger context window. For day-to-day development workflows, DeepSeek V4 Pro is more than capable.
2. Installing Claude Code
Prerequisites
- Node.js 18+ (Claude Code is built on Node.js)
- Git (Windows users need Git for Windows)
Install Node.js:
# macOS (via Homebrew)
brew install node
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify installation
node --version # Should show v18+ or higher
npm --version
Install Claude Code
# Global install
npm install -g @anthropic-ai/claude-code
# Verify installation
claude --version
If you see a version number, the installation succeeded.
3. Configuring the DeepSeek V4 Backend
This is the most critical step — making Claude Code use DeepSeek V4 instead of Anthropic's native models.
3.1 Get Your DeepSeek API Key
Go to the DeepSeek Open Platform, register an account, and create an API Key.
3.2 Set Environment Variables
macOS / Linux users:
# DeepSeek compatibility endpoint
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
# Your API Key (replace with your actual key)
export ANTHROPIC_AUTH_TOKEN=sk-your-deepseek-api-key
# Primary model: DeepSeek V4 Pro (1M context)
export ANTHROPIC_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4-pro[1m]
# Lightweight model: V4 Flash (for sub-tasks and fast inference)
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash
# Maximum reasoning effort
export CLAUDE_CODE_EFFORT_LEVEL=max
We recommend adding these variables to ~/.bashrc or ~/.zshrc so you don't have to re-set them every time you open a terminal:
echo 'export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN=sk-your-deepseek-api-key' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL=deepseek-v4-pro[1m]' >> ~/.zshrc
echo 'export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro[1m]' >> ~/.zshrc
echo 'export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4-pro[1m]' >> ~/.zshrc
echo 'export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash' >> ~/.zshrc
echo 'export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash' >> ~/.zshrc
echo 'export CLAUDE_CODE_EFFORT_LEVEL=max' >> ~/.zshrc
source ~/.zshrc
Windows PowerShell users:
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="sk-your-deepseek-api-key"
$env:ANTHROPIC_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"
3.3 Verify Your Configuration
Navigate to any project directory and launch Claude Code:
cd /path/to/your-project
claude
If Claude Code's interactive interface starts up, your configuration is correct.
4. Hands-On: Real Development Tasks with Claude Code
Now that everything is set up, let's jump into practice. I'll walk through 3 real-world scenarios demonstrating the actual development capabilities of Claude Code + DeepSeek V4.
Scenario 1: Quickly Build a REST API Service
Your prompt:
Create a Python FastAPI project with the following features:
1. GET /users - Get user list
2. POST /users - Create a new user
3. GET /users/{id} - Get single user details
Use SQLite database, include data validation and error handling
What Claude Code will do:
- Create the project directory structure
- Generate
requirements.txt - Write
main.py(with all routes) - Write
database.py(database connection and table creation) - Write
models.py(Pydantic models) - Automatically install dependencies and run tests
Generated code example:
# main.py
from fastapi import FastAPI, HTTPException, Depends
from pydantic import BaseModel, EmailStr
from typing import Optional
import sqlite3
app = FastAPI(title="User API")
# --- Models ---
class UserCreate(BaseModel):
name: str
email: EmailStr
age: Optional[int] = None
class UserResponse(BaseModel):
id: int
name: str
email: str
age: Optional[int]
# --- Database Helper ---
def get_db():
conn = sqlite3.connect("users.db")
conn.row_factory = sqlite3.Row
try:
yield conn
finally:
conn.close()
# --- Routes ---
@app.get("/users", response_model=list[UserResponse])
def list_users(db: sqlite3.Connection = Depends(get_db)):
rows = db.execute("SELECT * FROM users").fetchall()
return [dict(row) for row in rows]
@app.post("/users", response_model=UserResponse, status_code=201)
def create_user(user: UserCreate, db: sqlite3.Connection = Depends(get_db)):
cursor = db.execute(
"INSERT INTO users (name, email, age) VALUES (?, ?, ?)",
(user.name, user.email, user.age),
)
db.commit()
return {"id": cursor.lastrowid, **user.model_dump()}
@app.get("/users/{user_id}", response_model=UserResponse)
def get_user(user_id: int, db: sqlite3.Connection = Depends(get_db)):
row = db.execute("SELECT * FROM users WHERE id = ?", (user_id,)).fetchone()
if not row:
raise HTTPException(status_code=404, detail="User not found")
return dict(row)
Claude Code won't just generate code — it'll also create initialization scripts in database.py and even write pytest test cases for you.
Scenario 2: Refactor Existing Code
Say you have a messy Python file that needs refactoring:
Please refactor current_code.py with the following:
1. Extract repeated logic into independent functions
2. Add type annotations
3. Add docstrings
4. Follow PEP 8 conventions
5. Ensure functionality is unchanged after refactoring — run tests to verify
Claude Code will: - Read the original file - Analyze the code structure - Generate a refactored version - Automatically run tests to verify functional consistency - If any tests fail, debug and fix them automatically
Scenario 3: Debug a Bug
My project's tests/ directory has 3 failing tests. Help me find the root cause and fix them.
Start by running pytest to see the error messages, then analyze them one by one.
Claude Code will execute the following steps:
# Automatically run tests
pytest tests/ -v
# Analyze failures, inspect related source files
cat src/utils.py
cat tests/test_utils.py
# Fix bugs (edit files directly)
# ... editing process ...
# Re-run tests to verify
pytest tests/ -v
This is the core advantage of terminal AI programming — Claude Code doesn't just give you suggestions; it actually executes commands, modifies files, and verifies results right in your terminal.
5. Advanced Usage Tips
5.1 Using the CLAUDE.md Configuration File
Create a CLAUDE.md file in your project root so Claude Code understands your project conventions and preferences:
# CLAUDE.md
## Project Conventions
- Use Python 3.12+
- Follow PEP 8 coding style
- Use pytest for unit tests
- All functions must have type annotations
## Common Commands
- Run tests: `pytest tests/ -v`
- Format code: `ruff format .`
- Lint code: `ruff check .`
## Architecture Notes
- src/ directory contains main source code
- tests/ directory contains test code
- Database uses SQLite
Claude Code automatically reads this file on startup and works according to your conventions.
5.2 Sub-Model Division Strategy
Through environment variables, we've configured two models:
- V4 Pro (primary model): Handles complex reasoning, code generation, and architecture design
- V4 Flash (sub-model): Handles simple queries, code explanations, and quick Q&A
This division significantly reduces costs. Simple file-reading and explanation tasks go through the Flash channel, while only complex tasks consume Pro tokens.
5.3 Cost Estimation
For daily development:
| Task type | Tokens per use | Cost (V4 Pro) |
|---|---|---|
| Simple Q&A / explanation | ~2K | ~$0.0006 |
| Generate a function | ~5K | ~$0.0014 |
| Refactor a file | ~20K | ~$0.0056 |
| Build a complete project | ~100K | ~$0.028 |
Assuming 50 uses per day, monthly costs come to roughly $2–5, compared to $100–200/month with direct Claude Opus usage — exceptional value.
5.4 Third-Party Proxy Options
If you'd rather not use the DeepSeek API directly, here are alternative approaches:
Option A: SiliconFlow
export ANTHROPIC_BASE_URL=https://api.siliconflow.cn/v1
export ANTHROPIC_AUTH_TOKEN=sk-siliconflow-key
export ANTHROPIC_MODEL=deepseek-ai/DeepSeek-V4
Option B: One-API / New-API Aggregation Platform
Supports connecting to multiple model providers simultaneously with automatic load balancing.
6. Frequently Asked Questions
Q1: How good is DeepSeek V4 at coding?
According to independent evaluations, DeepSeek V4 scores close to GPT-4o on HumanEval and MBPP benchmarks — more than sufficient for everyday development tasks (CRUD, refactoring, test writing). Opus still holds an edge in complex architecture design scenarios, but the gap is narrowing.
Q2: Can I use it normally from within China?
Yes. The DeepSeek API is directly accessible from China with no special network configuration needed. Claude Code itself is an npm package, so installation is also unrestricted.
Q3: How does it compare to Cursor and GitHub Copilot?
| Feature | Claude Code | Cursor | GitHub Copilot |
|---|---|---|---|
| How it runs | Terminal | IDE | IDE plugin |
| File system access | ✅ Full read/write | ✅ Full read/write | ❌ Suggestions only |
| Shell execution | ✅ Direct execution | ⚠️ Limited | ❌ Not supported |
| Context window | 1M | 100K–200K | 128K |
| Custom backend | ✅ Compatible API | ✅ | ❌ Vendor-locked |
| Monthly cost | $2–5 | $20 | $10–39 |
Claude Code's core advantages are terminal-native operation, full Agent capabilities, and backend flexibility.
7. Summary
The Claude Code + DeepSeek V4 combo is currently the most cost-effective terminal AI programming solution available:
- ✅ Zero learning curve: Chat directly in the terminal — as natural as talking to a colleague
- ✅ 50x cost advantage: Compared to Anthropic's native solution
- ✅ 1M ultra-large context: Can understand an entire project's code
- ✅ China-friendly: Direct DeepSeek API connection, no proxy needed
- ✅ Open-source ecosystem: Active CLAUDE.md, plugin, and Skills community
If you're a heavy command-line user, or want the full power of an AI programming assistant without ever leaving your terminal, this setup is worth trying.
References: