← Back to Blog

Introducing Zed AI

August 20th, 2024


At Zed, we've dedicated our careers to mastering the art of text manipulation. From crafting parser generators to designing programming languages and shipping two production-grade text editors, we've always been captivated by the expressive power of words and symbols. So when large language models emerged to revolutionize text interpretation and generation, we knew we had to explore their potential.

In the two years since LLMs came onto our radar, we've been focused on building out the core of Zed: a fast, reliable text editor with the features developers need. Meanwhile, we've been quietly experimenting with integrating LLMs into our own workflows. Not as a flashy gimmick, but as a practical tool to enhance our productivity working on a complex, real-world codebase.

As we refined our AI integration, we caught the attention of some unexpected allies. Engineers at Anthropic, one of the world's leading AI companies, discovered Zed and quickly saw the value of our raw, text-centric interface that puts minimal separation between the user and the language model. Their enthusiasm was validating, and our conversations sparked a dialogue that quickly evolved into a collaboration.

Now, we're ready to introduce Zed AI, a hosted service providing convenient and performant support for AI-enabled coding in Zed, powered by Anthropic's Claude 3.5 Sonnet and accessible just by signing in. We also worked with Anthropic to optimize Zed for implement their new Prompt Caching beta, leading to lightning-fast responses even with thousands of lines of code included in the context window while reducing cost.

Zed AI is available now, free during our initial launch period. Sign in to Zed to access an AI-powered assistant panel and inline code transformations that integrate directly with your editing environment.

How Zed AI Works

What began as an experiment in AI-assisted coding has evolved into something that's captured the attention of leading AI practitioners. Our collaboration with Anthropic has grown organically, with a growing wave of their developers now using Zed daily and a core team of Anthropic's Rust engineers actively contributing to our open-source codebase.

By marrying cutting-edge AI with a fast, thoughtfully designed editor, we're creating a tool that resonates with those at the forefront of AI development—experts who demand both power and precision in their workflows.

Our approach to AI-assisted coding hinges on the interaction between two core features: Zed's assistant panel and inline transformations. This combination allows developers to leverage the power of language models while maintaining full control over their code.

The Assistant Panel: Mastering Massive Context

The assistant panel is where you interact with AI models in Zed, but it's not your typical chat interface. It's a full-fledged text editor that exposes the entire LLM request. Code snippets, conversation history, file contents—it's all there, and it's all just text. You can observe, edit, and refine any part of the request using familiar coding tools, giving you full transparency and control over every interaction.

To populate this text-based context, we've introduced a system of slash commands:

  • /tab: Insert the contents of an open tab
  • /file: Insert the contents of a specific file or tree of files
  • /terminal: Include terminal output
  • /diagnostics: Insert diagnostic information from across the codebase
  • /fetch: Insert the response from an arbitrary HTTP URL
Creating a Zed extension using the assistant panel.

The /file command allows us to bring in relevant context from our codebase, which the AI can then use to assist in development tasks.

When you use a slash command or the quote selection binding (cmd->), Zed inserts the content as folded text. This includes entire directory trees, which are inserted as recursive folds containing the full text of each file.

Zed's folding mechanism for inserted context balances detail with the big picture when working with large codebases or API documentation. Every token of context remains visible and editable, ensuring precise control over AI prompts. Expand folds to examine specifics, or collapse them to focus on the overall structure. This flexibility lets you tailor both your view and your AI interactions to the task at hand.

Slash commands are extensible via WebAssembly or a JSON-based context server protocol, opening up exciting possibilities. You can create custom commands tailored to your workflow, and we envision a future where language servers might implement /commands to fetch context in language-specific ways.

Now that we've created our Perplexity extension, let's see it in action:

Using the created Zed extension.

In this demo, we:

  1. Use our new /perplexity command to fetch key C interfaces for microphone capture on macOS: "/perplexity Provide the essential C interfaces for capturing microphone input on macOS. Include only the most relevant functions and structures."

  2. Use the fetched interfaces to generate Rust bindings: "Generate Rust bindings for capturing microphone input on macOS using these C interfaces."

This streamlined workflow demonstrates how Zed AI can seamlessly integrate external knowledge (/perplexity) and code generation, all within a single, coherent interface. By fetching the key interfaces directly, we've eliminated the need for manual file operations, making the process more efficient and focused.

Inline Transformations

Inline transformations, activated with ctrl-enter, allow you to transform and generate code via natural language prompts. What sets them apart is their precision and responsiveness.

To give you fast feedback, we've implemented a custom streaming diff protocol that works with Zed's CRDT-based buffers to deliver edits as soon as they're streamed from the model. You see the model's output token by token, allowing you to read and react to changes as they happen. This low-latency streaming creates a fluid, interactive coding experience that keeps you engaged and in control throughout the process.

Inline transformations in Zed use the context you've built in the assistant panel. There's no hidden system prompt-you see and control every input shaping the model's output. This transparency lets you fine-tune the model's behavior and improve your skills in AI-assisted coding.

Text transformation in Zed gains a powerful dimension through its recursive capabilities. You can apply inline transformations within the assistant panel itself, allowing you to refine context and iteratively improve prompts. This feature turns the panel into a dynamic workspace for prompt engineering, where you can experiment with different approaches, refine your instructions, and even use AI to help craft more effective AI prompts.

Inline transformations also work with Zed's multiple cursor feature, allowing you to apply the same transformation across multiple selections simultaneously.

What's Next for Zed AI

We're continuously working to expand Zed AI's capabilities. Here's a glimpse of what we're developing:

Workflows for Complex Transformations

You've seen how inline transformations can pull context from the assistant panel and even transform the panel's content itself. With the /workflow command, we're expanding this capability to create a two-way interaction between the assistant panel and your project files.

This feature allows you to work within the assistant panel to orchestrate changes that directly affect your codebase. When you use /workflow, it directs the model to emit a series of <step> tags that Zed interprets. These steps suggest inline transformations directly in your project files, offering a guided, AI-assisted approach to complex coding tasks.

The /workflow command effectively bridges the gap between the assistant panel and your actual code, allowing for a more integrated and powerful AI-assisted development process. While we're actively refining this feature, you can already try /workflow in Zed today. We encourage you to experiment with it across different programming languages and share your experiences. Your insights will help us expand and improve it.

Using the /workflow command.

Tools for Efficiently Crafting Contexts

We recognize that efficiently building appropriate context is a key challenge in AI-assisted development. To address this, we're developing tools that help you gather relevant information more quickly. These tools maintain the transparency and control central to Zed's philosophy, giving you powerful context-building capabilities while ensuring you understand and manage what goes into each AI interaction.

We're currently working on two key features to solve this problem:

  • /project: Currently behind a configuration flag, this command helps you quickly find and insert relevant project information into the assistant panel. It's designed to speed up context building while still allowing you to review and edit the results before they're used.

  • /auto: An upcoming feature that will automatically insert context based on your current task, much like other / commands. While it operates automatically, the inserted context remains fully visible and editable, allowing you to explore, modify, or remove any information it pulls in. This feature aims to streamline context building while maintaining your ability to control and understand the information being used.

These features are designed to give you leverage in managing complex contexts, while preserving your ability to understand and control exactly what information is being used in your AI interactions. We believe this balance of power and transparency is crucial for effective AI-assisted development.

As we continue to refine these tools, we welcome your feedback and ideas on how to further improve context management in Zed AI.

Join Us in Shaping AI-Assisted Development

Zed AI embodies our belief in open, collaborative software development. We've created a transparent, extensible environment that empowers you to harness AI on your own terms, keeping you firmly in control of your tools and workflows.

We invite you to try Zed AI and become part of this journey. Experiment with custom slash commands, fine-tune prompts, and push boundaries. Share your innovations as extensions or as contributions to the Zed repository.

With Zed AI, you're in the driver's seat, directing AI's potential within the familiar realm of text. Together, we'll build an AI-assisted development experience that amplifies your creativity and adapts to your unique coding style. We're excited to see what our community will create.