1# Using Rules {#using-rules}
2
3Rules are an essential part of interacting with AI assistants in Zed. They help guide the AI's responses and ensure you get the most relevant and useful information.
4
5Every new chat will start with the [default rules](#default-rules), which can be customized and is where your model prompting will stored.
6
7Remember that effective prompting is an iterative process. Experiment with different prompt structures and wordings to find what works best for your specific needs and the model you're using.
8
9Here are some tips for creating effective rules:
10
111. Be specific: Clearly state what you want the AI to do or explain.
122. Provide context: Include relevant information about your project or problem.
133. Use examples: If applicable, provide examples to illustrate your request.
144. Break down complex tasks: For multi-step problems, consider breaking them into smaller, more manageable rules.
15
16## `.rules` files
17
18Zed supports including `.rules` files at the top level of worktrees. Here, you can include project-level instructions you'd like to have included in all of your interactions with the agent panel. Other names for this file are also supported - the first file which matches in this list will be used: `.rules`, `.cursorrules`, `.windsurfrules`, `.clinerules`, `.github/copilot-instructions.md`, or `CLAUDE.md`.
19
20Zed also supports creating rules (`Rules Library`) that can be included in any interaction with the agent panel.
21
22## Rules Library {#rules-library}
23
24The Rules Library is an interface for writing and managing rules. Like other text-driven UIs in Zed, it is a full editor with syntax highlighting, keyboard shortcuts, etc.
25
26You can use the inline assistant right in the rules editor, allowing you to automate and rewrite rules.
27
28### Opening the Rules Library
29
301. Open the agent panel.
312. Click on the `Agent Menu` (`...`) in the top right corner.
323. Select `Rules...` from the dropdown.
33
34You can also use the `assistant: open rules library` command while in the agent panel.
35
36### Managing Rules
37
38Once 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.
39
40Rules can be duplicated, deleted, or added to the default rules using the buttons in the rules editor.
41
42## Creating Rules {#creating-rules}
43
44To 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.
45
46Having a series of rules files specifically tailored to prompt engineering can also help you write consistent and effective rules.
47
48The process of writing and refining prompts is commonly referred to as "prompt engineering."
49
50More on rule engineering:
51
52- [Anthropic: Prompt Engineering](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/overview)
53- [OpenAI: Prompt Engineering](https://platform.openai.com/docs/guides/prompt-engineering)
54
55## Editing the Default Rules {#default-rules}
56
57Zed allows you to customize the default rules used when interacting with LLMs. Or to be more precise, it uses a series of rules that are combined to form the default rules.
58
59To edit rules, select `Rules...` from the `Agent Menu` icon (`...`) in the upper right hand corner or using the {#kb assistant::OpenRulesLibrary} keyboard shortcut.
60
61A default set of rules might look something like:
62
63```plaintext
64[-] Default
65 [+] Today's date
66 [+] You are an expert
67 [+] Don't add comments
68```
69
70Default rules are included in the context of new threads automatically.
71
72Default rules will show at the top of the rules list, and will be included with every new conversation.
73
74You can manually add other rules as context using the `@rule` command.
75
76> **Note:** Remember, commands are only evaluated when the context is created, so a command like `@file` won't continuously update.
77
78## Migrating from Prompt Library
79
80Previously, the Rules Library was called the Prompt Library. The new rules system replaces the Prompt Library except in a few specific cases, which are outlined below.
81
82### Slash Commands in Rules
83
84Previously, it was possible to use slash commands (now @-mentions) in custom prompts (now rules). There is currently no support for using @-mentions in rules files, however, slash commands are supported in rules files when used with text threads. See the documentation for using [slash commands in rules](./text-threads.md#slash-commands-in-rules) for more information.
85
86### Prompt templates
87
88Zed maintains backwards compatibility with its original template system, which allows you to customize prompts used throughout the application, including the inline assistant. While the Rules Library is now the primary way to manage prompts, you can still use these legacy templates to override default prompts. For more details, see the [Rules Templates](./text-threads.md#rule-templates) section under [Text Threads](./text-threads.md).