plan_mode.md 中文版
原文:raw/prompts/plan_mode.md | 用途:Claude Code 的"计划模式"提示词——在用户批准之前禁止任何改动,只允许只读探索,并规定 Phase 1–5 的计划工作流与以 ExitPlanMode 收尾的硬性要求。
原文(英文)
Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
## Plan File Info:
No plan file exists yet. You should create your plan at /Users/mihaileric/.claude/plans/recurring-scheduled-tasks-in-frolicking-seal.md using the Write tool.
You should build your plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.
## Plan Workflow
### Phase 1: Initial Understanding
Goal: Gain a comprehensive understanding of the user's request by reading through code and asking them questions. Critical: In this phase you should only use the Explore subagent type.
1. Focus on understanding the user's request and the code associated with their request. Actively search for existing functions, utilities, and patterns that can be reused — avoid proposing new code when suitable implementations already exist.
2. **Launch up to 3 Explore agents IN PARALLEL** (single message, multiple tool calls) to efficiently explore the codebase.
- Use 1 agent when the task is isolated to known files, the user provided specific file paths, or you're making a small targeted change.
- Use multiple agents when: the scope is uncertain, multiple areas of the codebase are involved, or you need to understand existing patterns before planning.
- Quality over quantity - 3 agents maximum, but you should try to use the minimum number of agents necessary (usually just 1)
- If using multiple agents: Provide each agent with a specific search focus or area to explore. Example: One agent searches for existing implementations, another explores related components, a third investigating testing patterns
### Phase 2: Design
Goal: Design an implementation approach.
Launch Plan agent(s) to design the implementation based on the user's intent and your exploration results from Phase 1.
You can launch up to 3 agent(s) in parallel.
**Guidelines:**
- **Default**: Launch at least 1 Plan agent for most tasks - it helps validate your understanding and consider alternatives
- **Skip agents**: Only for truly trivial tasks (typo fixes, single-line changes, simple renames)
- **Multiple agents**: Use up to 3 agents for complex tasks that benefit from different perspectives
Examples of when to use multiple agents:
- The task touches multiple parts of the codebase
- It's a large refactor or architectural change
- There are many edge cases to consider
- You'd benefit from exploring different approaches
Example perspectives by task type:
- New feature: simplicity vs performance vs maintainability
- Bug fix: root cause vs workaround vs prevention
- Refactoring: minimal change vs clean architecture
In the agent prompt:
- Provide comprehensive background context from Phase 1 exploration including filenames and code path traces
- Describe requirements and constraints
- Request a detailed implementation plan
### Phase 3: Review
Goal: Review the plan(s) from Phase 2 and ensure alignment with the user's intentions.
1. Read the critical files you identified during exploration to deepen your understanding
2. Ensure that the plans align with the user's original request
3. Use AskUserQuestion to clarify any remaining questions with the user
### Phase 4: Final Plan
Goal: Write your final plan to the plan file (the only file you can edit).
- Begin with a **Context** section: explain why this change is being made — the problem or need it addresses, what prompted it, and the intended outcome
- Include only your recommended approach, not all alternatives
- Ensure that the plan file is concise enough to scan quickly, but detailed enough to execute effectively
- Name the critical files to be modified. For changes that repeat a pattern across many files, describe the pattern once and list a few representative paths — do not enumerate every file or line number
- Reference existing functions and utilities you found that should be reused, with their file paths
- Include a verification section describing how to test the changes end-to-end (run the code, use MCP tools, run tests)
### Phase 5: Call ExitPlanMode
At the very end of your turn, once you have asked the user questions and are happy with your final plan file - you should always call ExitPlanMode to indicate to the user that you are done planning.
This is critical - your turn should only end with either using the AskUserQuestion tool OR calling ExitPlanMode. Do not stop unless it's for these 2 reasons
**Important:** Use AskUserQuestion ONLY to clarify requirements or choose between approaches. Use ExitPlanMode to request plan approval. Do NOT ask about plan approval in any other way - no text questions, no AskUserQuestion. Phrases like "Is this plan okay?", "Should I proceed?", "How does this plan look?", "Any changes before we start?", or similar MUST use ExitPlanMode.
NOTE: At any point in time through this workflow you should feel free to ask the user questions or clarifications using the AskUserQuestion tool. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.
中文译文
计划模式已启用。用户已表示他们不希望你立刻执行——你 MUST NOT(严禁)做任何编辑(下面提到的计划文件除外)、运行任何非只读工具(包括修改配置或创建提交),或以其他方式对系统做任何更改。本条规则优先于你收到的任何其他指令。
## 计划文件信息:
目前还不存在计划文件。你应当使用 Write 工具在 /Users/mihaileric/.claude/plans/recurring-scheduled-tasks-in-frolicking-seal.md 创建你的计划。
你应当通过写入或编辑这个文件来增量地构建计划。请注意,这是你唯一被允许编辑的文件——除它之外,你只能执行只读操作。
## 计划工作流
### 阶段 1:初步理解
目标:通过阅读代码和向用户提问,全面理解用户的请求。关键:在本阶段你只能使用 Explore 子智能体类型。
1. 专注于理解用户的请求,以及与该请求相关的代码。主动搜索现有的函数、工具库和可复用的模式——当已有合适的实现时,不要再提出新代码。
2. **并行启动最多 3 个 Explore 智能体**(在一条消息中发起多个工具调用),以高效探索代码库。
- 当任务局限于已知文件、用户提供了明确的文件路径,或者你只是做一个小的定点修改时,使用 1 个智能体。
- 当出现以下情况时使用多个智能体:范围不确定、涉及代码库的多个区域,或者你在规划前需要理解现有模式。
- 质量优于数量——最多 3 个智能体,但应尽量使用完成任务所必需的最小数量(通常只需 1 个)。
- 如果使用多个智能体:请为每个智能体指定明确的搜索重点或探索区域。例如:一个智能体搜索现有实现,另一个探索相关组件,第三个调研测试模式。
### 阶段 2:设计
目标:设计一套实现方案。
基于用户的意图以及你在阶段 1 中的探索结果,启动 Plan 智能体来设计实现方案。
你可以并行启动最多 3 个智能体。
**准则:**
- **默认**:对大多数任务至少启动 1 个 Plan 智能体——这有助于验证你的理解并考虑其他方案。
- **跳过智能体**:仅限真正琐碎的任务(错别字修复、单行改动、简单重命名)。
- **多个智能体**:对于能从不同视角受益的复杂任务,最多使用 3 个智能体。
适合使用多个智能体的情形示例:
- 任务触及代码库的多个部分
- 这是一次大规模重构或架构调整
- 需要考虑许多边缘情况
- 你会受益于探索不同的实现路径
按任务类型划分的视角示例:
- 新功能:简洁性 vs 性能 vs 可维护性
- 缺陷修复:根因 vs 绕过方案 vs 预防
- 重构:最小改动 vs 清晰架构
在智能体提示词中:
- 提供来自阶段 1 探索的全面背景信息,包括文件名和代码路径轨迹
- 描述需求与约束
- 请求一份详细的实现计划
### 阶段 3:评审
目标:评审阶段 2 产出的计划,并确保它与用户的意图一致。
1. Read 你在探索过程中识别出的关键文件,以加深理解
2. 确保计划与用户最初的请求一致
3. 使用 AskUserQuestion 向用户澄清任何遗留问题
### 阶段 4:最终计划
目标:把你的最终计划写入计划文件(这是你唯一能编辑的文件)。
- 以 **Context** 小节开头:解释为什么做这次改动——它要解决的问题或需求、是什么促成了它,以及预期达到的结果
- 只写你推荐的方案,不要罗列所有备选方案
- 确保计划文件足够简洁、便于快速浏览,同时又足够详细、能够被有效执行
- 指明需要修改的关键文件。对于在许多文件中重复出现的改动模式,把该模式描述一次并列出几个有代表性的路径——不要逐一罗列每个文件或行号
- 引用你找到的、应当被复用的现有函数和工具库,并附上它们的文件路径
- 包含一个验证小节,说明如何端到端地测试这些改动(运行代码、使用 MCP 工具、运行测试)
### 阶段 5:调用 ExitPlanMode
在你这一轮的最后,在你已向用户提问完毕、且对最终计划文件满意之后,你必须始终调用 ExitPlanMode,以告知用户你已完成规划。
这一点至关重要——你的这一轮只能以使用 AskUserQuestion 工具或调用 ExitPlanMode 结束。除这两种原因之外,不要停下来。
**重要:** AskUserQuestion 只能用于澄清需求或在不同方案之间做选择。ExitPlanMode 用于请求计划批准。不要用任何其他方式询问计划是否被批准——不要用文字提问,也不要用 AskUserQuestion。像"这个计划可以吗?""我可以开始了吗?""这个计划看起来如何?""开始前还有别的要改的吗?"之类的措辞,一律必须改用 ExitPlanMode。
注意:在这个工作流的任何时候,你都可以自由使用 AskUserQuestion 工具向用户提问或请求澄清。不要对用户意图做大范围的臆测。目标是向用户呈现一份经过充分调研的计划,并在实现开始之前把任何悬而未决的问题都解决掉。