docs/ide-integration/index.md
Gemini CLI can integrate with your IDE to provide a more seamless and context-aware experience. This integration allows the CLI to understand your workspace better and enables powerful features like native in-editor diffing.
There are two primary ways to integrate Gemini CLI with an IDE:
The Gemini CLI Companion extension grants Gemini CLI direct access to your VS Code compatible IDEs and improves your experience by providing real-time context such as open files, cursor positions, and text selection. The extension also enables a native diffing interface so you can seamlessly review and apply AI-generated code changes directly within your editor.
Workspace context: The CLI automatically gains awareness of your workspace to provide more relevant and accurate responses. This context includes:
Native diffing: When Gemini suggests code modifications, you can view the changes directly within your IDE's native diff viewer. This lets you review, edit, and accept or reject the suggested changes seamlessly.
VS Code commands: You can access Gemini CLI features directly from the VS
Code Command Palette (Cmd+Shift+P or Ctrl+Shift+P):
Gemini CLI: Run: Starts a new Gemini CLI session in the integrated
terminal.Gemini CLI: Accept Diff: Accepts the changes in the active diff editor.Gemini CLI: Close Diff Editor: Rejects the changes and closes the active
diff editor.Gemini CLI: View Third-Party Notices: Displays the third-party notices for
the extension.There are three ways to set up the IDE integration:
When you run Gemini CLI inside a supported editor, it will automatically detect your environment and prompt you to connect. Answering "Yes" will automatically run the necessary setup, which includes installing the companion extension and enabling the connection.
If you previously dismissed the prompt or want to install the extension manually, you can run the following command inside Gemini CLI:
/ide install
This will find the correct extension for your IDE and install it.
You can also install the extension directly from a marketplace.
[!NOTE] The "Gemini CLI Companion" extension may appear towards the bottom of search results. If you don't see it immediately, try scrolling down or sorting by "Newly Published".
After manually installing the extension, you must run
/ide enablein the CLI to activate the integration.
You can control the IDE integration from within the CLI:
/ide enable
/ide disable
When enabled, Gemini CLI will automatically attempt to connect to the IDE companion extension.
To check the connection status and see the context the CLI has received from the IDE, run:
/ide status
If connected, this command will show the IDE it's connected to and a list of recently opened files it is aware of.
<!-- prettier-ignore -->[!NOTE] The file list is limited to 10 recently accessed files within your workspace and only includes local files on disk.
When you ask Gemini to modify a file, it can open a diff view directly in your editor.
To accept a diff, you can perform any of the following actions:
Cmd+S or Ctrl+S).yes in the CLI when prompted.To reject a diff, you can:
no in the CLI when prompted.You can also modify the suggested changes directly in the diff view before accepting them.
If you select ‘Allow for this session’ in the CLI, changes will no longer show up in the IDE as they will be auto-accepted.
ACP is an open protocol that standardizes how AI coding agents communicate with code editors and IDEs. It addresses the challenge of fragmented distribution, where agents traditionally needed custom integrations for each client. With ACP, developers can implement their agent once, and it becomes compatible with any ACP-compliant editor.
For a comprehensive introduction to ACP, including its architecture and benefits, refer to the official ACP Introduction documentation.
Gemini CLI is officially available in the ACP Agent Registry. This allows you to install and update Gemini CLI directly within supporting IDEs and eliminates the need for manual downloads or IDE-specific extensions.
Using the registry ensures:
For more details on how the registry works, visit the official ACP Agent Registry page. You can learn about how specific IDEs leverage this integration in the following section.
Gemini CLI is an ACP-compatible agent available in the ACP Agent Registry. Here’s how different IDEs leverage the ACP and the registry:
JetBrains IDEs (like IntelliJ IDEA, PyCharm, or GoLand) offer built-in registry support, allowing users to find and install ACP-compatible agents directly.
For more details, refer to the official JetBrains AI Blog announcement.
Zed, a modern code editor, also integrates with the ACP Agent Registry. This allows Zed users to easily browse, install, and manage ACP agents.
Learn more about Zed's integration with the ACP Registry in their blog post.
Any other IDE that supports the ACP Agent Registry can install Gemini CLI directly through their in-built registry features.
If you are using Gemini CLI within a sandbox, be aware of the following:
host.docker.internal. No special configuration is usually
required, but you may need to ensure your Docker networking setup allows
connections from the container to the host.Message:
🔴 Disconnected: Failed to connect to IDE companion extension in [IDE Name]. Please ensure the extension is running. To install the extension, run /ide install.
GEMINI_CLI_IDE_WORKSPACE_PATH or GEMINI_CLI_IDE_SERVER_PORT) to connect
to the IDE. This usually means the IDE companion extension is not running or
did not initialize correctly.Message:
🔴 Disconnected: IDE connection error. The connection was lost unexpectedly. Please try reconnecting by running /ide enable
/ide enable to try and reconnect. If the issue
continues, open a new terminal window or restart your IDE.If automatic IDE detection fails, or if you are running Gemini CLI in a
standalone terminal and want to manually associate it with a specific IDE
instance, you can set the GEMINI_CLI_IDE_PID environment variable to the
process ID (PID) of your IDE.
macOS/Linux
export GEMINI_CLI_IDE_PID=12345
Windows (PowerShell)
$env:GEMINI_CLI_IDE_PID=12345
When this variable is set, Gemini CLI will skip automatic detection and attempt to connect using the provided PID.
Message:
🔴 Disconnected: Directory mismatch. Gemini CLI is running in a different location than the open workspace in [IDE Name]. Please run the CLI from one of the following directories: [List of directories]
cd into the same directory that is open in your IDE and
restart the CLI.Message:
🔴 Disconnected: To use this feature, please open a workspace folder in [IDE Name] and try again.
Message:
IDE integration is not supported in your current environment. To use this feature, run Gemini CLI in one of these supported IDEs: [List of IDEs]
Message:
No installer is available for IDE. Please install Gemini CLI Companion extension manually from the marketplace.
/ide install, but the CLI does not have an automated
installer for your specific IDE.For issues related to ACP integration, refer to the debugging and telemetry section in the ACP Mode documentation.