In this article
March 11, 2025
March 11, 2025

What are Cursor Rules?

Cursor Rules are instructions or system prompts passed to the large language models (LLMs) that Cursor uses. Learn how to leverage them effectively.

Cursor Rules allow you to codify the foundational decisions in your codebase, to reduce hallucinations across agentic composer and chat sessions.

By placing these rules in special files (often in the .cursor/rules directory), you can tailor Cursor’s suggestions or completions to match your team’s coding style and best practices.

These rules attach at various points in your codebase based on file paths or patterns, allowing for extremely granular control.

Key features

Semantic descriptions and file pattern matching.

Each rule can include a description of when it should be applied. You can match entire directories or specific file types using glob patterns.

Reference files

Rules can reference other files via @file directives.

Automatic attachment

When you open or modify files that match certain rules, Cursor automatically applies them.

Getting started with Cursor rules

Creating a new Cursor Rule

In most projects, you store rules in the .cursor/rules directory. You can create a new rule via the Cursor command palette:

Cmd + Shift + P > New Cursor Rule

This will generate a template rule file where you can specify:

  • The file path or pattern the rule applies to
  • The instructions or prompts (e.g., “Use ESLint formatting for JavaScript files”)
  • Optional references to additional rule files via @file

Using the .cursorrules File (Legacy)

If you have an older project, you might see a single .cursorrules file in the repository root. While still supported, consider migrating to the newer .cursor/rules directory structure for better flexibility.

Global Rules

If you need certain rules to apply to every project you open in Cursor (e.g., always comment in English, or limit certain LLM response lengths), you can set them up in Cursor’s global settings under:

Cursor Settings > General > Rules for AI

Sharing Cursor Rules

A growing number of developers share their best practice rules through community-driven sites, such as:https://cursor.directory/

On these sites, you can browse, search, and import rule sets created by others—helping you kickstart your project with curated guidelines, or discover interesting approaches to frameworks and languages you might not have considered.

Tips and best practices

Keep your Rules granular

Instead of one massive rule file, create multiple smaller rules for each folder or file type in .cursor/rules. This improves clarity and keeps your instructions targeted.

Version control your Rules

Since .cursor/rules is just a folder with text files, you can store it in your repository to track changes over time and ensure consistency across branches.

Iterate and refine

Start with a minimal set of coding standards. As your team notices recurring challenges or style preferences, add or refine rules to address them.

This site uses cookies to improve your experience. Please accept the use of cookies on this site. You can review our cookie policy here and our privacy policy here. If you choose to refuse, functionality of this site will be limited.