A complete beginner-friendly guide — get your AI coding assistant running in 30 minutes
Claude Code is Anthropic's command-line AI coding assistant. You describe what you want in natural language, and it reads code, edits files, runs commands, and commits to Git — all from your terminal.
DeepSeek provides an API endpoint fully compatible with Anthropic's protocol. With just 4 environment variables, you can power Claude Code with DeepSeek and get a near-native coding experience at a fraction of the cost.
| Claude Opus 4.7 | DeepSeek V4 Pro | |
|---|---|---|
| Input Price | ~$5 / MTok | ~$0.41 / MTok |
| Output Price | ~$25 / MTok | ~$0.83 / MTok |
| Direct Access (China) | Requires VPN | Works directly ✅ |
| Context Window | 1M | 1M |
Pricing (verified 2026-05-20): DeepSeek V4 Pro at ¥3 input / ¥6 output per million tokens (permanent price drop since April 26); cache-hit scenarios as low as ¥0.025. DeepSeek's output cost is roughly 1/30th of Claude Opus 4.7.
- A computer with internet (Windows / macOS / Linux)
- A phone number (for DeepSeek registration)
- Alipay or WeChat (minimum top-up: ¥1)
- About 30 minutes
Git is a version control tool. Claude Code depends on it for commits, diffs, branching, and more.
Claude Code does not automatically initialize Git for you. Open your terminal, navigate to the project folder, and run
git initfirst.
-
Open https://git-scm.com and click Download for Windows
-
Run the downloaded
Git-2.xx.x-64-bit.exe -
Click Next through all steps (defaults are fine)
-
After installation, press
Win + R, typecmd, and hit Enter -
In the terminal, type:
git --versionIf you see git version 2.xx.x, Git is installed successfully.
Open Terminal (Cmd + Space, search "Terminal") and run:
git --versionIf not installed, macOS will prompt you to install Xcode Command Line Tools — click Install and wait.
Optional: Install Homebrew — a "command-line App Store" that lets you install Git, Node.js, and other dev tools with a single command:
First, check if it's already installed:
brew --versionIf you see
Homebrew 4.x.x, you're good — skip to the next step.If you get
command not found, install it with:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Once Homebrew is ready, install Git:
brew install git
sudo apt update
sudo apt install git -y
git --versionClaude Code runs on Node.js — you must install it first.
- Go to https://nodejs.org and click the green LTS button
- Run the downloaded
node-v20.xx.x-x64.msi - Important: During installation, make sure "Add to PATH" is checked (on by default)
- Click Next until finished
- Close and reopen your terminal, then run:
node --version
npm --versionBoth should show version numbers (e.g., v20.12.2 and 10.5.0).
If you have Homebrew installed, run in terminal:
brew install nodeOr download the .pkg installer from https://nodejs.org, and click Next until finished. Verify:
node --version
npm --versioncurl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
node --version
npm --versionOnce Node.js is set up, install Claude Code with one command.
💡 Users in China — set the npm mirror first (otherwise downloads may be slow or fail):
npm config set registry https://registry.npmmirror.comVerify:
npm config get registry # Should output: https://registry.npmmirror.com
npm install -g @anthropic-ai/claude-codeWindows users: Run the terminal as Administrator (right-click Start → Terminal (Admin)), otherwise you may hit permission errors.
Installation takes 1–2 minutes. Verify:
claude --versionYou should see a version number (e.g., 2.1.144 (Claude Code)).
When you first run claude, Claude Code normally asks you to log in with an Anthropic account. Since we're using DeepSeek as the backend, skip this by creating a .claude.json file:
| System | Path |
|---|---|
| Windows | C:\Users\YourUsername\.claude\.claude.json |
| macOS / Linux | ~/.claude/.claude.json |
Open .claude.json — there are two possible situations:
Situation A: File doesn't exist (fresh install)
Create the file and write:
{
"hasCompletedOnboarding": true
}Situation B: File already exists (Claude Code was installed before)
Open the existing file. You might see something like:
{
"installMethod": "native",
"autoUpdates": true
}Notice: the line "autoUpdates": true has no trailing comma — because it's the last item.
To add the new config, do two things:
- Add an English comma
,at the end of the last existing line (aftertrue) - On a new line, add
"hasCompletedOnboarding": true
After editing:
{
"installMethod": "native",
"autoUpdates": true,
"hasCompletedOnboarding": true
}💡 What's the comma for?
In JSON, commas
,separate multiple fields at the same level — like saying "this one's done, here comes the next." Two simple rules:
- Fields between other fields must be separated by a comma
- The last field must NOT have a trailing comma (nothing comes after it)
If there's only one field inside
{ }(like Situation A), it's both the first and the last — so no comma is needed.
What does this JSON mean?
- The outer
{ }is the standard JSON wrapper — all config must live inside these curly braces "hasCompletedOnboarding"is a config key — it asks "has the user finished the first-time setup?"trueis its value — meaning "yes, it's done";falsewould mean "no, not yet"- The colon
:between them means "is set to" - In plain English: tell Claude Code "the onboarding is already done, don't show the login screen"
⚠️ JSON formatting tips:
- Curly braces
{ }, colons:, and commas,must all be standard English half-width characters — Chinese full-width punctuation (,:) will break the file- Config keys (like
"hasCompletedOnboarding") must be wrapped in English double quotes" "true/falseshould NOT be quoted — they are JSON boolean keywords, not strings
Close and save the file. Now when you run claude, it will skip the login screen and go straight to the AI prompt.
The goal: tell Claude Code to route all requests through DeepSeek instead of Anthropic.
| System | Path |
|---|---|
| Windows | C:\Users\YourUsername\.claude\settings.json |
| macOS / Linux | ~/.claude/settings.json |
If the file doesn't exist, create it.
Open the file in any text editor and paste the following (replace sk-your-key-here with your actual API key):
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-your-deepseek-api-key",
"ANTHROPIC_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash[1m]",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-flash[1m]",
"CLAUDE_CODE_EFFORT_LEVEL": "max"
}
}Field Reference (skip if you're new):
| Field | Meaning |
|---|---|
ANTHROPIC_BASE_URL |
API endpoint — redirects from Anthropic to DeepSeek |
ANTHROPIC_AUTH_TOKEN |
Your DeepSeek API key |
ANTHROPIC_MODEL |
Primary model; [1m] enables 1M token context |
ANTHROPIC_DEFAULT_OPUS_MODEL |
Opus role → actually uses DeepSeek V4 Pro |
ANTHROPIC_DEFAULT_SONNET_MODEL |
Sonnet role → actually uses DeepSeek V4 Pro |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
Haiku role → actually uses DeepSeek V4 Flash (lightweight) |
CLAUDE_CODE_SUBAGENT_MODEL |
Sub-agents use the lighter model to save tokens |
CLAUDE_CODE_EFFORT_LEVEL |
max = strongest reasoning capability |
💡 Model choice: Primary recommendation is
deepseek-v4-pro[1m]; lightweight tasks usedeepseek-v4-flash.
Close and save the file, then proceed to get your API key.
DeepSeek API is pay-as-you-go — you only pay for what you use, not a monthly subscription. Minimum top-up is ¥1, which lasts a long time for casual use.
- Open https://platform.deepseek.com
- Click Sign In (登录) in the top right, register with your phone number
- You'll land on the console dashboard
- Click Top Up (充值) in the left sidebar
- Enter an amount (minimum ¥1)
- Pay with Alipay or WeChat
- Click API Keys in the left sidebar
- Click Create API Key
- Give it a name (e.g.,
claude-code) - Copy and save it immediately — the key is shown only once
- The key starts with
sk-followed by a long string
⚠️ Treat your API key like a password. Never share it or commit it to a public repository.
Open a terminal and type:
claudeFirst launch may take 1–2 minutes to initialize. You'll see a welcome screen when ready.
Ask a simple question:
What is 1 + 1?
If it responds normally, your setup is correct. The startup banner should also mention deepseek-v4-pro.
To confirm requests are actually hitting DeepSeek:
claude --debug-file debug.logAsk any question and exit. Open debug.log and search for api.deepseek.com — if you find it, you're 100% confirmed.
The npm global install directory is not in your system PATH.
Windows: Reopen an Admin terminal and try again. If it still fails, run npm config get prefix to find the path, then manually add it to your system PATH.
macOS / Linux:
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc- Double-check
ANTHROPIC_AUTH_TOKENinsettings.json(must start withsk-) - Check your API key status on the DeepSeek console
- Make sure your account has a balance
DeepSeek may experience queues during peak hours.
Fix: add this line to the env section of settings.json:
"API_TIMEOUT_MS": "3000000"Notepad saved with the wrong encoding. Use Save As and change encoding to UTF-8. Better yet, use VS Code or Notepad++.
# Recommended: use nvm to manage Node.js
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install 20
nvm use 20
# Alternative: change npm global directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
source ~/.zshrcThis is a known difference. Some DeepSeek models have ~80% tool-calling accuracy vs. Claude's 98%+. For daily use the impact is minimal. For complex tasks:
- Break work into smaller steps
- Double-check generated results
claude-code deepseek ai-coding tutorial beginner-friendly developer-tools
See CONTRIBUTING.md. Issues and PRs welcome.
MIT — see LICENSE.