mdskills
← Specs

.cursorrules — Custom Rules for Cursor

The .cursorrules file is a project-level configuration that tells Cursor how to write code for your specific codebase. It’s loaded into every AI interaction, giving Cursor persistent context about your project’s conventions and preferences.

What problem does it solve?

Every project has its own coding style — naming conventions, framework preferences, architectural patterns, and rules. Without explicit guidance, AI assistants default to generic patterns that may not match your codebase. A .cursorrules file ensures Cursor follows your project’s standards on every interaction.

How it works

Place a .cursorrules file at your project root. Cursor reads it automatically and applies the rules to all AI-generated code. The file is plain text with natural language instructions.

# .cursorrules
You are an expert in TypeScript, React, Next.js
App Router, and Tailwind CSS.
Key conventions:
- Use functional components with TypeScript interfaces
- Prefer server components; use 'use client' only when needed
- Use Tailwind for all styling, no CSS modules
- Name components in PascalCase, utilities in camelCase
- Always handle loading and error states
- Write concise, readable code — no over-engineering
Project structure:
- src/app/ for routes (Next.js App Router)
- src/components/ for shared UI components
- src/lib/ for utilities and data fetching

Cursor also supports .mdc rules

In addition to the global .cursorrules file, Cursor supports .cursor/rules/*.mdc files for more granular, file-pattern-specific rules. Each .mdc file can target specific file types or directories and includes frontmatter for metadata.

# .cursor/rules/react-components.mdc
---
description: Rules for React components
globs: src/components/**/*.tsx
---
All components must:
- Export a named function (not default)
- Accept props via a TypeScript interface
- Include JSDoc with a one-line description

Tips for effective rules

  • Be specific — “use Tailwind” is better than “use good styling”
  • Include your tech stack explicitly
  • Describe your project structure so the agent knows where to put files
  • Add error handling and testing preferences
  • Keep it under 2000 tokens — it’s loaded on every prompt

Similar formats in other tools

ToolRules file
Cursor.cursorrules
Claude CodeCLAUDE.md
Windsurf.windsurf/rules
Cline.clinerules
GitHub Copilot.github/copilot-instructions.md

Related specs

  • CLAUDE.md — Claude Code’s equivalent project rules file
  • AGENTS.md — cross-platform project context
  • SKILL.md — for on-demand capabilities (not always-on rules)

Cursor Documentation

Learn more about .cursorrules and rules configuration in the Cursor docs.

Read the Cursor rules documentation