Memories & Rules
Explains Windsurf's memory and rules system for persisting context across conversations and defining custom Cascade behavior.
What this file does
Explains Windsurf's memory and rules system for persisting context across conversations and defining custom Cascade behavior.
When to use it
- Setting up persistent context for a multi-session project
- Defining project-specific coding guidelines for Cascade
- Creating global rules that apply across all your workspaces
- Understanding how auto-generated memories work in Windsurf
Cascade
Memories & Rules
Memories is the system for sharing and persisting context across conversations.
There are two mechanisms for this in Windsurf: Memories, which can be automatically generated by Cascade, and rules, which are manually defined by the user at both the local and global levels.
[
](https://docs.codeium.com/windsurf/memories#memories)
Memories
During conversation, Cascade can automatically generate and store memories if it encounters context that it believes is useful to remember.
Additionally, you can ask Cascade to create a memory at any time. Just prompt Cascade to “create a memory of …”.
Cascade’s autogenerated memories are associated with the workspace that they were created in and Cascade will retrieve them when it believes that they are relevant. Memories generated in one workspace will not be available in another.
Creating and using auto-generated memories do NOT consume credits
[
](https://docs.codeium.com/windsurf/memories#managing-memories)
Managing Memories
The Memories panel can be accessed at any time by clicking on “Windsurf - Settings” in the bottom-right hand corner, selecting the “Settings” tab, and clicking “Manage” next to “Memories and Rules”. Alternatively, you can access the Memories panel by clicking the three dots in the top right corner of the Cascade window, and selecting “Cascade Memories Panel”.
[
](https://docs.codeium.com/windsurf/memories#windsurfrules)
.windsurfrules
Users can explicitly define their own rules for Cascade to follow. Cascade will be aware of your rules at all times, even if you change them in the middle of your conversation, and will try its best to follow them.
Rules are defined in designated rule files:
global_rules.md - rules applied across all workspaces
.windsurfrules - rules for the local workspace that the .windsurfrules file is in
To ensure that the rules are only applied to your local project, add .windsurfrules to your project’s .gitignore.
You can find example rule templates curated by the Windsurf team at https://codeium.com/directory to help you get started.
Edit these rules files by clicking on the Windsurf - Settings menu, select the “Settings” tab, and clicking “Edit Rules” next to either Set Global AI Rules or Set Workspace AI Rules.
global_rules.md and .windsurfrules are limited to 6000 characters each. Any content above 6000 characters will be truncated and Cascade will not be aware of them.
If your window has multiple workspaces, the .windsurfrules from each workspace will be applied. If the total of your global rules and local rules exceed 12,000 characters, priority will be given to the global rules, followed by the workspace rules. Any rules beyond 12,000 characters will be truncated.
[
](https://docs.codeium.com/windsurf/memories#best-practices)
Best Practices
To help Cascade follow your rules effectively, follow these best practices:
- Keep rules simple, concise, and specific. Rules that are too long or vague may confuse Cascade.
- There’s no need to add generic rules (e.g. “write good code”), as these are already baked into Cascade’s training data.
- Format your rules using bullet points, numbered lists, and markdown. These are easier for Cascade to follow compared to a long paragraph. For example:
Copy
# Coding Guidelines
- My project's programming language is python
- Use early returns when possible
- Always add documentation when creating new functions and classes
- XML tags can be an effective way to communicate and group similar rules together. For example:
Copy
<coding_guidelines>
- My project's programming language is python
- Use early returns when possible
- Always add documentation when creating new functions and classes
</coding_guidelines>
What's inside
Two main sections: Memories (auto/manual creation, management) and.windsurfrules (global/local rules, limits, best practices).
Change this for your project
- Replace
global_rules.mdwith your own global rule file path - Replace
.windsurfruleswith your own workspace rule file name - Replace example rules like
- My project's programming language is pythonwith your actual guidelines
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Use XML tags to group related rules for better Cascade comprehension
- Format rules as bullet points or numbered lists rather than paragraphs
Related Documents
Windsurf Rules Support
Documents how to create, install, publish, and convert Windsurf AI editor rules using the PRPM package manager.
windsurf
Walks through configuring Devopness as a remote MCP server in Windsurf for AI-assisted infrastructure management.
2024-11-23-windsurf
Reviews Windsurf, an AI-powered code editor from Codeium, covering its features, usage tips, and pricing.