rules.md

 1---
 2title: AI Rules in Zed - .rules, .cursorrules, CLAUDE.md
 3description: Configure AI behavior in Zed with .rules files, .cursorrules, CLAUDE.md, AGENTS.md, and the Rules Library for project-level instructions.
 4---
 5
 6# Using Rules {#using-rules}
 7
 8Rules are prompts that can be inserted either automatically at the beginning of each [Agent Panel](./agent-panel.md) interaction, through `.rules` files available in your project's file tree, or on-demand, through @-mentioning, via the Rules Library.
 9
10## `.rules` files
11
12Zed supports including `.rules` files at the root of a project's file tree, and they act as project-level instructions that are auto-included in all of your interactions with the Agent Panel.
13
14Other 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:
15
16- `.rules`
17- `.cursorrules`
18- `.windsurfrules`
19- `.clinerules`
20- `.github/copilot-instructions.md`
21- `AGENT.md`
22- `AGENTS.md`
23- `CLAUDE.md`
24- `GEMINI.md`
25
26## Rules Library {#rules-library}
27
28The Rules Library is an interface for writing and managing rules.
29It's a full editor with syntax highlighting and all standard keybindings.
30
31You can also use the inline assistant right in the rules editor, allowing you to get quick LLM support for writing rules.
32
33### Opening the Rules Library
34
351. Open the Agent Panel.
362. Click on the Agent menu (`...`) in the top right corner.
373. Select `Rules...` from the dropdown.
38
39You can also open it by running the {#action agent::OpenRulesLibrary} action or through the {#kb agent::OpenRulesLibrary} keybinding.
40
41### Managing Rules
42
43Once a rules file is selected, you can edit it directly in the built-in editor.
44Its title can be changed from the editor title bar as well.
45
46Rules can be duplicated, deleted, or added to the default rules using the buttons in the rules editor.
47
48### Creating Rules {#creating-rules}
49
50To create a rule file, simply open the `Rules Library` and click the `+` button.
51Rules files are stored locally and can be accessed from the library at any time.
52
53For guidance on writing effective rules:
54
55- [Anthropic: Prompt Engineering](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview)
56- [OpenAI: Prompt Engineering](https://platform.openai.com/docs/guides/prompt-engineering)
57
58### Using Rules
59
60You can @-mention every rule created through the Rules Library.
61This allows you to quickly reach for reusable prompts, saving the time to type them out every time you need to use them.
62
63#### Default Rules {#default-rules}
64
65All rules in the Rules Library can be set as a default rule, which means they’re automatically inserted into context for every new Agent Panel interaction.
66
67You can set any rule as the default by clicking the paper clip icon button in the top-right of the rule editor in the Rules Library.
68
69## Migrating from Prompt Library
70
71Previously, the Rules Library was called the "Prompt Library".
72The new rules system replaces the Prompt Library except in a few specific cases, which are outlined below.
73
74### Slash Commands in Rules
75
76Previously, it was possible to use slash commands (now @-mentions) in custom prompts (now rules).
77There is currently no support for using @-mentions in rules files, however, slash commands are supported in rules files when used with text threads.
78See the documentation for using [slash commands in rules](./text-threads.md#slash-commands-in-rules) for more information.
79
80### Prompt templates
81
82Zed maintains backwards compatibility with its original template system, which allows you to customize prompts used throughout the application, including the inline assistant.
83While the Rules Library is now the primary way to manage prompts, you can still use these legacy templates to override default prompts.
84For more details, see the [Rules Templates](./text-threads.md#rule-templates) section under [Text Threads](./text-threads.md).