Cursor Rules: How .mdc Files Work, Three to Copy, and What 498 Public Rules Show
Cursor rules are markdown files that Cursor's Agent reads before it edits your code, so the same conventions hold in every chat without you retyping them. This guide takes the format from Cursor's documentation, measures two public collections of rules against that guidance, writes three rule files for the folder structure a Lovable export actually has, and reports the one controlled study on whether files like these help at all.
Updated

What are Cursor rules, and where do they live?
A Cursor rule is persistent instruction text that Cursor puts into the Agent's context. The rules documentation, read on 26 September 2026, lists four kinds, and the first is the one people mean when they say “cursor rules”:
| Where it lives | What the docs say | |
|---|---|---|
| Project Rules | .cursor/rules/*.mdc, committed with the repo | Version-controlled and scoped to the codebase; the format the rest of this page covers. |
| User Rules | Cursor settings, not in any repo | “Global to your Cursor environment. Used by Agent (Chat)” and, per the same page, “not applied to Inline Edit (Cmd/Ctrl+K)”. |
| Team Rules | The team dashboard | “Team and Enterprise plans can create and enforce rules across their entire organization”; an enforced rule “is required for all team members and cannot be disabled”. |
| AGENTS.md | Repo root, or any subdirectory | “Agent instructions in markdown format. Simple alternative to .cursor/rules”; nested files apply “when working with files in that directory”. |
Creation is two commands. The docs say to “type /create-rule in Agent and describe what you want”, after which “Agent generates the rule file with proper frontmatter and saves it to .cursor/rules”, or to add one from the Customize sidebar. Either way the result is a plain file you can also write by hand, which is what the rest of this guide does.
One thing the page does not contain, as of 26 September 2026, is any mention of the single-file .cursorrules format that older tutorials describe. The collection with the most stars on GitHub, awesome-cursorrules, still carries the old name but has converted all 257 of its files to .mdc. Treat the folder as the format and the root file as history.
How does a .mdc rule file work?
An .mdc file is markdown with a YAML header. The header has three fields, and the docs define them as: alwaysApply, a boolean that “determines if rule applies universally or conditionally”; description, a string that “explains rule purpose for Agent relevance detection”; and globs, comma-separated “file path patterns triggering auto-attachment”. The example the docs give is short enough to quote in full:
---
alwaysApply: true
---
- All source files must include the company copyright header
- When you are unsure about implementation details, read the relevant
source files before proposing changes
- Never modify generated files in the `dist/` or `build/` directoriesThe three fields combine into four application modes. The names below are the docs' names, and the trigger column is quoted from the same table:
| Frontmatter | When it attaches (docs wording) | |
|---|---|---|
| Always Apply | alwaysApply: true | Applied to every chat session. |
| Apply Intelligently | description set, no globs | “When Agent decides it's relevant based on description”. |
| Apply to Specific Files | globs set | “When file matches a specified pattern”. |
| Apply Manually | neither, or invoked by name | “When @-mentioned in chat (e.g., @my-rule)”. |
- You send a message: in Agent, not Inline Edit
- alwaysApply rules load: every session
- Globs checked: against files in play
- Descriptions read: Agent picks relevant ones
- @rule added: if you named one
Sequence assembled from the application modes and frontmatter fields on Cursor's rules page, read on 26 September 2026.
Three more lines from the docs matter in practice. “Keep rules under 500 lines.” “Split large rules into multiple, composable rules.” And “reference files instead of copying their contents”, which is the @filename.ts syntax that includes a file without pasting it. The next section shows how far public rules sit from those three lines.
What do 498 public Cursor rules actually look like?
Most guides quote the 500-line rule and move on. We cloned the two most-starred public collections and measured every file on 26 September 2026: awesome-cursorrules, community-written and converted to .mdc, and awesome-cursor-rules-mdc, whose README says its files were produced by an LLM from web search results. The script is in the site repository, so the numbers are reproducible.
| Community-written (awesome-cursorrules) | LLM-generated (awesome-cursor-rules-mdc) | |
|---|---|---|
| GitHub stars, last push | 40,839, 2026-05-30 | 3,574, 2026-05-19 |
| .mdc files | 257 | 241 |
| Median length (lines) | 69 | 307 |
| 90th percentile (lines) | 201 | 427 |
| Over the 500-line guidance | 6 files | 6 files |
| globs set to **/* (attached to every file) | 212 (82%) | 82 (34%) |
| alwaysApply: true | 1 | 0 |
| Reference a file with @path | 1 | 3 |
| Category | rules |
|---|---|
| Under 50 lines | 89 |
| 50 to 99 lines | 88 |
| 100 to 299 lines | 71 |
| 300 to 499 lines | 3 |
| 500 lines and over | 6 |
Raw line counts of every .mdc in PatrickJS/awesome-cursorrules, measured 26 September 2026 with scripts/measure-cursor-rules.mjs.
The two collections disagree by a factor of four on length. Hand-written rules cluster under 100 lines; the generated ones cluster between 100 and 500, because each is a full “best practices” essay for one library. Both stay under the 500-line limit almost everywhere, with 6 exceptions each. Where both fall short of the docs is scoping.
| Category | rules |
|---|---|
| **/* (every file) | 212 |
| .ts | 33 |
| .tsx | 21 |
| .py | 15 |
| .js | 9 |
| .txt | 7 |
| .jsx | 6 |
| .go | 6 |
| .vue | 6 |
Extensions named in the globs field of every .mdc in PatrickJS/awesome-cursorrules, brace groups expanded; one rule can name several. Measured 26 September 2026.
82% of the community rules set globs: **/*, which attaches them to every file and makes them Always Apply rules in everything but name. Only 1 file in 498 uses alwaysApply: true honestly, and 4 reference another file with @path instead of pasting. The four modes exist; the public corpus uses one of them.
Whether any of this helps is a separate question, and it has one controlled answer. Gloaguen, Mündler, Müller, Raychev and Vechev at ETH Zurich tested repository context files (AGENTS.md and equivalents) across coding agents and models on SWE-bench tasks plus a fresh issue set, in Evaluating AGENTS.md (arXiv 2602.11988, revised 23 June 2026). Their abstract: “providing context files does not generally improve task success rates, while increasing inference cost by over 20% on average”, and “while instructions in the context files are well followed by coding agents, repository overviews, although popular and recommended by model providers, are not helpful”. Their conclusion is the design rule for everything below: context files “are useful for specifying non-standard coding practices”. Write prohibitions and conventions the agent cannot infer from the code. Do not write a tour of the codebase.
Which rules should a Lovable export carry?
Lovable's Git sync documentation says you can “clone that repository, edit the code with your own IDE or coding assistant, and push the result back”, one branch at a time. Every export has the same shape, and ours is no exception: this site's previous version was built in Lovable (the current one is Next.js, which is a story for the Lovable vs Cursor page). Reading that repository gives the non-standard facts a rule should state: Vite 5 with React 18 and TypeScript 5, Tailwind 3 and shadcn/ui with 49 generated primitives in src/components/ui, a lovable-tagger plugin in vite.config.ts, a dev server pinned to port 8080, a generated Supabase client and a 332-line types.ts under src/integrations/supabase whose first line reads “This file is automatically generated. Do not edit it directly”, 23 migrations and 12 edge functions under supabase/. Three rules cover it.
1. The project rule, always on
Conventions Cursor cannot infer plus the two Git rules from Lovable's docs, which warn: “Do not force-push, rebase, or squash commits that are already on the synced branch. Lovable keeps its own copy of that branch.”
---
description: Conventions of a project exported from Lovable (Vite, React, TypeScript, Tailwind, shadcn/ui, Supabase), synced two ways with GitHub.
globs:
alwaysApply: true
---
# Lovable export
- Stack: Vite 5, React 18, TypeScript 5, Tailwind 3, shadcn/ui, Supabase JS 2. "@/" maps to "src/".
- Never edit src/integrations/supabase/client.ts or types.ts. Both are generated and say so in their first line. Regenerate types after a migration instead.
- Schema changes are new files in supabase/migrations/, never edits to old ones. Enable RLS in the same migration (see supabase-rls).
- Server-side code lives in supabase/functions/<name>/index.ts and reads secrets with Deno.env.get(). Nothing secret goes under src/.
- src/components/ui/ is shadcn output. Compose new components in src/components/; do not hand-edit the primitives.
- Keep lovable-tagger in vite.config.ts and the dev server on port 8080; Lovable's preview expects both.
- Work on a feature branch. Never force-push, rebase or squash commits already on the synced branch: Lovable keeps its own copy and edits made only in Lovable can be lost.
- After a merge, the first prompt back in Lovable reads: "I changed [files] outside Lovable to [describe the change]."2. The database rule, scoped to migrations and functions
Row-level security is where generated apps fail. Insufficient RLS in Lovable-generated projects has its own record, CVE-2025-48757, which Lovable disputes on the grounds that customers own their data protection; either way the policy has to be written, and a glob-scoped rule makes Cursor write it every time it touches supabase/. The verification-query habit comes from our build kits, whose schemas ship with the queries that proved their policies.
---
description: Row-level security for every table, and the rules for edge functions that touch data.
globs: supabase/migrations/**/*.sql, supabase/functions/**/*.ts
alwaysApply: false
---
# Database access
- Every "create table" is followed by "alter table ... enable row level security" and at least one policy, in the same migration file.
- Policies compare auth.uid() with an owner column or a membership table. Never "using (true)" on a table that holds user data.
- The service-role key is used only inside edge functions. It never appears under src/ or in a client bundle.
- Edge functions verify the caller's JWT before reading or writing and return 401 otherwise.
- After a migration, add two verification queries to the PR: one as the owner (expects rows) and one as a different user (expects zero rows).3. The landing page rule, attached by description
The one rule most exports lack. It is the checklist behind every prompt on the landing page prompts page, reduced to five lines Cursor applies when it decides a marketing page is in play.
---
description: Copy and structure rules for landing pages, waitlists and any page a visitor sees before signing up. Use when editing marketing pages under src/pages.
globs:
alwaysApply: false
---
# Landing pages
- One offer and one primary action per page. Secondary links go in the footer.
- No invented proof. No placeholder testimonials, logos or user counts; leave a "proof pending" comment instead.
- Lead capture writes to an insert-only table and stores the UTM parameters from the URL.
- The file starts with a comment naming the traffic source the page was built for.
- The headline says what the product does in plain words. No superlatives.Total: 39 lines across three files, all under the guidance by a wide margin, one Always Apply, one by glob, one by description. None describes the architecture, because Cursor can read it and the ETH result says the description would not help.
How do Cursor rules compare with Lovable knowledge, CLAUDE.md and AGENTS.md?
Every tool a Lovable builder touches has its own version of the same file. The mechanics rhyme; the limits and the scoping do not. Sources are the Cursor rules page, Lovable's knowledge documentation and Claude Code's memory documentation, all read on 26 September 2026.
| Cursor rules | Lovable knowledge | Claude Code CLAUDE.md and .claude/rules/ | AGENTS.md | |
|---|---|---|---|---|
| Where it lives | .cursor/rules/*.mdc in the repo; User and Team rules outside it | Workspace settings and Project settings, not in the repo | CLAUDE.md at the root or in .claude/, plus .claude/rules/*.md | Repo root or any subdirectory |
| Scoping to files | globs, description or manual @mention | None; project knowledge overrides workspace knowledge | paths: frontmatter in .claude/rules/, loaded “when Claude reads files matching the pattern” | Per directory: nested files apply to that directory |
| Length guidance | “Keep rules under 500 lines” | Up to 10,000 characters per level; “bullet lists and direct rules” over paragraphs | No line cap on the page; a troubleshooting entry for a CLAUDE.md that is too large | None stated by Cursor; Claude Code reads it like a CLAUDE.md |
| Read by | Cursor Agent only (not Inline Edit for User Rules) | Lovable, on every message: “reads your project knowledge, workspace knowledge, and project code” | Claude Code | Cursor, and Claude Code when no CLAUDE.md exists above the working directory |
| Enforcement | Team Rules can be enforced; project rules are context | Context | “Context, not enforced configuration”; a PreToolUse hook blocks actions | Context |
The practical consequence for a builder who moves between Lovable and Cursor: the Lovable knowledge file and the Always Apply rule should say the same things, and the file-scoped rules have no Lovable equivalent, so they live only in the repo. If Claude Code is in the mix as well, the memory docs note it reads AGENTS.md “only when you have no CLAUDE.md in your working directory or above it”, which makes AGENTS.md the one file all three tools can share. Our Claude Code commands guide covers the skills side of that setup.
What goes wrong with Cursor rules, and how do you avoid it?
- The rule is a codebase tour. The ETH study found repository overviews “are not helpful” while instructions “are well followed”. Delete the paragraph that explains what the app does and keep the bullets that say what not to do.
- Every rule is attached to every file. 82% of the community rules use
globs: **/*. Each one rides along on every request, which is how the cost the ETH study measured accrues, with none of the scoping the format offers. Set globs to the directory the rule is about. - Vague guidance. The docs' own line is “Avoid vague guidance. Write rules like clear internal docs.” “Write clean code” changes nothing; “never
using (true)on a table with user data” changes the migration. - The rule pastes a file that then drifts. Only 4 of 498 public rules use
@path. Reference the schema or the config; do not copy it. - User Rules expected in Inline Edit. The docs are explicit that User Rules “are only used by Agent (Chat)”. A convention that must hold in Cmd+K edits goes in a project rule.
- Cursor edits break the Lovable sync. A rewrite of the synced branch is the failure Lovable's docs warn about by name. The Git lines in the project rule exist so the agent never proposes one. The rest of the sync workflow is on the app builder guide, and the mistakes that cost rebuild rounds on the Lovable side are on common mistakes.
Sources
All checked on 26 September 2026. Corpus numbers reproducible with scripts/measure-cursor-rules.mjs in the site repository.
- Cursor docs: Rules
- Gloaguen et al., Evaluating AGENTS.md: Are Repository-Level Context Files Helpful for Coding Agents? (arXiv 2602.11988)
- Lovable docs: Knowledge
- Lovable docs: Sync your Lovable project code with GitHub, GitLab, or Bitbucket
- Claude Code docs: How Claude remembers your project
- CVE record: CVE-2025-48757 (MITRE)
- GitHub: PatrickJS/awesome-cursorrules
- GitHub: sanjeed5/awesome-cursor-rules-mdc
Frequently asked
What is the difference between .cursorrules and .cursor/rules?↓
How long should a Cursor rule be?↓
How many Cursor rules should a project have?↓
Do Cursor rules cost anything?↓
Can I reuse my Lovable knowledge file as a Cursor rule?↓
Should I use AGENTS.md instead of Cursor rules?↓
Related reading
- Lovable vs Cursor
Builder or editor, and where an export goes next.
- Claude Code commands and skills
The CLI agent's own instruction files.
- the Lovable app builder guide
Editor, modes, Cloud panel and GitHub sync.
- free build kits with tested RLS
The verification queries the database rule asks for.
- backend prompts for roles, jobs and RLS
Policies enforced in the database, not a dashboard.
- landing page prompts by traffic source
The checklist the landing rule condenses.
- common Lovable mistakes
Trusting generated access control is one of them.
- advanced prompting: Skills, goals and chains
Lovable's reusable instructions, compared.
- Lovable alternatives compared
Six builders, one prompt, checked prices.
- Claude Code subagents
The source-checker that found this page's moved citation.
- coding prompts
Ten prompts whose conventions become rules.
- Cursor vs Claude Code
Editor or agent, priced and measured.
- the CLAUDE.md file
Claude Code's instruction file, counted and broken.
- Claude Code prompts
The same jobs as briefs for the agent.
Written by

Marco Kohns
Founder of ProtoBites - Venture Growth Studio
Growth PM at a Silicon Valley scale-up (a16z and General Catalyst backed), ex-Techstars where he consulted 13 early-stage startups, Reforge-trained. Every prompt on this site comes out of shipping ProtoBites' own portfolio products.