1# Text Threads
2
3## Overview {#overview}
4
5Text threads in the [Agent Panel](./agent-panel.md) work like a regular editor. You can use custom keybindings, multiple cursors, and all standard editing features.
6
7Text threads organize content into message blocks with roles:
8
9- `You`
10- `Assistant`
11- `System`
12
13To begin, type a message in a `You` block.
14
15
16
17As you type, the remaining tokens count for the selected model is updated.
18
19Inserting text from an editor is as simple as highlighting the text and running `agent: add selection to thread` ({#kb agent::AddSelectionToThread}); Zed will wrap it in a fenced code block if it is code.
20
21
22
23To submit a message, use {#kb assistant::Assist}(`assistant: assist`).
24In text threads, {#kb editor::Newline} inserts a new line rather than submitting. This preserves standard editor behavior.
25
26After submitting a message, the response will be streamed below, in an `Assistant` message block.
27
28
29
30The stream can be canceled at any point with <kbd>escape</kbd>.
31This is useful if you realize early on that the response is not what you were looking for.
32
33If you want to start a new conversation at any time, you can hit <kbd>cmd-n|ctrl-n</kbd> or use the `New Chat` menu option in the hamburger menu at the top left of the panel.
34
35Text threads support straightforward conversations, but you can also go back and modify earlier messages to change direction.
36
37## Editing a Text Thread {#edit-text-thread}
38
39You can edit any text in a thread, including previous LLM responses.
40If you want to remove a message block entirely, simply place your cursor at the beginning of the block and use the `delete` key.
41A typical workflow might involve making edits and adjustments throughout the context to refine your inquiry or provide additional information.
42Here's an example:
43
441. Write text in a `You` block.
452. Submit the message with {#kb assistant::Assist}.
463. Receive an `Assistant` response that doesn't meet your expectations.
474. Cancel the response with <kbd>escape</kbd>.
485. Erase the content of the `Assistant` message block and remove the block entirely.
496. Add additional context to your original message.
507. Submit the message with {#kb assistant::Assist}.
51
52Being able to edit previous messages gives you control over how tokens are used.
53You don't need to start up a new chat to correct a mistake or to add additional information, and you don't have to waste tokens by submitting follow-up corrections.
54
55> **Note**: The act of editing past messages is often referred to as "Rewriting History" in the context of the language models.
56
57Some additional points to keep in mind:
58
59- You can cycle the role of a message block by clicking on the role, which is useful when you receive a response in an `Assistant` block that you want to edit and send back up as a `You` block.
60
61## Commands Overview {#commands}
62
63Type `/` at the beginning of a line to see available slash commands:
64
65- `/default`: Inserts the default rule
66- `/diagnostics`: Injects errors reported by the project's language server
67- `/fetch`: Fetches the content of a webpage and inserts it
68- `/file`: Inserts a single file or a directory of files
69- `/now`: Inserts the current date and time
70- `/prompt`: Adds a custom-configured prompt to the context ([see Rules Library](./rules.md#rules-library))
71- `/symbols`: Inserts the current tab's active symbols
72- `/tab`: Inserts the content of the active tab or all open tabs
73- `/terminal`: Inserts a select number of lines of output from the terminal
74- `/selection`: Inserts the selected text
75
76> **Note:** Remember, commands are only evaluated when the text thread is created or when the command is inserted, so a command like `/now` won't continuously update, or `/file` commands won't keep their contents up to date.
77
78### `/default`
79
80Read more about `/default` in the [Rules: Editing the Default Rules](./rules.md#default-rules) section.
81
82Usage: `/default`
83
84### `/diagnostics`
85
86Injects errors reported by the project's language server into the context.
87
88Usage: `/diagnostics [--include-warnings] [path]`
89
90- `--include-warnings`: Optional flag to include warnings in addition to errors.
91- `path`: Optional path to limit diagnostics to a specific file or directory.
92
93### `/file`
94
95Inserts the content of a file or directory into the context. Supports glob patterns.
96
97Usage: `/file <path>`
98
99Examples:
100
101- `/file src/index.js` - Inserts the content of `src/index.js` into the context.
102- `/file src/*.js` - Inserts the content of all `.js` files in the `src` directory.
103- `/file src` - Inserts the content of all files in the `src` directory.
104
105### `/now`
106
107Inserts the current date and time. Useful for informing the model about its knowledge cutoff relative to now.
108
109Usage: `/now`
110
111### `/prompt`
112
113Inserts a rule from the Rules Library into the context. Rules can nest other rules.
114
115Usage: `/prompt <prompt_name>`
116
117Related: `/default`
118
119### `/symbols`
120
121Inserts the active symbols (functions, classes, etc.) from the current tab, providing a structural overview of the file.
122
123Usage: `/symbols`
124
125### `/tab`
126
127Inserts the content of the active tab or all open tabs.
128
129Usage: `/tab [tab_name|all]`
130
131- `tab_name`: Optional name of a specific tab to insert.
132- `all`: Insert content from all open tabs.
133
134Examples:
135
136- `/tab` - Inserts the content of the active tab.
137- `/tab "index.js"` - Inserts the content of the tab named "index.js".
138- `/tab all` - Inserts the content of all open tabs.
139
140### `/terminal`
141
142Inserts recent terminal output (default: 50 lines).
143
144Usage: `/terminal [<number>]`
145
146- `<number>`: Optional parameter to specify the number of lines to insert (default is 50).
147
148### `/selection`
149
150Inserts the currently selected text. Equivalent to `agent: add selection to thread` ({#kb agent::AddSelectionToThread}).
151
152Usage: `/selection`
153
154## Commands in the Rules Library {#slash-commands-in-rules}
155
156[Commands](#commands) can be used in rules, in the Rules Library (previously known as Prompt Library), to insert dynamic content or perform actions.
157For example, if you want to create a rule where it is important for the model to know the date, you can use the `/now` command to insert the current date.
158
159> **Warn:** Slash commands in rules **only** work when they are used in text threads. Using them in non-text threads is not supported.
160
161> **Note:** Slash commands in rules **must** be on their own line.
162
163See the [list of commands](#commands) above for more information on commands, and what slash commands are available.
164
165### Example
166
167```plaintext
168You are an expert Rust engineer. The user has asked you to review their project and answer some questions.
169
170Here is some information about their project:
171
172/file Cargo.toml
173```
174
175In the above example, the `/file` command is used to insert the contents of the `Cargo.toml` file (or all `Cargo.toml` files present in the project) into the rule.
176
177## Nesting Rules
178
179Similar to adding rules to the default rules, you can nest rules within other rules with the `/prompt` command (only supported in Text Threads currently).
180
181You might want to nest rules to:
182
183- Create templates on the fly
184- Break collections like docs or references into smaller, mix-and-matchable parts
185- Create variants of a similar rule (e.g., `Async Rust - Tokio` vs. `Async Rust - Async-std`)
186
187### Example
188
189```plaintext
190Title: Zed-Flavored Rust
191
192## About Zed
193
194/prompt Zed: Zed (a rule about what Zed is)
195
196## Rust - Zed Style
197
198/prompt Rust: Async - Async-std (zed doesn't use tokio)
199/prompt Rust: Zed-style Crates (we have some unique conventions)
200/prompt Rust - Workspace deps (bias towards reusing deps from the workspace)
201```
202
203_The text in parentheses above are comments and are not part of the rule._
204
205> **Note:** While you technically _can_ nest a rule within itself, we wouldn't recommend it (in the strongest of terms.) Use at your own risk!
206
207By using nested rules, you can create modular and reusable rule components that can be combined in various ways to suit different scenarios.
208
209> **Note:** When using slash commands to bring in additional context, the injected content can be edited directly inline in the text thread—edits here will not propagate to the saved rules.
210
211## Extensibility
212
213Additional slash commands can be provided by extensions.
214
215See [Extension: Slash Commands](../extensions/slash-commands.md) to learn how to create your own.
216
217## Text Threads vs. Threads
218
219Text threads were Zed's original AI interface. In May 2025, Zed introduced the current [Agent Panel](./agent-panel.md), optimized for readability and agentic workflows.
220
221The key difference: text threads don't support tool calls. They can't read files, write code, or run commands on your behalf. Text threads are for conversational interaction where you only receive text responses.
222
223[MCP servers](./mcp.md) and [external agents](./external-agents.md) are not available in text threads.
224
225## Advanced Concepts
226
227### Rule Templates {#rule-templates}
228
229Zed uses rule templates to power internal assistant features, like the terminal assistant, or the content rules used in the inline assistant.
230
231Zed has the following internal rule templates:
232
233- `content_prompt.hbs`: Used for generating content in the editor.
234- `terminal_assistant_prompt.hbs`: Used for the terminal assistant feature.
235
236At this point it is unknown if we will expand templates further to be user-creatable.
237
238### Overriding Templates
239
240> **Note:** It is not recommended to override templates unless you know what you are doing. Editing templates will break your assistant if done incorrectly.
241
242Zed allows you to override the default rules used for various assistant features by placing custom Handlebars (.hbs) templates in your `~/.config/zed/prompt_overrides` directory.
243
244The following templates can be overridden:
245
2461. [`content_prompt.hbs`](https://github.com/zed-industries/zed/tree/main/assets/prompts/content_prompt.hbs): Used for generating content in the editor.
247
2482. [`terminal_assistant_prompt.hbs`](https://github.com/zed-industries/zed/tree/main/assets/prompts/terminal_assistant_prompt.hbs): Used for the terminal assistant feature.
249
250> **Note:** Be sure you want to override these, as you'll miss out on iteration on our built-in features.
251> This should be primarily used when developing Zed.
252
253You can customize these templates to better suit your needs while maintaining the core structure and variables used by Zed.
254Zed will automatically reload your prompt overrides when they change on disk.
255
256Consult Zed's [assets/prompts](https://github.com/zed-industries/zed/tree/main/assets/prompts) directory for current versions you can play with.
257
258### History {#history}
259
260After you submit your first message in a text thread, a name for your context is generated by the language model, and the context is automatically saved to your file system in
261
262- `~/.config/zed/conversations` (macOS)
263- `~/.local/share/zed/conversations` (Linux)
264- `%LocalAppData%\Zed\conversations` (Windows)
265
266You can access and load previous contexts by clicking on the history button in the top-left corner of the agent panel.
267
268