Define the rules, shape the memory
1. Define the rules, shape the memory
Hi! In this video, we’ll learn how to define and control AI behavior in Cursor using Rules and Memory.2. Cursor Rules
Rules in Cursor act like a set of shared guidelines for our AI assistant. They define conventions, preferences, and workflows that guide how the AI writes, edits, and refactors code across projects.3. Types of Cursor Rules
Cursor supports four types of rules: Project Rules that live in `.cursor/rules`, scoped to our codebase. User Rules that apply across all our projects. Team Rules, shared standards managed from the dashboard. And `AGENTS.md`, a markdown-based agent instruction for lightweight configuration. Rules provide persistent context to the model. They’re included at the start of each model prompt,4. Types of Cursor Rules
helping us get consistent results.5. How do Rules work?
To create one, we can navigate to Cursor Settings and Rules. We can give it a name — for example, “html-style-guide” — and add our instructions. Let’s take the previous example of our portfolio site and add an HTML rule file written in MDC format, which is similar to Markdown. Then, we apply the settings. The `globs` property defines which files the rule applies to, while the `alwaysApply` flag controls if it’s automatically included in every model prompt. If we want to change this, we can choose from the four options available in the dropdown based on when we want the instructions to be applicable.6. Nesting Rules
We can also nest rules — for example, one rule file for our backend and another one for our frontend — and these instructions will be executed based on the type of code.7. Best practices of defining rules
When we define rules, it’s best to: Keep them focused and actionable. Split large rules into smaller ones. And include clear examples to guide the AI assistant.8. Defining Agent instructions
For simpler setups, we can use `AGENTS.md` — a markdown file placed in our project root. It defines AI behavior without complex configuration. For example, we might ask to use TailwindCSS for styling and follow the repository pattern for architecture. This approach works well for smaller or less structured projects.9. Memory in Cursor
Now, let’s talk about Memory. With Memory, Cursor automatically generates reusable rules based on preferences it picks up from our conversations with the AI assistant. It captures key details — like naming conventions or workflow preferences — to maintain consistency across sessions.10. Cursor settings
These memories aren’t saved automatically; we can review, approve, or delete them anytime from Cursor Settings, Rules and Memory.11. How are memories created?
Cursor can actually remember things from our conversations — and it does this in two ways: Sidecar observation, where a background model extracts useful details from our chats and suggests them as memories. And tool calls, where memories are saved directly when we ask the agent to do so or when it detects important details to remember for future sessions.12. How are memories created?
For instance, if we ask the Cursor Agent: “Always use the TailwindCSS classes for styling purposes. Remember this.” Cursor will save this as a memory and remember this behavior for future sessions.13. Less repetition, more creation
By combining Rules and Memory, we shape Cursor into an assistant that truly understands how we like to code — learning our habits, preferences, and project quirks — so we spend less time repeating ourselves and more time building.14. Let's practice!
Let’s practice!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.