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 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.
9
10## `.rules` files
11
12Zed 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.
13Other 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:
14
15- `.rules`
16- `.cursorrules`
17- `.windsurfrules`
18- `.clinerules`
19- `.github/copilot-instructions.md`
20- `AGENT.md`
21- `AGENTS.md`
22- `CLAUDE.md`
23- `GEMINI.md`
24
25## Rules Library {#rules-library}
26
27The Rules Library is an interface for writing and managing rules. It's a full editor with syntax highlighting and all standard keybindings.
28
29You can use the inline assistant right in the rules editor, allowing you to automate and rewrite rules.
30
31### Opening the Rules Library
32
331. Open the Agent Panel.
342. Click on the Agent menu (`...`) in the top right corner.
353. Select `Rules...` from the dropdown.
36
37You can also reach it by running {#action agent::OpenRulesLibrary} in the command palette or through the {#kb agent::OpenRulesLibrary} keybinding.
38
39### Managing Rules
40
41Once 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.
42
43Rules can be duplicated, deleted, or added to the default rules using the buttons in the rules editor.
44
45### Creating Rules {#creating-rules}
46
47To 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.
48
49For guidance on writing effective rules:
50
51- [Anthropic: Prompt Engineering](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview)
52- [OpenAI: Prompt Engineering](https://platform.openai.com/docs/guides/prompt-engineering)
53
54### Editing the Default Rules {#default-rules}
55
56Zed allows you to customize the default rules used when interacting with LLMs.
57Or to be more precise, it uses a series of rules that are combined to form the default rules.
58
59Default rules are included in the context of every new thread automatically.
60You can also manually add other rules (that are not flagged as default) as context using the `@rule` command.
61
62## Migrating from Prompt Library
63
64Previously, the Rules Library was called the "Prompt Library".
65The new rules system replaces the Prompt Library except in a few specific cases, which are outlined below.
66
67### Slash Commands in Rules
68
69Previously, it was possible to use slash commands (now @-mentions) in custom prompts (now rules).
70There is currently no support for using @-mentions in rules files, however, slash commands are supported in rules files when used with text threads.
71See the documentation for using [slash commands in rules](./text-threads.md#slash-commands-in-rules) for more information.
72
73### Prompt templates
74
75Zed maintains backwards compatibility with its original template system, which allows you to customize prompts used throughout the application, including the inline assistant.
76While the Rules Library is now the primary way to manage prompts, you can still use these legacy templates to override default prompts.
77For more details, see the [Rules Templates](./text-threads.md#rule-templates) section under [Text Threads](./text-threads.md).