Skip to content

使用教程

第一次使用 Cline 时,建议从只读任务开始,让它理解项目结构,不要一上来授权大范围修改。

只读分析

text
Read the current project structure and tell me:
1. What technology stack does this project use?
2. What are the start and build commands?
3. What are the main directories responsible for?
Do not modify any files

这类任务适合新项目、陌生仓库、接手旧代码时使用。

定位报错

把终端报错贴给 Cline:

text
This is a terminal error. Analyze likely causes first and list the files you need to inspect.
Do not modify code before I confirm.

这样可以先控制它的动作范围,避免它直接改一堆不相关文件。

小范围修复

text
Fix the issue where the login page button does not respond to clicks.
Requirements:
1. First explain which files you will inspect
2. Tell me the exact changes before editing
3. Run existing tests or build commands after editing

如果项目很大,建议明确目录:

text
Only inspect files related to web/src/pages/Login and web/src/api/auth.

代码审查

如果你已经有一批改动,可以让 Cline 审查:

text
Review the current git diff and list risks, missing tests, and possible regressions by severity.
Do not modify files.

如果使用 CLI:

bash
git diff | cline "Review these changes and list risks, missing tests, and possible regressions by severity"

生成提交信息

bash
git diff | cline "Write a concise commit message for these changes"

推荐工作流

  1. 先打开一个干净的 Git 分支。
  2. 让 Cline 使用 Plan 模式分析项目和方案。
  3. 确认方案后再进入 Act 模式修改。
  4. 每次只给一个明确任务,不要把多个大需求塞进同一轮。
  5. 审查 Cline 提出的文件改动和终端命令。
  6. 修改完成后运行测试、构建或手动验证。
  7. git diff 复查最终改动。

适合给 Cline 的任务应该具体,例如“修复这个构建错误”比“优化整个项目”更容易得到稳定结果。

权限与安全

Cline 可以读文件、改文件、运行命令,所以要把它当成一个有操作能力的开发助手。

  • 不要把 Xikapi API Key 写进项目仓库。
  • 不要授权它运行你不理解的命令。
  • 不要在生产服务器上直接开启自动批准。
  • CLI 直接任务或 CI 任务执行前先运行 cline --help,确认 --auto-approve-y 等参数的实际含义。
  • 不要让它执行删除、重置、部署、数据库迁移等高风险命令,除非你已经确认影响范围。
  • 新项目先关闭或谨慎使用 Auto Approve。
  • 涉及密钥、支付、用户数据、后台权限时,先让它做只读分析。

下一步

遇到连接或模型问题时查看 常见命令与报错处理