Cursor rules
Cursor rules that actually change what the agent does
Cursor reads project rules from .cursor/rules, where each rule is an .mdc file with a short frontmatter block. Older repos may still have a single root .cursorrules file; new rules belong in the folder.
Reviewed Oct 17, 2026. Checked against Cursor's rules documentation.
How a rule is applied
- Always apply (
alwaysApply: true): included in every session. - Apply intelligently: the agent decides from the
description. - Apply to specific files: attached when a file matches
globs. Separate multiple patterns with commas. - Apply manually: only when you @-mention the rule in chat.
- Also read: User Rules (global, set in Customize > Rules), Team Rules on Team and Enterprise plans, and AGENTS.md files, which can be nested in subfolders.
.cursor/rules/backend.mdc
--- description: RPC service conventions for the backend globs: src/server/**/*.ts alwaysApply: false --- - Keep handlers thin; business logic lives in src/server/services. - Validate input with the shared schemas in src/server/schemas.
Cursor Team Rules
Team-wide rules managed from the Cursor dashboard. Available on Team and Enterprise plans.
- Team administrators create and manage Team Rules directly from the Cursor dashboard.
- Admins choose whether each rule is enforced. An enforced rule is required for every team member and cannot be disabled in Customize. A rule that is not enforced can be toggled off by each member under Team Rules in Customize.
- A rule with a glob pattern (for example
**/*.py) only applies when matching files are in context. A rule without a glob applies to every conversation. - Leave the enable box unchecked to save a rule as a draft that does not apply yet.
- Enabled Team Rules are included in Agent (Chat) context across all repositories and projects for the team.
- Order: Team Rules, then Project Rules, then User Rules. All applicable rules are merged, and earlier sources win when guidance conflicts.
Full rules setup guide: project rules, User Rules, Team Rules and AGENTS.md
Get Cursor rules and settings changes by email
When Cursor changes how rules, run modes or settings work, we update these pages from the docs and send a short note. One email a week at most.
Rules of thumb
- Keep each rule under 500 lines; split by topic instead.
- Reference files instead of pasting their contents.
- Write what the agent cannot infer from the code: commands that must pass, sharp edges, what not to touch.
- Plain
.mdfiles in .cursor/rules are ignored; use.mdcwith frontmatter. - Share one set of instructions across tools with AGENTS.md, which Cursor also reads.
Rule templates
Short, opinionated starting points. Copy one into .cursor/rules and edit it to match your repo.
TypeScript · React · Next.js
Next.js App Router
Server Components by default, data fetching on the server, and the App Router conventions agents most often get wrong.
TypeScript
TypeScript (strict)
Strict typing rules that stop agents from reaching for any, non-null assertions and unchecked casts.
React
React components
Component, hook and state rules that keep generated React readable and accessible.
Python 3
Python
Typing, packaging and testing rules for modern Python projects managed with uv or pip.
Python · FastAPI · Pydantic
FastAPI
Routing, validation and dependency-injection rules for FastAPI services.
Node.js · TypeScript · Fastify
Fastify
Plugin, schema and error-handling rules for Fastify APIs.
Node.js · Express
Node.js and Express
Routing, validation and error-handling rules for Express APIs.
Go
Go
Error handling, package layout and testing rules for idiomatic Go.
Rust
Rust
Error handling and safety rules for Rust crates.
Python · pandas · Jupyter
Data science notebooks and pipelines
Reproducibility rules for analysis code, notebooks and data pipelines.
Any language
Testing discipline
Make the agent prove changes with tests instead of declaring success.
Any language
Security guardrails
Baseline rules that stop agents from leaking secrets or weakening auth.
More Cursor setup guides
Sourced answers for the Cursor settings people search for most.
How to allow Cursor to run all commands: Run Everything, allowlist and sandbox
How do I let Cursor's agent run commands without asking?
Cursor Privacy Mode: telemetry, training and data retention
Does Cursor store or train on my code?
Add MCP servers to Cursor with mcp.json
How do I add an MCP server to Cursor?
Keep files out of Cursor with .cursorignore
How do I stop Cursor from reading certain files?
Cursor CLI: install, headless mode, permissions and CI
How do I set up and run the Cursor CLI, including in scripts and CI?
Cursor hooks: hooks.json, beforeShellExecution, afterFileEdit and exit codes
How do I configure hooks in Cursor to run scripts on agent events?
Cursor sandbox: sandbox.json, network allowlist and run modes
How does Cursor's agent terminal sandbox work and how do I configure it?
Cursor settings: settings.json, Cursor Settings and the ~/.cursor config files
How do I find and edit Cursor's settings files?
Cursor browser agent: @browser, browser automation and approval modes
How do I let Cursor's Agent use the built-in browser?
Cursor subagents: .cursor/agents, frontmatter, built-in Explore and Browser
How do I create and use subagents in Cursor?
Cursor telemetry and OpenTelemetry export (Privacy Mode, OTLP, Analytics API)
How do I control Cursor telemetry and export usage data to OpenTelemetry?
Cursor rules setup: project, user and Team Rules, .mdc frontmatter, globs and AGENTS.md
How do I add project rules in Cursor?