In this categoryCursor ยท 26
- How to Install Cursor and Import VS Code Settings (6 Minutes)Start
- Cursor Setup Guide: From Install to Your First AI Edit
- How to Set Up Project Rules in the .cursor/rules Folder
- How to Set Up Codebase Indexing in Cursor
- How to Enforce Project Conventions with Cursor Rules
- How to Write a Team Rule That Applies Only to Certain Files
- How to Migrate a Legacy .cursorrules File to the New Rules Folder
- How to Use Cursor Rules to Guide AI Edits
- How to Set Project Rules in Cursor
- How to Add a .cursorrules File to Steer Cursor
- How to Customize Cursor Keyboard Shortcuts
- How to Edit Multiple Files at Once with Cursor Composer
- How to Use Cursor Tab Completion Effectively
- How to Edit Code Inline with Cmd+K in Cursor
- How to Add Context to Cursor Chat with @ Mentions
- How to Choose and Switch AI Models in Cursor
- How to Add Library Docs as Context with @Docs in Cursor
- How to Generate and Maintain Tests with Cursor Composer
- How to Undo a Composer Change with Checkpoints in Cursor
- How to Use Cursor Agent Mode to Build a Feature End to End
- How to Connect an MCP Server to Cursor
- How to Refactor Across Your Whole Codebase in Cursor
- How to Query Your Database from Cursor with a Postgres MCP Server
- How to Let Cursor Run Commands Automatically (and Keep It Safe)
- How to Build a Full Feature Across Frontend and Backend with Composer
- How to Debug an MCP Server That Will Not Connect in Cursor
How to Enforce Project Conventions with Cursor Rules
Write project rules in .cursor/rules so the agent follows your conventions on every multi-file edit.
Without guidance, Cursor writes code in whatever style it defaults to, which may not match your project. Cursor Rules are short Markdown files that ride along with every prompt and tell the agent how your codebase works: which libraries to use, what to avoid, how to name things. They are especially valuable for multi-file edits, where a single bad assumption gets repeated across many files.
- A project open in Cursor
- A clear sense of two or three conventions your team always follows
- Write access to the project root
Create the rules folder
Make a .cursor/rules directory in your project root. Each rule lives in its own file with an .mdc extension. Splitting rules into focused files keeps them easy to maintain.
Write a rule
A rule file starts with a small frontmatter header that controls when it applies, followed by plain instructions. Keep instructions concrete and short. Vague rules get ignored.
---
description: Styling conventions for this project
globs: src/**/*.tsx
alwaysApply: false
---
- Use Tailwind utility classes, never inline style objects.
- Do not add new CSS files; extend the existing tokens.
- Components are function declarations, not arrow consts.
- Never use the any type.Choose how the rule applies
The frontmatter decides scope. Set alwaysApply: true for rules that should ride along on every request, or use globs so a rule only loads when matching files are in context. Glob-scoped rules keep prompts focused.
Verify the rule changed behavior
Ask Composer to add a new component. With the styling rule in place, it should reach for Tailwind utilities and a function declaration without being told in the prompt. If it ignores a rule, make the rule more specific or mark it alwaysApply.
Result: every edit Cursor proposes now respects your conventions automatically, so multi-file changes stay consistent with the rest of the codebase.
Watch related tutorials
33:42
41:18
28:05
3:12
26:54
39:10New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.