开源 AI 编程 CLI 排行榜:本地开发者的终极选择指南
基于 Reddit r/LocalLLaMA 真实用户反馈与 Terminal Bench 基准测试,为你梳理最适合本地开发的开源 CLI 编码 Agent。
引言
在 AI 编程工具爆炸的时代,Claude Code、GitHub Copilot、Cursor 等云端产品占据主流。但对于追求隐私、成本控制、或拥有本地 GPU 的开发者来说,本地 CLI Agent才是真正的答案。
Reddit 用户exaknight21的一个问题引发了热议:
“I am trying to set up Claude Code to work with llama.cpp, using Qwen3.6-35B-A3B. For the life of me I cannot figure out how to get it to work.”
80 条评论后,答案清晰了:OpenCode、pi.dev、NanoCoder、Qwen Code—— 这些才是本地开发者的真正选择。
排行榜:开源 CLI 编程 Agent
| 排名 | 名称 | Reddit 推荐票数 | 核心优势 | GitHub |
|---|---|---|---|---|
| 🥇#1 | OpenCode | ↑57 | 开箱即用、内置本地模型支持 | opencode.ai |
| 🥈#2 | pi.dev | ↑28 | 最小 system prompt、高度可定制 | pi.dev |
| 🥉#3 | NanoCoder | ↑8 | 专为本地模型设计 | github.com/Nano-Collective/nanocoder |
| #4 | Qwen Code | ↑8 | Gemini CLI fork、Qwen 优化 | - |
| #5 | Crush (Charm) | ↑3 | Charmbracelet出品、平衡设计 | github.com/charmbracelet/crush |
| #6 | Mistral Vibe | ↑3 | 8K prompt、简单易用 | - |
| #7 | Cline | 多人推荐 | VSCode 扩展、本地友好 | - |
深度分析:Top 3 方案
🥇 OpenCode:本地开发者的首选
为什么排名第一?
“OpenCode has nice built-in defaults that will let you use a local model. I use llama.cpp to run the model locally, then fire up OpenCode and use
localin the /model selector. Don’t even have to edit a config file.” — u/tulsadune (↑57)
核心特性:
- ✅零配置本地模型:
/model选择器直接选local - ✅多 Agent 支持:可配置规划 Agent + 构建 Agent 分工协作
- ✅模型切换灵活:Claude Pro 规划 + 本地模型构建
- ✅社区活跃:持续更新、Bug 修复快
实测体验:
“I use Qwen3.6 with OpenCode and it’s replaced Claude Code with Sonnet for me. Sure it’s not as fast, but the code it generates has worked out well.” — u/ripter (↑3)
注意事项:
“OpenCode had a historically weird compaction/pruning strategy which fucked up cached reads. This got generalized to ‘uses more tokens’.” — u/lloyd08 (↑1)
🥈 pi.dev:极简主义者的利器
定位:OpenClaw 的底层 harness,追求最小化
核心优势:
- 🎯最小 System Prompt(约 2K):比 OpenCode(10K)、Qwen CLI(14K)节省大量 token
- 🎯高度可定制:可以自己写扩展、MCP 工具
- 🎯开源透明:代码库简洁,便于学习和贡献
用户评价:
“I like the design of pi (coding harness behind OpenClaw) but it’s much less plug and play.” — u/rorykoehler (↑28)
“When you realize Pi can make its own extensions I feel it’s more plug and play. Less opinionated in a weird way.” — u/ZubZero (↑4)
适用人群:
- 喜欢折腾、追求极致性能的开发者
- 需要深度定制 Agent 行为的高级用户
- 想要学习 Agent harness 架构的学习者
🥉 NanoCoder:本地模型的最佳搭档
定位:专为本地模型设计,支持 Qwen 系列
核心特性:
- ✅ 内置 Qwen3.6-27B 支持
- ✅ 优化本地推理性能
- ✅ 简单安装流程
用户反馈:
“NanoCoder is built with your use case in mind. I’ve been using it with Qwen3.6-27B, it’s pretty usable.” — u/DenizOkcu (↑8) / u/Steve_Streza (↑1)
Token 消耗对比:谁最省钱?
| Harness | System Prompt 大小 | Token 效率 |
|---|---|---|
| pi.dev | ~2K | ⭐⭐⭐⭐⭐ 最优 |
| Mistral Vibe | 8K | ⭐⭐⭐⭐ |
| OpenCode | 10K | ⭐⭐⭐ |
| Qwen CLI | 14K | ⭐⭐ |
| Zed | - | ⭐ “way way worse” |
关键洞察:
“Anthropic did their ‘no 3rd party harnesses w/ claude pro’ policy a year ago, even though their own system prompt is double OpenCode’s. The boogeyman will stick around.” — u/lloyd08
结论:如果你用本地模型且预算有限,pi.dev 是最省 token 的选择。
Terminal Bench:基准测试真相
Terminal Bench 是一个专门测试 Agent harness 的基准平台,分离测试 harness 和模型,让你能看到真正的 harness 影响。
震撼结果:
“Claude Code is inlast place, 10th out of 10, with Claude Opus 4.6! Make of that what you will (and probably choose a higher performing harness).” — u/robogame_dev (↑7)
解读:
- Claude Code 虽然 Anthropic 官方出品,但 harness 设计并非最优
- 模型再强,harness 设计差也会拖累整体表现
- 选择排名靠前的 harness + 强模型 = 最佳组合
Claude Code 本地模型配置指南
如果你坚持要用 Claude Code 配本地模型,Reddit 用户给出了详细教程:
方法一:Ollama
# 确保 Ollama v0.14.0+ollama pull qwen2.5-coder:32b# 设置环境变量exportANTHROPIC_AUTH_TOKEN=***exportANTHROPIC_BASE_URL=http://localhost:11434# 运行 Claude Codeclaude方法二:llama.cpp
# llama-server 已暴露兼容 APIexportANTHROPIC_AUTH_TOKEN=***exportANTHROPIC_BASE_URL=http://localhost:8080# 关键优化:禁用 attribution header(提升 90% 速度)# ~/.claude/settings.json:{"env":{"CLAUDE_CODE_ATTRIBUTION_HEADER":"0"}}Ollama 性能调优(Apple Silicon)
# ~/.zshrc 或 ~/.bash_profileexportOLLAMA_CONTEXT_LENGTH=65536# 64K contextexportOLLAMA_FLASH_ATTENTION=1# faster attentionexportOLLAMA_KV_CACHE_TYPE=f16# M1/M2 推荐 f16,M3/M4 可尝试 bf16多 Agent 架构:规划 + 构建
Reddit 用户分享了一个高效的多 Agent 配置方案:
“You can specify multiple agents for different purposes. You need at least two: one for planning and one for building. I use my Claude Pro subscription for planning. Over the weekend I configured qwen.2.5-coder.32B on my gaming rig with RTX4090 using llama.cpp on WSL. It’s running as my build agent. I’m getting 30 tokens a second.” — u/Curious-Function7490 (↑4)
架构图:
┌─────────────────────┐ ┌─────────────────────┐ │ Planning Agent │ │ Building Agent │ │ (Claude Pro/云端) │ ──▶ │ (本地 GPU/Qwen) │ │ 高质量规划决策 │ │ 快速代码生成 │ └─────────────────────┘ └─────────────────────┘优势:
- 规划阶段用强模型(Claude),确保方向正确
- 构建阶段用本地模型,节省成本、保护隐私
- 兼顾质量与成本
硬件要求:本地 Agent 的硬门槛
重要警告:
“Unless you’re loading that model 100% into VRAM, you won’t be able to do anything with it. As soon as you try to code, have it analyze a codebase, it will fail. Harnesses start to timeout waiting for API responses.” — u/OneSlash137 (↑-7,但观点被多位用户验证)
关键因素:
| 硬件配置 | 能否运行 Agent |
|---|---|
| 全 VRAM 加载 | ✅ 可稳定运行 |
| 部分 VRAM + CPU offload | ❌ 会超时失败 |
| 纯 CPU | ❌ 完全不可用 |
原因分析:
Agent 任务的 system prompt 通常 40K+,加上文件上下文,首请求巨大。如果专家层被 offload 到 CPU,token 处理速度会掉到无法接受,导致 timeout。
最佳实践总结
1. 选择建议
| 场景 | 推荐方案 |
|---|---|
| 新手入门 | OpenCode +localselector |
| 极致性能 | pi.dev + 最小 prompt |
| 本地 Qwen | NanoCoder 或 Qwen Code |
| VSCode 用户 | Cline 扩展 |
| 多 Agent 协作 | OpenCode 多 Agent 配置 |
2. 本地模型推荐
| 模型 | 参数量 | 适用场景 |
|---|---|---|
| Qwen3.6-35B-A3B | 35B MoE | 复杂编码任务 |
| Qwen3.6-27B-UD | 27B | 平衡性能与速度 |
| Qwen2.5-Coder-32B | 32B | 经典选择,社区验证多 |
3. 省钱策略
- 用pi.dev最省 token
- 规划用云端、构建用本地
- 禁用 Claude Code attribution header
CLI vs IDE:为什么有人偏好 CLI?
Reddit 用户给出了清晰的解释:
“It’s a different way of using the LLM. IDE is more like writing it yourself with LLM help. CLI is more like telling another engineer the requirements and reviewing their code.” — u/ripter
CLI 适用人群:
- 终端重度用户
- SSH/tmux 远程开发
- 不喜欢 IDE bloat 的开发者
- 需要跨平台统一体验
结论
开源 CLI Agent 的世界正在快速进化:
- OpenCode—— 本地开发者的首选,开箱即用
- pi.dev—— 极简主义者的利器,最小 prompt
- NanoCoder/Qwen Code—— Qwen 模型的最佳搭档
关键教训:
Claude Code 在 Terminal Bench 排名第 10(最后一名),即使模型是 Opus 4.6。模型再强,harness 设计差也会拖累整体。
选择正确的 harness + 合适的本地模型,你可以在保护隐私、控制成本的同时,获得媲美云端的编码体验。
附录:资源链接
| 资源 | 链接 |
|---|---|
| Terminal Bench 基准测试 | https://www.tbench.ai/leaderboard/terminal-bench/2.0 |
| OpenCode 官网 | https://opencode.ai |
| NanoCoder GitHub | https://github.com/Nano-Collective/nanocoder |
| Crush (Charm) | https://github.com/charmbracelet/crush |
| Reddit 原帖 | https://www.reddit.com/r/LocalLLaMA/comments/1swhw84/ |
数据来源:Reddit r/LocalLLaMA 社区、Terminal Bench、2026-04-27