开源项目整合 Claude 和 DeepSeek V4,通过 Agent 循环实现更强的代码生成能力,可直接集成到编程工作流中提升效率。
使用 Claude Code 的自主 agent 循环与 DeepSeek V4 Pro、OpenRouter 或任何 Anthropic 兼容后端结合。相同的用户体验,成本降低 17 倍。
Claude Code 是最好的自主编码 agent —— 但它的成本是 $200/月加使用额度限制。DeepSeek V4 Pro 在 LiveCodeBench 上得分 96.4%,成本仅需 $0.87/M 输出 token。
deepclaude 替换了大脑,但保留了身体:
Your terminal
+-- Claude Code CLI (tool loop, file editing, bash, git - unchanged)
+-- API calls -> DeepSeek V4 Pro ($0.87/M) instead of Anthropic ($15/M)
一切都能工作:文件读取、编辑、bash 执行、子 agent 生成、自主多步编码循环。唯一的区别是哪个模型在思考。
在 platform.deepseek.com 注册,添加 $5 额度,复制你的 API 密钥。
Windows (PowerShell):
setx DEEPSEEK_API_KEY "sk-your-key-here"
macOS/Linux:
echo 'export DEEPSEEK_API_KEY="sk-your-key-here"' >> ~/.bashrc
source ~/.bashrc
Windows:
# Copy the script to a directory in your PATH
Copy-Item deepclaude.ps1 "$env:USERPROFILE\.local\bin\deepclaude.ps1"
# Or add the repo directory to PATH
setx PATH "$env:PATH;C:\path\to\deepclaude"
macOS/Linux:
chmod +x deepclaude.sh
sudo ln -s "$(pwd)/deepclaude.sh" /usr/local/bin/deepclaude
deepclaude # Launch Claude Code with DeepSeek V4 Pro
deepclaude --status # Show available backends and keys
deepclaude --backend or # Use OpenRouter (cheapest, $0.44/M input)
deepclaude --backend fw # Use Fireworks AI (fastest, US servers)
deepclaude --backend anthropic # Normal Claude Code (when you need Opus)
deepclaude --cost # Show pricing comparison
deepclaude --benchmark # Latency test across all providers
deepclaude --switch ds # Switch backend mid-session (no restart)
Claude Code 读取这些环境变量来确定向哪里发送 API 调用:
deepclaude 按会话设置这些变量(不是永久设置),启动 Claude Code,然后在退出时恢复你的原始设置。
setx DEEPSEEK_API_KEY "sk-..." # Windows
export DEEPSEEK_API_KEY="sk-..." # macOS/Linux
setx OPENROUTER_API_KEY "sk-or-..." # Windows
export OPENROUTER_API_KEY="sk-or-..." # macOS/Linux
setx FIREWORKS_API_KEY "fw_..." # Windows
export FIREWORKS_API_KEY="fw_..." # macOS/Linux
DeepSeek 的自动上下文缓存使 agent 循环成本极低 - 首次请求后,系统提示和文件上下文以 $0.004/M 缓存(相对于未缓存的 $0.44/M)。
文件读取、写入、编辑(Read/Write/Edit 工具)
Bash/PowerShell 执行
多步自主工具循环
项目初始化(/init)
思考模式(默认启用)
智能差异
日常任务(80% 的工作):DeepSeek V4 Pro 与 Claude Opus 相当
复杂推理(20%):Claude Opus 更强 - 用 --backend anthropic 切换
在会话中实时在 Anthropic 和 DeepSeek 之间切换 - 从 Claude Code 内部直接操作。无需重启,无需终端命令。只需输入斜杠命令。
在 Claude Code 终端中:
/deepseek
/anthropic
/openrouter
在 Claude Code VS Code 扩展中:
代理运行在 localhost:3200 并拦截所有 API 调用。控制端点(/_proxy/mode)让你瞬间切换活跃后端:
Claude Code -> localhost:3200 (proxy)
|
+-- /_proxy/mode POST -> switch backend
+-- /_proxy/status GET -> current backend + uptime
+-- /_proxy/cost GET -> token usage + cost savings
|
+-- /v1/messages -> active backend (DeepSeek/OpenRouter/Anthropic)
+-- everything else -> Anthropic (passthrough)
将这些文件添加到 ~/.claude/commands/:
deepseek.json:
Switch the model proxy to DeepSeek. Run this command silently and report the result:
curl -sX POST http://127.0.0.1:3200/_proxy/mode -d "backend=deepseek"
If successful, say: "Switched to DeepSeek."
anthropic.json:
Switch the model proxy back to Anthropic. Run this command silently and report the result:
curl -sX POST http://127.0.0.1:3200/_proxy/mode -d "backend=anthropic"
If successful, say: "Switched to Anthropic."
openrouter.json:
Switch the model proxy to OpenRouter. Run this command silently and report the result:
curl -sX POST http://127.0.0.1:3200/_proxy/mode -d "backend=openrouter"
If successful, say: "Switched to OpenRouter."
然后在任何 Claude Code 会话中输入 /deepseek、/anthropic 或 /openrouter 可以瞬间切换。
deepclaude --switch deepseek # or: ds, or, fw, anthropic
deepclaude -s anthropic
添加到 .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Proxy: Switch to DeepSeek",
"type": "shell",
"command": "Invoke-RestMethod -Uri http://127.0.0.1:3200/_proxy/mode -Method Post -Body 'backend=deepseek'",
"presentation": { "reveal": "always" },
"problemMatcher": []
},
{
"label": "Proxy: Switch to Anthropic",
"type": "shell",
"command": "Invoke-RestMethod -Uri http://127.0.0.1:3200/_proxy/mode -Method Post -Body 'backend=anthropic'",
"presentation": { "reveal": "always" },
"problemMatcher": []
}
]
}
然后在 keybindings.json 中绑定:
{ "key": "ctrl+alt+d", "command": "workbench.action.tasks.runTask", "args": "Proxy: Switch to DeepSeek" },
{ "key": "ctrl+alt+a", "command": "workbench.action.tasks.runTask", "args": "Proxy: Switch to Anthropic" }
代理追踪 token 使用情况,并计算相对于 Anthropic 定价的节省:
curl -s http://127.0.0.1:3200/_proxy/cost
{
"backends": {
"deepseek": {
"input_tokens": 125000,
"output_tokens": 45000,
"requests": 12,
"cost": 0.0941,
"anthropic_equivalent": 1.05
}
},
"total_cost": 0.0941,
"anthropic_equivalent": 1.05,
"savings": 0.9559
}
添加终端配置文件以便你可以从 IDE 启动 deepclaude:
Windows:
{
"terminal.integrated.profiles.windows": {
"DeepSeek Agent": {
"path": "powershell.exe",
"args": ["-ExecutionPolicy", "Bypass", "-NoExit", "-File", "C:\\path\\to\\deepclaude.ps1"]
}
}
}
macOS/Linux:
{
"terminal.integrated.profiles.linux": {
"DeepSeek Agent": {
"path": "/usr/local/bin/deepclaude"
}
}
}
在任何浏览器中打开 Claude Code 会话 - 用 DeepSeek 作为大脑:
deepclaude --remote # Remote control + DeepSeek
deepclaude --remote -b or # Remote control + OpenRouter
deepclaude --remote -b anthropic # Remote control + Anthropic (normal)
这会打印一个 https://claude.ai/code/session_... URL,你可以在你的手机、平板或任何浏览器上打开。
远程控制需要 Anthropic 的网桥来进行 WebSocket 连接,但模型调用可以走其他地方。deepclaude 启动一个本地代理来分流流量:
claude remote-control
+-- Bridge WebSocket -> wss://bridge.claudeusercontent.com (Anthropic, hardcoded)
+-- Model API calls -> http://localhost:3200 (proxy)
+-- /v1/messages -> DeepSeek ($0.87/M)
+-- everything else -> Anthropic (passthrough)
必须登录 Claude Code:claude auth login
必须有 claude.ai 订阅(网桥是 Anthropic 基础设施)
Node.js 18+(用于代理)
代理会自动启动,会话结束时停止。详见 proxy/README.md 获取技术细节。