---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/zed.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/zed.md
  - href: en/sourcecraft/operations/zed.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: Connecting the SourceCraft CLI AI agent CLI in Zed
description: How to connect the SourceCraft CLI AI agent in the Zed editor.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


<!-- source: en/_includes/sourcecraft/src-cli-zed.md -->
# Integrating Code Assistant with Zed using the SourceCraft CLI

[Zed](https://zed.dev/) is a fast cross-platform open-source editor written in Rust and designed for collaborative development with integrated AI agents.

To integrate [Code Assistant](https://sourcecraft.dev/portal/docs/en/code-assistant/index.md) with Zed, you need to use the [SourceCraft CLI](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/cli-quickstart.md) over [ACP](https://agentclientprotocol.com/get-started/introduction) (Agent Client Protocol).

To use Code Assistant in Zed:
1. [Install and configure](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/cli-quickstart.md) the SourceCraft CLI.

    {% note warning %}

    Make sure to confirm the [OpenCode](https://opencode.ai/docs/en) installation.

    {% endnote %}

1. [Install](https://zed.dev/download) Zed.
1. Connect the SourceCraft CLI to Zed as an [external custom AI agent](https://zed.dev/docs/ai/external-agents#custom-agents):

    {% list tabs group=instructions %}

    - GUI {#ui}

      1. Open Zed settings by pressing **Ctrl** + **,** for Windows/Linux or **Command** + **,** for macOS.
      1. Go to **AI** → **General** → **External Agents** → **Configure >**.
      1. Click ![image](../../_assets/console-icons/plus.svg) **Add Agent** and select **Add Custom Agent**.
      1. Fill out the fields as follows:
          * **Agent Name**: Agent name, e.g., `SourceCraft Code Assistant`.
          * **Command**: Path to the SourceCraft CLI executable, such as the following:

            <!-- source: en/_includes/sourcecraft/src-cli-path.md -->
            * In Linux: `/home/<username>/sourcecraft/bin/src`
            * In macOS: `/Users/<username>/sourcecraft/bin/src`
            * In Windows: `C:\Users\<username>\AppData\Local\Programs\src\src.exe`
            <!-- endsource: en/_includes/sourcecraft/src-cli-path.md -->

          * **Arguments**: Settings for running OpenCode from the SourceCraft CLI in ACP mode: `code -- acp`.
          * **Environment Variables**: Leave empty.
      1. Click **Save** and close the settings window.

    - Configuration file {#config}

      1. Open the `settings.json` Zed configuration file by pressing **Ctrl** + **Alt** + **,** for Windows or Linux or **Command** + **Option** + **,** for macOS.
      1. Add the `agent_servers` section:

          ```json
          {
            "agent_servers": {
              "SourceCraftCA": {
                "type": "custom",
                "command": "<path_to_SourceCraft_CLI_executable>",
                "args": [
                  "code",
                  "--",
                  "acp"
                ],
                "default_config_options": {
                  "mode": "plan"
                }
              }
            }
          }
          ```

          Where `command` is the path to the SourceCraft CLI executable, such as the following:

          <!-- source: en/_includes/sourcecraft/src-cli-path.md -->
          * In Linux: `/home/<username>/sourcecraft/bin/src`
          * In macOS: `/Users/<username>/sourcecraft/bin/src`
          * In Windows: `C:\Users\<username>\AppData\Local\Programs\src\src.exe`
          <!-- endsource: en/_includes/sourcecraft/src-cli-path.md -->

      1. Save your changes.

    {% endlist %}

1. Open the agent panel by pressing **Ctrl** + **Alt** + **B** for Windows or Linux or **Command** + **B** for macOS, click ![image](../../_assets/console-icons/plus.svg) on top of the panel, and select the external `SourceCraft Code Assistant` agent.
1. Test the agent by typing a prompt in the chat window.

#### Useful links {#see-also}

* [Getting started with the SourceCraft CLI](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/cli-quickstart.md)
* [SourceCraft CLI reference](https://sourcecraft.dev/portal/docs/en/cli-ref/src-code.md)
* [External AI agents Zed reference](https://zed.dev/docs/ai/external-agents)
<!-- endsource: en/_includes/sourcecraft/src-cli-zed.md -->
