|
| 1 | +# Plan Mode |
| 2 | + |
| 3 | +Plan Mode is a built-in collaboration mode in Deep Code. When Plan Mode is active, the AI assistant works with you to create a detailed implementation plan, but **does not perform any code-modifying actions**. Plan first, implement later—giving every step of a complex task a clear rationale. |
| 4 | + |
| 5 | +## Why Plan Mode |
| 6 | + |
| 7 | +Asking the AI to "just do it" works well for simple tasks, but with complex cross-file refactors, feature development, or architectural changes, common pitfalls include: |
| 8 | + |
| 9 | +- The AI starts editing without a full picture, leading to wrong directions |
| 10 | +- No shared understanding before acting, causing expensive back-and-forth corrections |
| 11 | +- Implementation and planning mixed together, making it hard to trace decisions |
| 12 | + |
| 13 | +Plan Mode separates "thinking" from "doing." First, explore, ask questions, and reach agreement during the planning phase. Then, once the plan is decision-complete, move on to implementation. |
| 14 | + |
| 15 | +## Enabling Plan Mode |
| 16 | + |
| 17 | +You can enter Plan Mode in two ways: |
| 18 | + |
| 19 | +| Method | Action | |
| 20 | +| ------ | ------ | |
| 21 | +| Keyboard shortcut | Press `Shift+Tab` in the input box to toggle between Plan Mode and Default Mode | |
| 22 | +| Slash command | Type `/plan`, or type `/` to open the command menu and select `/plan` | |
| 23 | + |
| 24 | +Once active, a yellow `💡 Plan mode` indicator appears in the top-right corner of the input area. |
| 25 | + |
| 26 | +To leave Plan Mode, toggle again with `Shift+Tab`, or select "switch to Default mode" after reviewing a proposed plan. |
| 27 | + |
| 28 | +## Behavior in Plan Mode |
| 29 | + |
| 30 | +### Three Planning Phases |
| 31 | + |
| 32 | +In Plan Mode, the AI follows a three-phase collaboration workflow: |
| 33 | + |
| 34 | +1. **Ground in the environment (Phase 1)** — Understand the current project state by reading files, searching code, and checking configuration. Resolve unknowns through exploration before asking questions. |
| 35 | +2. **Intent chat (Phase 2)** — Ask about goals and preferences to clarify success criteria, scope boundaries, constraints, and key tradeoffs. |
| 36 | +3. **Implementation chat (Phase 3)** — Once intent is stable, discuss the concrete implementation approach: API design, data flow, edge cases, testing strategy, and so on, until the spec is "decision complete." |
| 37 | + |
| 38 | +In each phase, the AI interacts with you through the `AskUserQuestion` tool, offering concrete options to choose from. |
| 39 | + |
| 40 | +### Strict Rules: No Mutations |
| 41 | + |
| 42 | +Plan Mode's core rule: **plan only, don't touch code**. The following actions are **allowed**: |
| 43 | + |
| 44 | +- Reading and searching files, configs, type definitions, and docs |
| 45 | +- Static analysis and code exploration |
| 46 | +- Running dry-run commands that don't modify repo-tracked files |
| 47 | +- Running tests or builds that may write to caches or build artifacts (e.g. `target/`, `.cache/`) without altering tracked files |
| 48 | + |
| 49 | +The following actions are **not allowed**: |
| 50 | + |
| 51 | +- Editing or writing files |
| 52 | +- Running formatters or linters that rewrite files |
| 53 | +- Applying patches, migrations, or code generation |
| 54 | +- Side-effectful commands whose purpose is to execute the plan rather than refine it |
| 55 | + |
| 56 | +### Permission Restrictions |
| 57 | + |
| 58 | +Even if your `settings.json` is configured to auto-allow write, delete, or similar operations, Plan Mode **forcibly escalates these to "ask."** Specifically, the following permission scopes always require confirmation in Plan Mode: |
| 59 | + |
| 60 | +| Permission scope | Description | |
| 61 | +| ---------------- | ----------- | |
| 62 | +| `write-in-cwd` | Create or overwrite files within the workspace | |
| 63 | +| `write-out-cwd` | Create or overwrite files outside the workspace | |
| 64 | +| `delete-in-cwd` | Delete files within the workspace | |
| 65 | +| `delete-out-cwd` | Delete files outside the workspace | |
| 66 | +| `mutate-git-log` | Modify Git history | |
| 67 | + |
| 68 | +This ensures that Plan Mode won't accidentally modify your code, even with permissive settings. |
| 69 | + |
| 70 | +## The Proposed Plan |
| 71 | + |
| 72 | +When the AI considers the plan decision-complete—meaning an implementer needs to make no further decisions—it outputs a `<proposed_plan>` block in the response: |
| 73 | + |
| 74 | +```xml |
| 75 | +<proposed_plan> |
| 76 | +Plan content (in Markdown) |
| 77 | +</proposed_plan> |
| 78 | +``` |
| 79 | + |
| 80 | +A plan typically includes: |
| 81 | + |
| 82 | +- **Title**: The plan name |
| 83 | +- **Summary**: A brief overview |
| 84 | +- **Key Changes / Implementation Changes**: Critical changes described at the behavior level (not a file-by-file inventory) |
| 85 | +- **Test Plan**: Test cases and scenarios |
| 86 | +- **Assumptions**: Assumptions made and defaults chosen |
| 87 | + |
| 88 | +After the plan is output, Deep Code automatically shows a choice dialog—no extra input needed: |
| 89 | + |
| 90 | +| Option | Effect | |
| 91 | +| ------ | ------ | |
| 92 | +| **1. implement this plan** | Leave Plan Mode and automatically send an implementation prompt so the AI starts coding | |
| 93 | +| **2. stay in Plan mode** | Stay in Plan Mode to continue refining the plan | |
| 94 | +| **3. switch to Default mode** | Leave Plan Mode and return to Default mode without starting implementation | |
| 95 | + |
| 96 | +You can press `1-3` to select directly, or use `↑/↓` to move the cursor and `Enter` to confirm. Pressing `Esc` is equivalent to choosing "stay in Plan mode." |
| 97 | + |
| 98 | +## Plan Mode vs. UpdatePlan Tool |
| 99 | + |
| 100 | +Plan Mode is a **collaborative conversation mode** whose final artifact is the complete plan inside a `<proposed_plan>` block. |
| 101 | + |
| 102 | +`UpdatePlan` is Deep Code's **progress checklist tool** that shows step-by-step progress during execution. It does not enter or exit Plan Mode and is not the final planning artifact. |
| 103 | + |
| 104 | +The two can work together: during implementation, the AI may use `UpdatePlan` to track progress on complex tasks, but the plan itself is already settled in Plan Mode. |
| 105 | + |
| 106 | +## Common Use Cases |
| 107 | + |
| 108 | +### 1. New Feature Development |
| 109 | + |
| 110 | +``` |
| 111 | +Add pagination and search to the user list. |
| 112 | +``` |
| 113 | + |
| 114 | +In Plan Mode, the AI first understands the existing code structure, routes, and data models, then discusses pagination style (cursor vs. offset), search scope, API changes, etc., before producing a complete plan. |
| 115 | + |
| 116 | +### 2. Code Refactoring |
| 117 | + |
| 118 | +``` |
| 119 | +Split the tangled business logic in UserService into separate services. |
| 120 | +``` |
| 121 | + |
| 122 | +The AI analyzes `UserService` dependencies and call sites, then proposes a split plan with migration steps and compatibility considerations. |
| 123 | + |
| 124 | +### 3. Architecture Review |
| 125 | + |
| 126 | +``` |
| 127 | +Analyze the current authentication flow and suggest security improvements. |
| 128 | +``` |
| 129 | + |
| 130 | +The AI walks through auth-related code, identifies potential risks, and delivers concrete improvement steps as a plan. |
0 commit comments