Cursor rules examples work best when they encode repo-specific contracts: how to register routes, which commands prove “done,” and what the agent must never touch. This page shows layouts and snippets you can copy into.cursor/rules, then tighten against your own build and review habits. Treat every product label here as illustrative—UI and rule formats change across Cursor releases.
01
Independence note
02
What rules are for (vs one-shot prompts)
A one-shot prompt steers a single session. Project rules steer every session that loads them. Put durable, repo-wide constraints in rules; keep ticket-specific goals in the chat brief. If a sentence would still be true next month for any contributor, it belongs in rules. If it only matters for this PR, leave it in the prompt.
- Rules: indent, route registration, forbidden deploy paths, test commands, language defaults.
- Prompts: this ticket’s objective, acceptance checks, and temporary non-goals.
- Neither: secrets, production credentials, or one-off customer data.
For session briefs, see how to write a good agent prompt. For day-to-day agent habits inside the IDE, see cursor agent tips.
03
File layout patterns
Many teams keep a small set of focused rule files under.cursor/rules/ rather than one giant blob. Split by concern so you can enable, disable, or scope rules without rewriting everything:
.cursor/
rules/
project-conventions.mdc # always-on house style
frontend-pages.mdc # globs: src/pages/**/*.tsx
no-deploy.mdc # forbid wrangler/DNS unless asked
testing.mdc # how to verify changesPrefer short files with a clear “when this applies” note at the top. If a rule only matters for page components, say so—and point at an existing file as the pattern to extend. Agents follow nearby examples more reliably than abstract style essays.
04
.mdc frontmatter: globs, alwaysApply, and pitfalls
Searching for cursor mdc rules examples usually means the YAML-ish front matter on .mdc rule files—not another essay on “what rules are.” Below is a copy-ready skeleton plus common foot-guns. Exact keys and apply behavior depend on your Cursor version—confirm in current product docs; this is unofficial.
---
description: Frontend page conventions for src/pages
globs:
- src/pages/**/*.tsx
alwaysApply: false
---
# Frontend pages
- Unique H1; register the route in src/index.tsx pages[].
- Prefer extending an existing guide page over inventing a new layout.
- Keep FAQ answers short enough to mirror in JSON-LD.alwaysApply: true: house style and safety that should load often. Keep these files short—always-on novels get ignored.globs: path-scoped contracts. Prefer tight globs (src/pages/**) over**/*“just in case.”description: helps humans (and some loaders) know when the rule matters. Write the job, not marketing.
05
Cursor user rules vs project rules
Teams searching for cursor user rules vs project rulesare usually deciding what belongs in a personal preference store versus what must travel with the repository. The engineering cut is simple:
- Project rules (
.cursor/rulesin the repo): stack pins, route registry, verify commands, deploy non-goals—anything every contributor’s agent must share. - User rules (editor / account level): personal tone, preferred explanation depth, private shortcuts that should not become team policy.
If a rule would still be true for a new hire next month, it is a project rule. If it only describes how you like answers formatted, keep it as a user rule so it does not silently override teammates. Exact UI labels and discovery paths change across Cursor releases—confirm in current product docs. For task playbooks that are neither “always-on style” nor personal preference, see cursor skills examples (rules vs skills decision).
06
.cursorrules deprecated → .cursor/rules
Older writeups still mention a single root .cursorrulesfile. Many modern Cursor setups prefer a.cursor/rules/ directory with small, focused files (often with scope / front matter). If you are migrating becausecursorrules deprecated warnings or docs point you here:
- Inventory the old root file; split by concern (conventions, safety, area-scoped).
- Move durable contracts into
.cursor/rules/; delete or stub the legacy file once discovery is confirmed on your version. - Re-check apply / globs / always-on behavior after the move—do not assume one-to-one file semantics.
- Keep ticket goals out of rules; put them in the session prompt.
07
Copy-ready cursor rules examples
Adapt these templates. Replace commands, paths, and non-goals with your repo’s truth. Keep them short enough that a human will maintain them.
Project conventions (always on)
# Project conventions
- Indent with 4 spaces; do not reformat unrelated files.
- Register every indexable page in src/index.tsx pages[] (routes + sitemap).
- Prefer extending an existing page/component pattern over inventing a new layout.
- Run pnpm run build before claiming done. Do not pass --pm-on-fail to vite.
- Do not deploy, edit wrangler, or change DNS unless the user explicitly asks.Frontend / docs pages (scoped)
# Frontend page rules
# Apply when editing src/pages/** or public/assets/styles.css
- Mirror ArticleNavigation + article-hero structure from sibling EN how-to pages.
- Unique Title, Description, and a single H1 that contains the target phrase.
- Include Related reading links to sibling guides; keep bidirectional links updated.
- Optional light CSS only when matching existing card/summary styles.
- Do not invent new indexed URLs; only add paths listed in the task.Safety / non-goals
# Safety defaults
- Never commit secrets, tokens, or .env contents.
- Treat shell commands as untrusted until reviewed.
- Prefer read-only exploration before bulk edits on unfamiliar modules.
- Ask when the framework or package manager choice is ambiguous.When tools live outside the editor, pair rules with a clear tool policy in the prompt, and see the MCP server tutorial for host config and schema pitfalls.
08
Writing patterns that stick
- Imperative and testable. “Run
pnpm run build” beats “ensure quality.” - Name artifacts. Paths, array names (
pages[]), and sibling files beat vibes. - State non-goals. Agents over-help; forbid deploy, rebrand, or drive-by refactors.
- One concern per file. Split “style” from “security” so reviews stay focused.
- Point at exemplars. “Match
GoodAgentPromptPage.tsx” beats reinventing layout.
Rules degrade when they become a wishlist. If the agent still violates a rule after two sessions, either the rule is vague or a stronger nearby example is missing—fix the example first.
09
Nested .cursor/rules folders & monorepo layouts
Searching for cursor rules nested folders (or monorepo rules) usually means package-level contracts are fighting a single root rules tree. Prefer clarity over clever nesting:
- Root always-on: short house style and safety non-goals at the repo root
.cursor/rules/. - Globs before deep nesting: many teams keep one rules directory and scope with frontmatter
globs(for exampleapps/web/**) instead of inventing a second discovery tree. See .mdc frontmatter. - Package-local rules (when supported): if your Cursor build discovers nested
.cursor/rulesunder packages, keep those files thin and package-specific—do not duplicate the root novel. Re-check discovery on your version; Docs and Forum threads disagree across releases. - Monorepo pitfall: five copies of “always run the wrong package’s test command.” Name verify commands per package and point at the nearest
package.json/ workspace script. - Still no dedicated monorepo URL: this anchor is the home for nested-folder judgment. Portable cross-tool facts still belong in AGENTS.md.
repo/
AGENTS.md
.cursor/rules/
00-house.mdc # alwaysApply: true — short
10-web.mdc # globs: apps/web/**
20-api.mdc # globs: apps/api/**
apps/
web/
api/10
Anti-patterns
- Novel-length rules: nobody updates them; the agent samples inconsistently.
- Contradictions: “always refactor” next to “never touch unrelated files.”
- Secrets in rules: rules are often committed; use env stores instead.
- Product tutorials inside rules: teach workflows in docs; keep rules as contracts.
- Copying another company’s rules wholesale: wrong stack, wrong done checks.
Related reading: Windsurf rules examples · Continue rules examples · Cline rules examples · Kilo code rules examples · Amazon Q rules examples · Cursor skills examples · How to write AGENTS.md · AGENTS.md vs CLAUDE.md vs Cursor rules · Cursor agent tips · Good agent prompts · How to write CLAUDE.md · MCP server tutorial · Agent engineering notes · Codex CLI multi-config
11
FAQ
Where should I put cursor rules examples in a repo?
Most teams use a .cursor/rules/ directory with small, focused files. Exact discovery rules depend on your Cursor version— confirm in current product docs. This site’s examples are unofficial templates, not a product catalog.
How many rule files is enough?
Start with one always-on conventions file plus one scoped file for the area you edit most. Add a safety file when agents keep proposing deploy or secret-related changes. Split further only when a file becomes hard to review in one screen.
Rules vs CLAUDE.md vs a good agent prompt?
Rules (and similar project instruction files) are durable repo memory. A solid CLAUDE.md plays a similar role for Claude Code-style workflows. A good agent prompt is the per-ticket contract. Use all three intentionally; do not paste the same wall of text into every layer. Side-by-side choice notes: AGENTS.md vs CLAUDE.md vs Cursor rules. For task playbooks, see cursor skills examples.
User rules vs project rules—where should conventions live?
Put shared stack, verify commands, and safety non-goals in project rules under .cursor/rules. Keep personal tone and private preferences in user-level rules so they do not become accidental team policy. See user vs project rules above.
Is .cursorrules deprecated?
Many current setups prefer .cursor/rules/ over a single root .cursorrules file. Treat legacy root files as a migration source: split by concern, confirm discovery on your Cursor version, then remove the stale file. See .cursorrules legacy.
Where do Cursor commands fit vs rules and skills?
Searching for cursor commands examples usually means short user-invoked recipes (often under .cursor/commands), not always-on house style. Keep contracts in rules; keep richer playbooks in skills. Decision notes: cursor skills examples (commands vs skills FAQ). Prefer extending existing pages over a new thin URL.
How should nested .cursor/rules folders work in a monorepo?
Prefer root always-on plus globs for packages; add nested package rules only when your Cursor build clearly discovers them—and keep them thin. See nested folders. No separate monorepo URL on this site.
What belongs in .mdc frontmatter (globs / alwaysApply)?
Use front matter for when a rule applies: shortdescription, tight globs, andalwaysApply only for true house style. Copy-ready skeleton and pitfalls: .mdc frontmatter.
Will these templates work unchanged on every Cursor release?
No. Treat them as starting points. Re-verify file names, front matter, and apply/globs behavior after upgrades. Prefer repo-specific commands and paths over marketing phrases that age poorly.