How to Insert Rules into Cursor & Windsurf
For Cursor
Rules in Cursor provide persistent, reusable context for the Agent and Cmd-K AI. You can create project rules (in .cursor/rules
), user rules (in settings), or use legacy .cursorrules
files. Learn more in the Cursor Docs.
Open your project in Cursor.
Press Cmd + Shift + P and search for "New Cursor Rule".
Press Cmd + Shift + P and search for "New Cursor Rule".
Choose where to store the rule:
- For project rules, select your project and Cursor will create a file in
- For user rules, go to Cursor Settings > Rules.
- For project rules, select your project and Cursor will create a file in
.cursor/rules/
.- For user rules, go to Cursor Settings > Rules.
Paste or write your rule in MDC format.
Example:
Example:
---\ndescription: My custom rule\nglobs: src/**/*.ts\n---\n- Always use snake_case for variable names.\n- Add error handling to all API calls.
Save the rule.
The rule will now be available to the Cursor Agent and Cmd-K AI, and will be applied according to its type and scope.
The rule will now be available to the Cursor Agent and Cmd-K AI, and will be applied according to its type and scope.
Tips:
- Project rules are version-controlled and can be organized in nested
.cursor/rules
folders. - Use globs to scope rules to specific files or directories.
- Use description and examples in your rules for clarity.
- You can generate rules from chat using /Generate Cursor Rules.
For Windsurf
Windsurf (Cascade) lets you define rules at the global or workspace level. Global rules apply across all workspaces, while workspace rules are specific to a project. You can use curated templates from the Windsurf team at windsurf.com/editor/directory.
Open Cascade in Windsurf.
Click the Customizations icon in the top right slider menu.
Click the Customizations icon in the top right slider menu.
Navigate to the Rules panel.
Here you can manage both global and workspace rules.
Here you can manage both global and workspace rules.
Click + Global or + Workspace to create a new rule.
- Global rules are stored in
- Workspace rules are stored in
- Global rules are stored in
global_rules.md
and apply to all workspaces.- Workspace rules are stored in
.windsurf/rules
and can use globs or natural language descriptions.Paste or write your rule.
You can use templates from the Windsurf directory for inspiration.
You can use templates from the Windsurf directory for inspiration.
Save the rule.
Rules are limited to 6000 characters each. If your global and workspace rules together exceed 12,000 characters, priority is given to global rules, then workspace rules. Any content above these limits will be truncated.
Rules are limited to 6000 characters each. If your global and workspace rules together exceed 12,000 characters, priority is given to global rules, then workspace rules. Any content above these limits will be truncated.
Tips:
- Use globs or natural language to describe when rules should apply in workspace rules.
- Keep each rule file under 6000 characters for full effect.
- Review and organize your rules to stay within the 12,000 character total limit.
- Check out curated templates at windsurf.com/editor/directory.