4.5 Plan Mode 深度指南

先想清楚,再动手
Plan Mode 是 Claude Code 里最容易被忽视的功能之一——很多人装了很久都不知道它的存在。
但一旦你用过,你会发现它对复杂任务来说几乎是必须的。
Plan Mode 是什么
Plan Mode 下,Claude Code 进入只读状态:
- ✅ 可以读取文件、搜索代码、分析结构
- ✅ 可以回答问题、提出建议、制定计划
- ❌ 不能修改任何文件
- ❌ 不能运行任何命令
你可以把它理解为"先开会讨论方案,再开始施工"。
三种开启方式
方式一:启动时进入
claude --permission-mode plan方式二:会话中切换
在会话里按 Shift+Tab,会在三种模式之间循环:
普通模式 → 自动接受模式 → Plan Mode → 普通模式底部状态栏会显示当前模式:
- 普通模式:无特殊标识
- 自动接受:
⏵⏵ accept edits on - Plan Mode:
⏸ plan mode on
方式三:设为默认
在 .claude/settings.json 里设置:
{
"permissions": {
"defaultMode": "plan"
}
}适合谨慎的场景,比如在生产代码库里工作,每次任务都先强制规划。
Plan Mode 的三个核心使用场景
场景一:复杂任务前规划
任何需要改动 3 个以上文件的任务,都建议先进 Plan Mode:
I need to add rate limiting to all API endpoints.
analyze the current routing structure and create a plan:
- which files need to change?
- where should the rate limiting middleware be added?
- how should different endpoints have different limits?
- what's the safest order to make these changes?拿到计划之后,你来决定是否认可,再切回普通模式执行。
场景二:探索陌生代码库
Plan Mode 是安全的探索模式——它只读不写,特别适合刚接手项目的时候:
explore the entire codebase. understand the architecture,
find the key modules, and identify any potential issues.
don't make any changes — just report what you find.用 Plan Mode 探索,不用担心它"手滑"改了什么。
场景三:代码审查(不改动,只分析)
review the recent changes in git (last 5 commits).
analyze for: code quality issues, potential bugs, security concerns,
and missing test coverage. give me a detailed report.
do not make any changes.Ctrl+G:在编辑器里编辑计划
这是 Plan Mode 里最强大、也最少人知道的功能。
当 Claude Code 生成了一份计划,你在 Plan Mode 下按 Ctrl+G,这份计划会在你的默认编辑器(VS Code、vim、nano……)里打开,你可以直接编辑它。
你可以做的事:
- 删掉你不认可的步骤
- 修改执行顺序
- 加上额外的约束("这一步不要改 API 接口")
- 注明某个地方要特别小心("这个函数有三个调用方")
编辑完保存,关掉编辑器,Claude Code 会按照你修改后的计划来执行。
这实际上是一种"人机协作规划"——AI 生成草稿,你来审核和修改,然后 AI 执行。比你从零写计划快,比 AI 独自执行可控。
什么时候不该用 Plan Mode
Plan Mode 有价值,但也有开销——它会增加一轮"先分析再执行"的往返。
可以跳过 Plan Mode 的情况:
- 任务很简单,一两个文件的小改动
- 你已经很熟悉这段代码,知道要改什么
- 修 bug 时已经有明确的报错和调用栈
- 添加一行日志、修改一个配置值这类微操作
一个经验规则: 如果你能用一句话描述清楚要改的 diff,就不需要 Plan Mode。如果你需要一段话才能说清楚,Plan Mode 就值得用。
让 Claude Code 帮你判断
如果你不确定要不要用 Plan Mode,可以直接问它:
I want to add OAuth2 support to this app. is this complex enough
to warrant using plan mode first, or can we just do it directly?它会根据任务的复杂度给你建议。
第四章小结
这一章覆盖了日常开发里最常见的五类任务:
| 任务 | 关键点 |
|---|---|
| 探索代码库 | 从宏观到微观,用 @ 聚焦具体文件,最后生成 CLAUDE.md |
| 修复 bug | 给完整上下文(报错+复现步骤+验收标准),改完要 review |
| 代码重构 | 三步走:探索 → 计划(Ctrl+G 编辑)→ 分批执行 |
| 编写测试 | 先找缺口,再生成,再找 edge case,最后审查质量 |
| Plan Mode | 先想清楚再动手,Ctrl+G 让你直接编辑计划 |
下一章,我们来聊怎么把重复的工作打包成命令,一次设置,永久省事。
