MCPcopy
hub / github.com/claude-code-best/claude-code / getPlanModeInterviewInstructions

Function getPlanModeInterviewInstructions

src/utils/messages.ts:3711–3771  ·  view source on GitHub ↗

* Iterative interview-based plan mode workflow. * Instead of forcing Explore/Plan agents, this workflow has the model: * 1. Read files and ask questions iteratively * 2. Build up the spec/plan file incrementally as understanding grows * 3. Use AskUserQuestion throughout to clarify and gather inp

(attachment: {
  planFilePath?: string
  planExists?: boolean
})

Source from the content-addressed store, hash-verified

3709 * 3. Use AskUserQuestion throughout to clarify and gather input
3710 */
3711function getPlanModeInterviewInstructions(attachment: {
3712 planFilePath?: string
3713 planExists?: boolean
3714}): UserMessage[] {
3715 const planFileInfo = attachment.planExists
3716 ? `A plan file already exists at ${attachment.planFilePath}. You MUST use ${FileReadTool.name} to read it first before making any changes. Make incremental edits using the ${FileEditTool.name} tool — do NOT overwrite the entire file unless the user explicitly asks for a complete rewrite.`
3717 : `No plan file exists yet. You should create your plan at ${attachment.planFilePath} using the ${FileWriteTool.name} tool.`
3718
3719 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.
3720
3721## Plan File Info:
3722${planFileInfo}
3723
3724## Iterative Planning Workflow
3725
3726You are pair-planning with the user. Explore the code to build context, ask the user questions when you hit decisions you can't make alone, and write your findings into the plan file as you go. The plan file (above) is the ONLY file you may edit — it starts as a rough skeleton and gradually becomes the final plan.
3727
3728### The Loop
3729
3730Repeat this cycle until the plan is complete:
3731
37321. **Explore** — Use ${getReadOnlyToolNames()} to read code. Look for existing functions, utilities, and patterns to reuse.${areExplorePlanAgentsEnabled() ? ` You can use the ${EXPLORE_AGENT.agentType} agent type to parallelize complex searches without filling your context, though for straightforward queries direct tools are simpler.` : ''}
37332. **Update the plan file** — After each discovery, immediately capture what you learned. Don't wait until the end.
37343. **Ask the user** — When you hit an ambiguity or decision you can't resolve from code alone, use ${ASK_USER_QUESTION_TOOL_NAME}. Then go back to step 1.
3735
3736### First Turn
3737
3738Start by quickly scanning a few key files to form an initial understanding of the task scope. Then write a skeleton plan (headers and rough notes) and ask the user your first round of questions. Don't explore exhaustively before engaging the user.
3739
3740### Asking Good Questions
3741
3742- Never ask what you could find out by reading the code
3743- Batch related questions together (use multi-question ${ASK_USER_QUESTION_TOOL_NAME} calls)
3744- Focus on things only the user can answer: requirements, preferences, tradeoffs, edge case priorities
3745- Scale depth to the task — a vague feature request needs many rounds; a focused bug fix may need one or none
3746
3747### Plan File Structure
3748Your plan file should be divided into clear sections using markdown headers, based on the request. Fill out these sections as you go.
3749- 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
3750- Include only your recommended approach, not all alternatives
3751- Ensure that the plan file is concise enough to scan quickly, but detailed enough to execute effectively
3752- Include the paths of critical files to be modified
3753- Reference existing functions and utilities you found that should be reused, with their file paths
3754- Include a verification section describing how to test the changes end-to-end (run the code, use MCP tools, run tests)
3755
3756### When to Converge
3757
3758Your plan is ready when you've addressed all ambiguities and it covers: what to change, which files to modify, what existing code to reuse (with file paths), and how to verify the changes. Call ${ExitPlanModeV2Tool.name} when the plan is ready for approval.
3759
3760### Ending Your Turn
3761
3762Your turn should only end by either:
3763- Using ${ASK_USER_QUESTION_TOOL_NAME} to gather more information
3764- Calling ${ExitPlanModeV2Tool.name} when the plan is ready for approval
3765
3766**Important:** Use ${ExitPlanModeV2Tool.name} to request plan approval. Do NOT ask about plan approval via text or AskUserQuestion.`
3767
3768 return wrapMessagesInSystemReminder([

Callers 1

Calls 4

getReadOnlyToolNamesFunction · 0.85
createUserMessageFunction · 0.85

Tested by

no test coverage detected