External Agents | Zed Code Editor Documentation
Description: Learn how to use and customize Zed, the fast, collaborative code editor. Official docs on features, configuration, AI tools, and workflows.

# External Agents

Zed supports terminal-based agents through the Agent Client Protocol (ACP).

Currently, Gemini CLI serves as the reference implementation. Claude Code and Codex are also included by default, and you can add custom ACP-compatible agents as well.

> Note that Zed's affordance for external agents is strictly UI-based; the billing and legal/terms arrangement is directly between you and the agent provider. Zed does not charge for use of external agents, and our zero-data retention agreements/privacy guarantees are only applicable for Zed's hosted models.

## Gemini CLI

Zed provides the ability to run Gemini CLI directly in the agent panel.

Under the hood we run Gemini CLI in the background, and talk to it over ACP. This means that you're running the real Gemini CLI, with all of the advantages of that, but you can see and interact with files in your editor.

### Getting Started

As of Zed Stable v0.201.5 you should be able to use Gemini CLI directly from Zed. First open the agent panel with `cmd-?|ctrl-?`, and then use the `+` button in the top right to start a new Gemini CLI thread.

If you'd like to bind this to a keyboard shortcut, you can do so by editing your `keymap.json` file via the `zed: open keymap` command to include:

    [
      {
        "bindings": {
          "cmd-alt-g": ["agent::NewExternalAgentThread", { "agent": "gemini" }]
        }
      }
    ]

#### Installation

The first time you create a Gemini CLI thread, Zed will install @google/gemini-cli. This installation is only available to Zed and is kept up to date as you use the agent.

By default, Zed will use this managed version of Gemini CLI even if you have it installed globally. However, you can configure it to use a version in your `PATH` by adding this to your settings:

    {
      "agent_servers": {
        "gemini": {
          "ignore_system_version": false
        }
      }
    }

#### Authentication

After you have Gemini CLI running, you'll be prompted to choose your authentication method.

Most users should click the "Log in with Google". This will cause a browser window to pop-up and auth directly with Gemini CLI. Zed does not see your OAuth or access tokens in this case.

You can also use the "Gemini API Key". If you select this, and have the `GEMINI_API_KEY` set, then we will use that. Otherwise Zed will prompt you for an API key which will be stored securely in your keychain, and used to start Gemini CLI from within Zed.

The "Vertex AI" option is for those who are using Vertex AI, and have already configured their environment correctly.

For more information, see the Gemini CLI docs.

### Usage

Similar to Zed's first-party agent, you can use Gemini CLI to do anything that you need. And to give it context, you can @-mention files, recent threads, symbols, or fetch the web.

> Note that some first-party agent features don't yet work with Gemini CLI: editing past messages, resuming threads from history, and checkpointing. We hope to add these features in the near future.

## Claude Code

Similar to Gemini CLI, you can also run Claude Code directly via Zed's agent panel. Under the hood, Zed runs Claude Code and communicate to it over ACP, through a dedicated adapter.

### Getting Started

Open the agent panel with `cmd-?|ctrl-?`, and then use the `+` button in the top right to start a new Claude Code thread.

If you'd like to bind this to a keyboard shortcut, you can do so by editing your `keymap.json` file via the `zed: open keymap` command to include:

    [
      {
        "bindings": {
          "cmd-alt-c": ["agent::NewExternalAgentThread", { "agent": "claude_code" }]
        }
      }
    ]

### Authentication

As of version `0.202.7` (stable) and `0.203.2` (preview), authentication to Zed's Claude Code installation is decoupled entirely from Zed's agent. That is to say, an Anthropic API key added via the Zed Agent's settings will not be utilized by Claude Code for authentication and billing.

To ensure you're using your billing method of choice, open a new Claude Code thread. Then, run `/login`, and authenticate either via API key, or via `Log in with Claude Code` to use a Claude Pro/Max subscription.

#### Installation

The first time you create a Claude Code thread, Zed will install @zed-industries/claude-code-acp. This installation is only available to Zed and is kept up to date as you use the agent.

Zed will always use this managed version of the Claude Code adapter, which includes a vendored version of the Claude Code CLI, even if you have it installed globally.

If you want to override the executable used by the adapter, you can set the `CLAUDE_CODE_EXECUTABLE` environment variable in your settings to the path of your preferred executable.

    {
      "agent_servers": {
        "claude": {
          "env": {
            "CLAUDE_CODE_EXECUTABLE": "/path/to/alternate-claude-code-executable"
          }
        }
      }
    }

### Usage

Similar to Zed's first-party agent, you can use Claude Code to do anything that you need. And to give it context, you can @-mention files, recent threads, symbols, or fetch the web.

In complement to talking to it over ACP, Zed relies on the Claude Code SDK to support some of its specific features. However, the SDK doesn't yet expose everything needed to fully support all of them:

- Slash Commands: A subset of built-in commands are supported, while custom slash commands are fully supported.
- Subagents are supported.
- Hooks are currently not supported.

> Also note that some first-party agent features don't yet work with Claude Code: editing past messages, resuming threads from history, and checkpointing. We hope to add these features in the near future.

#### CLAUDE.md

Claude Code in Zed will automatically use any `CLAUDE.md` file found in your project root, project subdirectories, or root `.claude` directory.

If you don't have a `CLAUDE.md` file, you can ask Claude Code to create one for you through the `init` slash command.

## Codex CLI

You can also run Codex CLI directly via Zed's agent panel. Under the hood, Zed runs Codex CLI and communicates to it over ACP, through a dedicated adapter.

### Getting Started

As of Zed Stable v0.208 you should be able to use Codex directly from Zed. Open the agent panel with `cmd-?|ctrl-?`, and then use the `+` button in the top right to start a new Codex thread.

If you'd like to bind this to a keyboard shortcut, you can do so by editing your `keymap.json` file via the `zed: open keymap` command to include:

    [
      {
        "bindings": {
          "cmd-alt-c": ["agent::NewExternalAgentThread", { "agent": "codex" }]
        }
      }
    ]

### Authentication

Authentication to Zed's Codex installation is decoupled entirely from Zed's agent. That is to say, an OpenAI API key added via the Zed Agent's settings will not be utilized by Codex for authentication and billing.

To ensure you're using your billing method of choice, open a new Codex thread. The first time you will be prompted to authenticate with one of three methods:

1. Login with ChatGPT - allows you to use your existing, paid ChatGPT subscription. Note: This method isn't currently supported in remote projects
2. `CODEX_API_KEY` - uses an API key you have set in your environment under the variable `CODEX_API_KEY`.
3. `OPENAI_API_KEY` - uses an API key you have set in your environment under the variable `OPENAI_API_KEY`.

If you are already logged in and want to change your authentication method, type `/logout` in the thread and authenticate again.

#### Installation

The first time you create a Codex thread, Zed will install codex-acp. This installation is only available to Zed and is kept up to date as you use the agent.

Zed will always use this managed version of Codex even if you have it installed globally.

### Usage

Similar to Zed's first-party agent, you can use Codex to do anything that you need. And to give it context, you can @-mention files, symbols, or fetch the web.

> Note that some first-party agent features don't yet work with Codex: editing past messages, resuming threads from history, and checkpointing. We hope to add these features in the near future.

## Add Custom Agents

You can run any agent speaking ACP in Zed by changing your settings as follows:

    {
      "agent_servers": {
        "Custom Agent": {
          "command": "node",
          "args": ["~/projects/agent/index.js", "--acp"],
          "env": {}
        }
      }
    }

This can also be useful if you're in the middle of developing a new agent that speaks the protocol and you want to debug it.

You can also specify a custom path, arguments, or environment for the builtin integrations by using the `claude` and `gemini` names.

## Debugging Agents

When using external agents in Zed, you can access the debug view via with `dev: open acp logs` from the Command Palette. This lets you see the messages being sent and received between Zed and the agent.

## MCP Servers

Note that for external agents, access to MCP servers installed from Zed may vary depending on the ACP agent implementation.

Regarding the built-in ones, Claude Code and Codex both support it, and Gemini CLI does not yet. In the meantime, learn how to add MCP server support to Gemini CLI through their documentation.