Claude Code中英文系列教程:plan模式

Use Plan Mode for safe code analysis

使用计划模式进行安全的代码分析

Plan Mode instructs Claude to create a plan by analyzing the codebase with read-only operations, perfect for exploring codebases, planning complex changes, or reviewing code safely.

In Plan Mode, Claude uses AskUserQuestion to gather requirements and clarify your goals before proposing a plan.

计划模式指示 Claude 通过只读操作分析代码库来创建计划,非常适合探索代码库、规划复杂变更或安全地审查代码。

在计划模式下,Claude 先使用 AskUserQuestion 工具来收集需求并澄清您的目标,然后再提出计划。

一,When to use Plan Mode

何时使用计划模式

Multi-step implementation: When your feature requires making edits to many files

多步实现:当您的功能需要修改多个文件时

Code exploration: When you want to research the codebase thoroughly before changing anything

代码探索:在更改任何内容之前,您想要彻底研究代码库

Interactive development: When you want to iterate on the direction with Claude

交互式开发:当你想与 Claude 一起迭代开发时

二,How to use Plan Mode

如何使用计划模式

1,Turn on Plan Mode during a session

在会话期间开启计划模式

You can switch into Plan Mode during a session using Shift+Tab to cycle through permission modes.

可以使用 Shift+Tab 在会话期间切换到计划模式,并循环浏览各种模式。

If you are in Normal Mode, Shift+Tab first switches into Auto-Accept Mode, indicated by ⏵⏵accept edits on at the bottom of the terminal.

A subsequent Shift+Tab will switch into Plan Mode, indicated by ⏸ plan mode on.

如果你处于普通模式,Shift+Tab 首先会切换到自动接受模式,终端底部会显示 ⏵⏵ accept edits on 。

随后的 Shift+Tab 会切换到计划模式,显示 ⏸ plan mode on 。

记住这个快捷键。

2,Start a new session in Plan Mode

在计划模式下启动新会话

To start a new session in Plan Mode, use the --permission-mode plan flag:

要在计划模式下启动新会话,使用 --permission-mode plan 标志:

claude --permission-mode plan

3,Run "headless" queries in Plan Mode

在计划模式下运行"无头"查询

You can also run a query in Plan Mode directly with -p (that is, in "headless mode"):

您也可以直接使用 -p 在计划模式下运行查询(即在"无头模式"下):

claude --permission-mode plan -p "Analyze the authentication system and suggest improvements"

分析认证系统并提出改进建议

现在用一个示例来演示下:

三,示例:Planning a complex refactor

规划一个复杂的重构

claude --permission-mode plan

> I need to refactor our authentication system to use OAuth2. Create a detailed migration plan.

我需要使用OAuth2重构身份验证系统。请创建一份详细的迁移计划。

Claude analyzes the current implementation and create a comprehensive plan. Refine with follow-ups:

Claude 分析当前实现并创建一个全面的计划。通过后续跟进进行细化:

> What about backward compatibility? //向后兼容性怎么样?

> How should we handle database migration? //应该如何处理数据库迁移?

四,Configure Plan Mode as default

将计划模式设为默认

// .claude/settings.json

{

"permissions": {

"defaultMode": "plan"

}

}

相关推荐
yangminlei2 小时前
使用 Cursor 快速创建一个springboot项目
spring boot·ai编程
冬奇Lab2 小时前
团队宪法:CLAUDE.md 和rule使用技巧与复利模式
人工智能·ai编程
Java后端的Ai之路4 小时前
【AI编程工具】-Skills和Rule傻傻分不清?(一文带你读懂)
ai编程·trae·rule·skills
星辰引路-Lefan4 小时前
Antigravity 登录问题及解决方案:Antigravity Tools 账号管理工具详解
ide·ai编程·gemini·antigravity
HyperAI超神经6 小时前
覆盖天体物理/地球科学/流变学/声学等19种场景,Polymathic AI构建1.3B模型实现精确连续介质仿真
人工智能·深度学习·学习·算法·机器学习·ai编程·vllm
猫头虎8 小时前
2026全网最热Claude Skills工具箱,GitHub上最受欢迎的7大Skills开源AI技能库
langchain·开源·prompt·github·aigc·ai编程·agi
Sammyyyyy9 小时前
Claude, Cursor, Aider, Copilot,AI编程助手该选哪个?
copilot·ai编程·开发工具·servbay
IT·小灰灰9 小时前
基于DMXAPI与GLM-4.7-Flash构建零成本AI编程工作站:从API选型到流式生成实战
人工智能·aigc·ai编程
这是个栗子10 小时前
AI辅助编程工具(三) - Github Copilot
ai·编程·ai编程·github copilot
攻城狮7号21 小时前
Kimi 发布并开源 K2.5 模型:开始在逻辑和干活上卷你了
人工智能·ai编程·视觉理解·kimi code·kimi k2.5·agent 集群