Cline 深度实战:在 IDE 和终端中部署 AI 编码 Agent

从 CLI、VS Code 扩展到 Kanban 多 Agent 看板,系统讲解 Cline 三大部署形态与 MCP 集成实践,打造人机协作的 AI 编码工作流。

AgentList Team · 2026年6月21日
ClineVS CodeCoding AgentAI 编程CLIIDE

Cline 不只是"代码补全"工具,而是一个可以在你的 IDE、终端或本地 Kanban 看板里运行的完整 AI 编码 Agent——它能读懂整个代码库、执行 shell 命令、自动写 PR,全程需要你点头。

三大部署形态

形态 安装命令 适合场景
VS Code 扩展 VS Marketplace 搜 "Cline" 日常开发、inline diff 审阅
JetBrains 插件 JetBrains Marketplace 搜 "Cline" IntelliJ/PyCharm 用户
CLI npm i -g cline CI/CD、脚本化、headless 任务
Kanban npm i -g kanban 多 Agent 并行、依赖链编排

同一个 Cline Agent 在不同形态下行为一致。

VS Code 扩展模式

适合日常开发,UI 嵌入编辑器。

安装

  1. 打开 VS Code → 扩展 → 搜索 "Cline" → 安装
  2. 左侧活动栏出现 Cline 图标,点击打开侧边栏
  3. 设置 API Key(支持 30+ provider)
  4. 选择模型

支持的 Provider

不绑定单一供应商:OpenAI(GPT-4o / GPT-5 系列)、Anthropic Claude(Sonnet / Opus / Haiku)、Google Gemini、DeepSeek、AWS Bedrock、OpenRouter、OpenAI 兼容接口(本地 Ollama / vLLM)、MiniMax、Z.AI、Qwen 等。

上下文层(自动)

Cline 在 VS Code 中自动收集以下上下文,无需手动配置:

  • 当前打开的文件
  • LSP 诊断信息
  • 终端输出
  • 选中的代码片段
  • Git 状态

CLI 模式

npm i -g cline
cline                                 # 交互式
cline --yolo "添加 JWT 验证"           # 一次性,跳过确认
cline --yolo "运行测试"                # CI/CD,完全无人值守

Kanban 多 Agent 看板

Kanban 是 Cline 的"杀手锏"——本地 web 应用,并行运行多个 Agent,每个 Agent 在独立 git worktree 中。

npx kanban
# 或
npm i -g kanban

核心工作流

  1. 创建任务——手动或 sidebar chat 让 Agent 拆任务
  2. 链接任务——⌘+点击 卡片 A 链接到 B,A 完成后 B 自动开始
  3. 启动——点击 play,kanban 创建独立 worktree
  4. 审查——点击卡片查看 diff,checkpoint 系统支持按消息范围回溯
  5. 提交或开 PR——点击 Commit 或 Open PR,Agent 自动处理 merge 冲突
  6. 清理——移到 trash,工作流结束

MCP 工具集成

形态 配置路径
CLI ~/.cline/mcp.json
IDE 扩展 Cline 面板 → MCP Servers → Configure
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "<token>" }
    }
  }
}

支持 STDIO(本地)和 HTTP/SSE(远程,推荐 Streamable HTTP)。

当前工具 API

Cline 运行时工具(SDK/CLI/Kanban,VS Code 扩展已对齐):

工具 作用
bash 执行 shell
editor 查看/编辑文件
read_files 批量读
apply_patch 应用 diff
search ripgrep 搜索
fetch_web HTTP + HTML→markdown
ask_question 向用户提问

⚠️ 老版本 XML 工具名(read_filereplace_in_fileexecute_command)已废弃。

CI/CD 集成

cline --yolo "运行 eslint,修复可自动修复的警告"
cline --yolo "分析本次 commit 列表,更新 CHANGELOG.md"
cline --yolo "审查 PR diff,指出潜在安全问题"

适用场景

  • 日常开发(补全、重构、写新功能)✅
  • 跨文件大规模重构✅ (Kanban 并行)
  • CI/CD 集成✅ (CLI 模式)
  • 纯 UI/设计工作❌

总结

Cline 的差异化在三个层面:多部署形态(同一 Agent 跨 IDE/CLI/Kanban)、模型无关(30+ provider)、人在环路(每步需 Approve)。

官方文档: docs.cline.bot · 仓库: cline/cline · Kanban: cline/kanban