Guide

Cursor Rules: Complete Guide to Customizing Your AI IDE

A practical guide to Cursor Rules: how to write and use .cursorrules to shape how Cursor's AI behaves in your projects.

By AI Coding Tools Directory2026-02-2810 min read
Last reviewed: 2026-02-28
ACTD
AI Coding Tools Directory

Editorial Team

The AI Coding Tools Directory editorial team researches and reviews AI-powered development tools to help developers find the best solutions for their workflows.

Cursor Rules are instructions stored in .cursorrules or Settings that customize how Cursor's AI behaves in your projects -- enforcing coding style, testing conventions, framework patterns, and constraints. They apply to Composer, Agent mode, and chat across all models. This guide explains how to write and use them effectively.

Cursor logo
CursorFreemium

The AI-native code editor with $1B+ ARR, 25+ models, and background agents on dedicated VMs

TL;DR

  • Place rules in .cursorrules at your project root for project-specific behavior, or in Settings > Rules for AI for global defaults.
  • Rules should specify concrete conventions: style, testing framework, tech stack, forbidden patterns, and file references.
  • Project rules take precedence over global rules when both exist.
  • Be specific ("Use 2-space indent. Prefer named exports.") rather than vague ("Write good code.").
  • Keep rules concise and updated as your project evolves; stale rules that contradict actual code produce worse output.

Quick Answer

Cursor Rules = instructions that tell Cursor how to code for your project. Put them in .cursorrules (project root) or Settings > Rules for AI (global). Use them for style, conventions, and constraints. Cursor

Where Rules Live

Location Scope
.cursorrules (project root) Project only
~/.cursor/rules or Settings > Rules for AI Global (all projects)
.cursor/rules/ (project) Project-specific rule files

Project rules take precedence when both exist.

What to Put in Rules

Category Example
Style "Use 2-space indent. Prefer named exports."
Testing "Write Jest tests for every new function."
Stack "This is a Next.js 15 app with App Router."
Constraints "Never use eval. No inline styles."
Patterns "Use our AuthContext for auth; do not add new auth libs."

Example .cursorrules

# Project: MyApp

- Next.js 15, TypeScript, Tailwind
- Use server components by default; add "use client" only when needed
- Write tests in Vitest; colocate with src
- No console.log in production code
- Follow our existing API patterns in /lib/api

Best Practices

Do Avoid
Be specific Vague "write good code"
Reference real paths and patterns Abstract rules with no examples
Keep rules concise Hundreds of lines of rules
Update as project evolves Stale rules that contradict code

Rules vs Other Context

  • Rules: Persistent instructions; always in context.
  • @-mentions: One-off context (files, docs, web).
  • Chat history: Conversational context.

Rules set the baseline; @-mentions add task-specific context.

Common Patterns

  • Language/framework: "TypeScript strict. React 19."
  • Testing: "Jest/Vitest. Aim for 80% coverage on new code."
  • Security: "No hardcoded secrets. Use env vars."
  • Architecture: "Feature folders. No circular imports."

Next Steps

Free Resource

2026 AI Coding Tools Comparison Chart

Side-by-side comparison of features, pricing, and capabilities for every major AI coding tool.

No spam, unsubscribe anytime.

Frequently Asked Questions

What are Cursor Rules?
Cursor Rules are instructions in .cursorrules (or Rules for AI in Settings) that tell Cursor how to behave: style, conventions, constraints. They apply per project or globally.
Where do I put Cursor Rules?
Project-level: .cursorrules in the project root. Global: Settings > Rules for AI. Project rules override global when both apply.
Can Cursor Rules improve code quality?
Yes. Rules for style, testing, and architecture help the AI match your conventions. Be specific—vague rules produce vague results.
Do Cursor Rules work with all models?
Yes. Rules are part of the system/context sent to whichever model Cursor uses. Behavior may vary slightly by model.