2026-02-09 22:13:04 -05:00
|
|
|
# Plan Mode (experimental)
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
Plan Mode is a read-only environment for architecting robust solutions before
|
|
|
|
|
implementation. It allows you to:
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
- **Research:** Explore the project in a read-only state to prevent accidental
|
|
|
|
|
changes.
|
|
|
|
|
- **Design:** Understand problems, evaluate trade-offs, and choose a solution.
|
|
|
|
|
- **Plan:** Align on an execution strategy before any code is modified.
|
|
|
|
|
|
|
|
|
|
> **Note:** This is a preview feature currently under active development. Your
|
|
|
|
|
> feedback is invaluable as we refine this feature. If you have ideas,
|
2026-02-08 22:25:02 -05:00
|
|
|
> suggestions, or encounter issues:
|
|
|
|
|
>
|
|
|
|
|
> - [Open an issue](https://github.com/google-gemini/gemini-cli/issues) on
|
|
|
|
|
> GitHub.
|
2026-02-20 10:56:49 -05:00
|
|
|
> - Use the **/bug** command within Gemini CLI to file an issue.
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
- [Enabling Plan Mode](#enabling-plan-mode)
|
2026-02-08 22:25:02 -05:00
|
|
|
- [How to use Plan Mode](#how-to-use-plan-mode)
|
|
|
|
|
- [Entering Plan Mode](#entering-plan-mode)
|
2026-02-20 10:56:49 -05:00
|
|
|
- [Planning Workflow](#planning-workflow)
|
2026-02-08 22:25:02 -05:00
|
|
|
- [Exiting Plan Mode](#exiting-plan-mode)
|
2026-03-03 16:36:51 -05:00
|
|
|
- [Commands](#commands)
|
2026-02-08 22:25:02 -05:00
|
|
|
- [Tool Restrictions](#tool-restrictions)
|
2026-02-11 12:59:03 -05:00
|
|
|
- [Customizing Planning with Skills](#customizing-planning-with-skills)
|
2026-02-11 12:32:02 -05:00
|
|
|
- [Customizing Policies](#customizing-policies)
|
2026-02-20 10:56:49 -05:00
|
|
|
- [Example: Allow git commands in Plan Mode](#example-allow-git-commands-in-plan-mode)
|
2026-03-03 11:52:27 -05:00
|
|
|
- [Example: Enable custom subagents in Plan Mode](#example-enable-custom-subagents-in-plan-mode)
|
2026-02-20 10:56:49 -05:00
|
|
|
- [Custom Plan Directory and Policies](#custom-plan-directory-and-policies)
|
2026-02-24 19:15:14 -05:00
|
|
|
- [Automatic Model Routing](#automatic-model-routing)
|
2026-03-03 09:11:25 -05:00
|
|
|
- [Cleanup](#cleanup)
|
2026-02-20 10:56:49 -05:00
|
|
|
|
|
|
|
|
## Enabling Plan Mode
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
To use Plan Mode, enable it via **/settings** (search for **Plan**) or add the
|
|
|
|
|
following to your `settings.json`:
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"experimental": {
|
|
|
|
|
"plan": true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
## How to use Plan Mode
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
### Entering Plan Mode
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
You can configure Gemini CLI to start in Plan Mode by default or enter it
|
|
|
|
|
manually during a session.
|
|
|
|
|
|
|
|
|
|
- **Configuration:** Configure Gemini CLI to start directly in Plan Mode by
|
|
|
|
|
default:
|
|
|
|
|
1. Type `/settings` in the CLI.
|
|
|
|
|
2. Search for **Default Approval Mode**.
|
|
|
|
|
3. Set the value to **Plan**.
|
|
|
|
|
|
|
|
|
|
Alternatively, use the `gemini --approval-mode=plan` CLI flag or manually
|
|
|
|
|
update:
|
2026-02-08 22:25:02 -05:00
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
2026-02-10 08:07:04 -05:00
|
|
|
"general": {
|
|
|
|
|
"defaultApprovalMode": "plan"
|
2026-02-08 22:25:02 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
- **Keyboard Shortcut:** Press `Shift+Tab` to cycle through approval modes
|
|
|
|
|
(`Default` -> `Auto-Edit` -> `Plan`).
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
> **Note:** Plan Mode is automatically removed from the rotation when Gemini
|
|
|
|
|
> CLI is actively processing or showing confirmation dialogs.
|
2026-02-17 12:36:59 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
- **Command:** Type `/plan` in the input box.
|
2026-02-17 12:36:59 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
- **Natural Language:** Ask Gemini CLI to "start a plan for...". Gemini CLI then
|
|
|
|
|
calls the [`enter_plan_mode`] tool to switch modes.
|
|
|
|
|
> **Note:** This tool is not available when Gemini CLI is in [YOLO mode].
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
### Planning Workflow
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-26 17:58:19 -05:00
|
|
|
Plan Mode uses an adaptive planning workflow where the research depth, plan
|
|
|
|
|
structure, and consultation level are proportional to the task's complexity:
|
|
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
1. **Explore & Analyze:** Analyze requirements and use read-only tools to map
|
2026-02-26 17:58:19 -05:00
|
|
|
affected modules and identify dependencies.
|
|
|
|
|
2. **Consult:** The depth of consultation is proportional to the task's
|
|
|
|
|
complexity:
|
|
|
|
|
- **Simple Tasks:** Proceed directly to drafting.
|
|
|
|
|
- **Standard Tasks:** Present a summary of viable approaches via
|
|
|
|
|
[`ask_user`] for selection.
|
|
|
|
|
- **Complex Tasks:** Present detailed trade-offs for at least two viable
|
|
|
|
|
approaches via [`ask_user`] and obtain approval before drafting.
|
|
|
|
|
3. **Draft:** Write a detailed implementation plan to the
|
|
|
|
|
[plans directory](#custom-plan-directory-and-policies). The plan's structure
|
|
|
|
|
adapts to the task:
|
|
|
|
|
- **Simple Tasks:** Focused on specific **Changes** and **Verification**
|
|
|
|
|
steps.
|
|
|
|
|
- **Standard Tasks:** Includes an **Objective**, **Key Files & Context**,
|
|
|
|
|
**Implementation Steps**, and **Verification & Testing**.
|
|
|
|
|
- **Complex Tasks:** Comprehensive plans including **Background &
|
|
|
|
|
Motivation**, **Scope & Impact**, **Proposed Solution**, **Alternatives
|
|
|
|
|
Considered**, a phased **Implementation Plan**, **Verification**, and
|
|
|
|
|
**Migration & Rollback** strategies.
|
2026-02-20 10:56:49 -05:00
|
|
|
4. **Review & Approval:** Use the [`exit_plan_mode`] tool to present the plan
|
|
|
|
|
and formally request approval.
|
|
|
|
|
- **Approve:** Exit Plan Mode and start implementation.
|
2026-02-08 22:25:02 -05:00
|
|
|
- **Iterate:** Provide feedback to refine the plan.
|
2026-02-26 19:30:23 -05:00
|
|
|
- **Refine manually:** Press **Ctrl + X** to open the plan file in your
|
|
|
|
|
[preferred external editor]. This allows you to manually refine the plan
|
2026-03-02 18:03:59 -05:00
|
|
|
steps before approval. If you make any changes and save the file, the CLI
|
|
|
|
|
will automatically send the updated plan back to the agent for review and
|
|
|
|
|
iteration.
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
For more complex or specialized planning tasks, you can
|
|
|
|
|
[customize the planning workflow with skills](#customizing-planning-with-skills).
|
|
|
|
|
|
2026-02-08 22:25:02 -05:00
|
|
|
### Exiting Plan Mode
|
|
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
To exit Plan Mode, you can:
|
|
|
|
|
|
|
|
|
|
- **Keyboard Shortcut:** Press `Shift+Tab` to cycle to the desired mode.
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
- **Tool:** Gemini CLI calls the [`exit_plan_mode`] tool to present the
|
|
|
|
|
finalized plan for your approval.
|
2026-02-08 22:25:02 -05:00
|
|
|
|
2026-03-03 16:36:51 -05:00
|
|
|
### Commands
|
|
|
|
|
|
|
|
|
|
- **`/plan copy`**: Copy the currently approved plan to your clipboard.
|
|
|
|
|
|
2026-02-08 22:25:02 -05:00
|
|
|
## Tool Restrictions
|
|
|
|
|
|
|
|
|
|
Plan Mode enforces strict safety policies to prevent accidental changes.
|
|
|
|
|
|
|
|
|
|
These are the only allowed tools:
|
|
|
|
|
|
|
|
|
|
- **FileSystem (Read):** [`read_file`], [`list_directory`], [`glob`]
|
|
|
|
|
- **Search:** [`grep_search`], [`google_web_search`]
|
2026-03-03 11:52:27 -05:00
|
|
|
- **Research Subagents:** [`codebase_investigator`], [`cli_help`]
|
2026-02-11 15:04:01 -05:00
|
|
|
- **Interaction:** [`ask_user`]
|
2026-02-08 22:25:02 -05:00
|
|
|
- **MCP Tools (Read):** Read-only [MCP tools] (e.g., `github_read_issue`,
|
|
|
|
|
`postgres_read_schema`) are allowed.
|
2026-02-20 10:56:49 -05:00
|
|
|
- **Planning (Write):** [`write_file`] and [`replace`] only allowed for `.md`
|
|
|
|
|
files in the `~/.gemini/tmp/<project>/<session-id>/plans/` directory or your
|
|
|
|
|
[custom plans directory](#custom-plan-directory-and-policies).
|
2026-02-26 08:59:44 -05:00
|
|
|
- **Memory:** [`save_memory`]
|
2026-02-11 12:59:03 -05:00
|
|
|
- **Skills:** [`activate_skill`] (allows loading specialized instructions and
|
|
|
|
|
resources in a read-only manner)
|
|
|
|
|
|
|
|
|
|
### Customizing Planning with Skills
|
|
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
You can use [Agent Skills](./skills.md) to customize how Gemini CLI approaches
|
|
|
|
|
planning for specific types of tasks. When a skill is activated during Plan
|
|
|
|
|
Mode, its specialized instructions and procedural workflows will guide the
|
|
|
|
|
research, design and planning phases.
|
2026-02-11 12:59:03 -05:00
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
- A **"Database Migration"** skill could ensure the plan includes data safety
|
|
|
|
|
checks and rollback strategies.
|
2026-02-20 10:56:49 -05:00
|
|
|
- A **"Security Audit"** skill could prompt Gemini CLI to look for specific
|
2026-02-11 12:59:03 -05:00
|
|
|
vulnerabilities during codebase exploration.
|
2026-02-20 10:56:49 -05:00
|
|
|
- A **"Frontend Design"** skill could guide Gemini CLI to use specific UI
|
2026-02-11 12:59:03 -05:00
|
|
|
components and accessibility standards in its proposal.
|
|
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
To use a skill in Plan Mode, you can explicitly ask Gemini CLI to "use the
|
|
|
|
|
`<skill-name>` skill to plan..." or Gemini CLI may autonomously activate it
|
|
|
|
|
based on the task description.
|
2026-02-19 17:47:08 -05:00
|
|
|
|
2026-02-11 12:32:02 -05:00
|
|
|
### Customizing Policies
|
|
|
|
|
|
2026-02-24 09:20:11 -05:00
|
|
|
Plan Mode's default tool restrictions are managed by the [policy engine] and
|
|
|
|
|
defined in the built-in [`plan.toml`] file. The built-in policy (Tier 1)
|
|
|
|
|
enforces the read-only state, but you can customize these rules by creating your
|
|
|
|
|
own policies in your `~/.gemini/policies/` directory (Tier 2).
|
2026-02-11 12:32:02 -05:00
|
|
|
|
2026-02-24 09:20:11 -05:00
|
|
|
#### Example: Automatically approve read-only MCP tools
|
|
|
|
|
|
|
|
|
|
By default, read-only MCP tools require user confirmation in Plan Mode. You can
|
|
|
|
|
use `toolAnnotations` and the `mcpName` wildcard to customize this behavior for
|
|
|
|
|
your specific environment.
|
|
|
|
|
|
|
|
|
|
`~/.gemini/policies/mcp-read-only.toml`
|
|
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[[rule]]
|
|
|
|
|
mcpName = "*"
|
|
|
|
|
toolAnnotations = { readOnlyHint = true }
|
|
|
|
|
decision = "allow"
|
|
|
|
|
priority = 100
|
|
|
|
|
modes = ["plan"]
|
|
|
|
|
```
|
2026-02-11 12:32:02 -05:00
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
#### Example: Allow git commands in Plan Mode
|
2026-02-11 12:32:02 -05:00
|
|
|
|
|
|
|
|
This rule allows you to check the repository status and see changes while in
|
|
|
|
|
Plan Mode.
|
|
|
|
|
|
|
|
|
|
`~/.gemini/policies/git-research.toml`
|
|
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[[rule]]
|
|
|
|
|
toolName = "run_shell_command"
|
|
|
|
|
commandPrefix = ["git status", "git diff"]
|
|
|
|
|
decision = "allow"
|
|
|
|
|
priority = 100
|
|
|
|
|
modes = ["plan"]
|
|
|
|
|
```
|
|
|
|
|
|
2026-03-03 11:52:27 -05:00
|
|
|
#### Example: Enable custom subagents in Plan Mode
|
2026-02-11 12:32:02 -05:00
|
|
|
|
2026-03-03 11:52:27 -05:00
|
|
|
Built-in research [subagents] like [`codebase_investigator`] and [`cli_help`]
|
|
|
|
|
are enabled by default in Plan Mode. You can enable additional [custom
|
|
|
|
|
subagents] by adding a rule to your policy.
|
2026-02-11 12:32:02 -05:00
|
|
|
|
|
|
|
|
`~/.gemini/policies/research-subagents.toml`
|
|
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[[rule]]
|
2026-03-03 11:52:27 -05:00
|
|
|
toolName = "my_custom_subagent"
|
2026-02-11 12:32:02 -05:00
|
|
|
decision = "allow"
|
|
|
|
|
priority = 100
|
|
|
|
|
modes = ["plan"]
|
|
|
|
|
```
|
|
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
Tell Gemini CLI it can use these tools in your prompt, for example: _"You can
|
2026-02-11 12:32:02 -05:00
|
|
|
check ongoing changes in git."_
|
|
|
|
|
|
2026-02-20 10:56:49 -05:00
|
|
|
For more information on how the policy engine works, see the [policy engine]
|
|
|
|
|
docs.
|
|
|
|
|
|
|
|
|
|
### Custom Plan Directory and Policies
|
|
|
|
|
|
|
|
|
|
By default, planning artifacts are stored in a managed temporary directory
|
|
|
|
|
outside your project: `~/.gemini/tmp/<project>/<session-id>/plans/`.
|
|
|
|
|
|
|
|
|
|
You can configure a custom directory for plans in your `settings.json`. For
|
|
|
|
|
example, to store plans in a `.gemini/plans` directory within your project:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"general": {
|
|
|
|
|
"plan": {
|
|
|
|
|
"directory": ".gemini/plans"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To maintain the safety of Plan Mode, user-configured paths for the plans
|
|
|
|
|
directory are restricted to the project root. This ensures that custom planning
|
|
|
|
|
locations defined within a project's workspace cannot be used to escape and
|
|
|
|
|
overwrite sensitive files elsewhere. Any user-configured directory must reside
|
|
|
|
|
within the project boundary.
|
|
|
|
|
|
|
|
|
|
Using a custom directory requires updating your [policy engine] configurations
|
|
|
|
|
to allow `write_file` and `replace` in that specific location. For example, to
|
|
|
|
|
allow writing to the `.gemini/plans` directory within your project, create a
|
|
|
|
|
policy file at `~/.gemini/policies/plan-custom-directory.toml`:
|
|
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[[rule]]
|
|
|
|
|
toolName = ["write_file", "replace"]
|
|
|
|
|
decision = "allow"
|
|
|
|
|
priority = 100
|
|
|
|
|
modes = ["plan"]
|
|
|
|
|
# Adjust the pattern to match your custom directory.
|
|
|
|
|
# This example matches any .md file in a .gemini/plans directory within the project.
|
2026-02-23 12:48:50 -05:00
|
|
|
argsPattern = "\"file_path\":\"[^\"]+[\\\\/]+\\.gemini[\\\\/]+plans[\\\\/]+[\\w-]+\\.md\""
|
2026-02-20 10:56:49 -05:00
|
|
|
```
|
2026-02-11 12:32:02 -05:00
|
|
|
|
2026-02-24 19:15:14 -05:00
|
|
|
## Automatic Model Routing
|
|
|
|
|
|
|
|
|
|
When using an [**auto model**], Gemini CLI automatically optimizes [**model
|
|
|
|
|
routing**] based on the current phase of your task:
|
|
|
|
|
|
|
|
|
|
1. **Planning Phase:** While in Plan Mode, the CLI routes requests to a
|
|
|
|
|
high-reasoning **Pro** model to ensure robust architectural decisions and
|
|
|
|
|
high-quality plans.
|
|
|
|
|
2. **Implementation Phase:** Once a plan is approved and you exit Plan Mode,
|
|
|
|
|
the CLI detects the existence of the approved plan and automatically
|
|
|
|
|
switches to a high-speed **Flash** model. This provides a faster, more
|
|
|
|
|
responsive experience during the implementation of the plan.
|
|
|
|
|
|
|
|
|
|
This behavior is enabled by default to provide the best balance of quality and
|
|
|
|
|
performance. You can disable this automatic switching in your settings:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"general": {
|
|
|
|
|
"plan": {
|
|
|
|
|
"modelRouting": false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2026-03-03 09:11:25 -05:00
|
|
|
## Cleanup
|
|
|
|
|
|
|
|
|
|
By default, Gemini CLI automatically cleans up old session data, including all
|
|
|
|
|
associated plan files and task trackers.
|
|
|
|
|
|
|
|
|
|
- **Default behavior:** Sessions (and their plans) are retained for **30 days**.
|
|
|
|
|
- **Configuration:** You can customize this behavior via the `/settings` command
|
|
|
|
|
(search for **Session Retention**) or in your `settings.json` file. See
|
|
|
|
|
[session retention] for more details.
|
|
|
|
|
|
|
|
|
|
Manual deletion also removes all associated artifacts:
|
|
|
|
|
|
|
|
|
|
- **Command Line:** Use `gemini --delete-session <index|id>`.
|
|
|
|
|
- **Session Browser:** Press `/resume`, navigate to a session, and press `x`.
|
|
|
|
|
|
|
|
|
|
If you use a [custom plans directory](#custom-plan-directory-and-policies),
|
|
|
|
|
those files are not automatically deleted and must be managed manually.
|
|
|
|
|
|
2026-02-09 13:08:39 -05:00
|
|
|
[`list_directory`]: /docs/tools/file-system.md#1-list_directory-readfolder
|
|
|
|
|
[`read_file`]: /docs/tools/file-system.md#2-read_file-readfile
|
|
|
|
|
[`grep_search`]: /docs/tools/file-system.md#5-grep_search-searchtext
|
|
|
|
|
[`write_file`]: /docs/tools/file-system.md#3-write_file-writefile
|
|
|
|
|
[`glob`]: /docs/tools/file-system.md#4-glob-findfiles
|
|
|
|
|
[`google_web_search`]: /docs/tools/web-search.md
|
|
|
|
|
[`replace`]: /docs/tools/file-system.md#6-replace-edit
|
|
|
|
|
[MCP tools]: /docs/tools/mcp-server.md
|
2026-02-26 08:59:44 -05:00
|
|
|
[`save_memory`]: /docs/tools/memory.md
|
2026-02-11 12:59:03 -05:00
|
|
|
[`activate_skill`]: /docs/cli/skills.md
|
2026-03-03 11:52:27 -05:00
|
|
|
[`codebase_investigator`]: /docs/core/subagents.md#codebase_investigator
|
|
|
|
|
[`cli_help`]: /docs/core/subagents.md#cli_help
|
2026-02-20 10:56:49 -05:00
|
|
|
[subagents]: /docs/core/subagents.md
|
2026-03-03 11:52:27 -05:00
|
|
|
[custom subagents]: /docs/core/subagents.md#creating-custom-subagents
|
2026-02-20 10:56:49 -05:00
|
|
|
[policy engine]: /docs/reference/policy-engine.md
|
2026-02-11 13:53:43 -05:00
|
|
|
[`enter_plan_mode`]: /docs/tools/planning.md#1-enter_plan_mode-enterplanmode
|
|
|
|
|
[`exit_plan_mode`]: /docs/tools/planning.md#2-exit_plan_mode-exitplanmode
|
2026-02-11 15:04:01 -05:00
|
|
|
[`ask_user`]: /docs/tools/ask-user.md
|
2026-02-20 10:56:49 -05:00
|
|
|
[YOLO mode]: /docs/reference/configuration.md#command-line-arguments
|
2026-02-24 09:20:11 -05:00
|
|
|
[`plan.toml`]:
|
|
|
|
|
https://github.com/google-gemini/gemini-cli/blob/main/packages/core/src/policy/policies/plan.toml
|
2026-02-24 19:15:14 -05:00
|
|
|
[auto model]: /docs/reference/configuration.md#model-settings
|
|
|
|
|
[model routing]: /docs/cli/telemetry.md#model-routing
|
2026-02-26 19:30:23 -05:00
|
|
|
[preferred external editor]: /docs/reference/configuration.md#general
|
2026-03-03 09:11:25 -05:00
|
|
|
[session retention]: /docs/cli/session-management.md#session-retention
|