rules.md

 1# Using Rules {#using-rules}
 2
 3Rules are prompts inserted at the beginning of each agent interaction. Add them via files in your worktree (`.rules`, etc.) or through the Rules Library for reuse across projects and threads.
 4
 5## `.rules` files
 6
 7Zed supports including `.rules` files at the top level of worktrees, and they act as project-level instructions that are included in all of your interactions with the Agent Panel.
 8Other names for this file are also supported for compatibility with other agents, but note that the first file which matches in this list will be used:
 9
10- `.rules`
11- `.cursorrules`
12- `.windsurfrules`
13- `.clinerules`
14- `.github/copilot-instructions.md`
15- `AGENT.md`
16- `AGENTS.md`
17- `CLAUDE.md`
18- `GEMINI.md`
19
20## Rules Library {#rules-library}
21
22The Rules Library is an interface for writing and managing rules. It's a full editor with syntax highlighting and all standard keybindings.
23
24You can use the inline assistant right in the rules editor, allowing you to automate and rewrite rules.
25
26### Opening the Rules Library
27
281. Open the Agent Panel.
292. Click on the Agent menu (`...`) in the top right corner.
303. Select `Rules...` from the dropdown.
31
32You can also reach it by running {#action agent::OpenRulesLibrary} in the command palette or through the {#kb agent::OpenRulesLibrary} keybinding.
33
34### Managing Rules
35
36Once a rules file is selected, you can edit it directly in the built-in editor. Its title can be changed from the editor title bar as well.
37
38Rules can be duplicated, deleted, or added to the default rules using the buttons in the rules editor.
39
40### Creating Rules {#creating-rules}
41
42To create a rule file, simply open the `Rules Library` and click the `+` button. Rules files are stored locally and can be accessed from the library at any time.
43
44For guidance on writing effective rules:
45
46- [Anthropic: Prompt Engineering](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview)
47- [OpenAI: Prompt Engineering](https://platform.openai.com/docs/guides/prompt-engineering)
48
49### Editing the Default Rules {#default-rules}
50
51Zed allows you to customize the default rules used when interacting with LLMs.
52Or to be more precise, it uses a series of rules that are combined to form the default rules.
53
54Default rules are included in the context of every new thread automatically.
55You can also manually add other rules (that are not flagged as default) as context using the `@rule` command.
56
57## Migrating from Prompt Library
58
59Previously, the Rules Library was called the "Prompt Library".
60The new rules system replaces the Prompt Library except in a few specific cases, which are outlined below.
61
62### Slash Commands in Rules
63
64Previously, it was possible to use slash commands (now @-mentions) in custom prompts (now rules).
65There is currently no support for using @-mentions in rules files, however, slash commands are supported in rules files when used with text threads.
66See the documentation for using [slash commands in rules](./text-threads.md#slash-commands-in-rules) for more information.
67
68### Prompt templates
69
70Zed maintains backwards compatibility with its original template system, which allows you to customize prompts used throughout the application, including the inline assistant.
71While the Rules Library is now the primary way to manage prompts, you can still use these legacy templates to override default prompts.
72For more details, see the [Rules Templates](./text-threads.md#rule-templates) section under [Text Threads](./text-threads.md).