MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getPlanModeV2Instructions

Function getPlanModeV2Instructions

src/utils/messages.ts:3207–3297  ·  view source on GitHub ↗
(attachment: {
  isSubAgent?: boolean
  planFilePath?: string
  planExists?: boolean
})

Source from the content-addressed store, hash-verified

3205}
3206
3207function getPlanModeV2Instructions(attachment: {
3208 isSubAgent?: boolean
3209 planFilePath?: string
3210 planExists?: boolean
3211}): UserMessage[] {
3212 if (attachment.isSubAgent) {
3213 return []
3214 }
3215
3216 // When interview phase is enabled, use the iterative workflow.
3217 if (isPlanModeInterviewPhaseEnabled()) {
3218 return getPlanModeInterviewInstructions(attachment)
3219 }
3220
3221 const agentCount = getPlanModeV2AgentCount()
3222 const exploreAgentCount = getPlanModeV2ExploreAgentCount()
3223 const planFileInfo = attachment.planExists
3224 ? `A plan file already exists at ${attachment.planFilePath}. You can read it and make incremental edits using the ${FileEditTool.name} tool.`
3225 : `No plan file exists yet. You should create your plan at ${attachment.planFilePath} using the ${FileWriteTool.name} tool.`
3226
3227 const content = `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.
3228
3229## Plan File Info:
3230${planFileInfo}
3231You 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.
3232
3233## Plan Workflow
3234
3235### Phase 1: Initial Understanding
3236Goal: 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_AGENT.agentType} subagent type.
3237
32381. 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.
3239
32402. **Launch up to ${exploreAgentCount} ${EXPLORE_AGENT.agentType} agents IN PARALLEL** (single message, multiple tool calls) to efficiently explore the codebase.
3241 - 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.
3242 - Use multiple agents when: the scope is uncertain, multiple areas of the codebase are involved, or you need to understand existing patterns before planning.
3243 - Quality over quantity - ${exploreAgentCount} agents maximum, but you should try to use the minimum number of agents necessary (usually just 1)
3244 - 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
3245
3246### Phase 2: Design
3247Goal: Design an implementation approach.
3248
3249Launch ${PLAN_AGENT.agentType} agent(s) to design the implementation based on the user's intent and your exploration results from Phase 1.
3250
3251You can launch up to ${agentCount} agent(s) in parallel.
3252
3253**Guidelines:**
3254- **Default**: Launch at least 1 Plan agent for most tasks - it helps validate your understanding and consider alternatives
3255- **Skip agents**: Only for truly trivial tasks (typo fixes, single-line changes, simple renames)
3256${
3257 agentCount > 1
3258 ? `- **Multiple agents**: Use up to ${agentCount} agents for complex tasks that benefit from different perspectives
3259
3260Examples of when to use multiple agents:
3261- The task touches multiple parts of the codebase
3262- It's a large refactor or architectural change
3263- There are many edge cases to consider
3264- You'd benefit from exploring different approaches

Callers 1

getPlanModeInstructionsFunction · 0.85

Tested by

no test coverage detected