Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

The Cursor rules documentation publishes exactly one size limit: keep rules under 500 lines. That is the only number in the entire specification.
Everything else you have read about ideal rule length is community folklore. So is most advice about what belongs in a rule.
A Cursor rule is a markdown file of standing instructions that the agent reads before it writes anything. Where you put that file decides whether it gets read at all.
TL;DR
Cursor rules are markdown instruction files in .cursor/rules that get injected at the start of the model context. Which rule fires depends entirely on three frontmatter fields, and the most common failure is a rule that never loads rather than a rule that gives bad advice.
Project rules live in the .cursor/rules directory as .mdc files, version-controlled with your repository. The older .cursorrules file in your project root still works, but Cursor now calls it legacy.
The wording matters, because most guides overstate it.
There are four places rule content can come from, and mixing them up causes most of the confusion around this feature.
| Source | Where it lives | Travels with the repo |
|---|---|---|
| Project Rules | .cursor/rules in the project | Yes, committed to git |
| User Rules (settings) | Stored on your Cursor account | No, syncs to your machines |
| User rule files | ~/.cursor/rules on that machine | No, and does not sync |
| Team Rules | Dashboard, Team and Enterprise plans | No, managed centrally |
When two sources disagree, Cursor applies Team Rules first, then Project Rules, then User Rules. All applicable rules merge, and earlier sources win the conflict.
Cursor documents four activation types: Always Apply, Apply Intelligently, Apply to Specific Files, and Apply Manually. You do not set the type directly, because three frontmatter fields decide it for you.
Note the naming. Older guides still say Auto Attached and Agent Requested, and those strings no longer appear anywhere in Cursor's documentation.
| Type | Frontmatter that produces it | When it fires |
|---|---|---|
| Always Apply | alwaysApply: true | Every chat session, globs ignored |
| Apply to Specific Files | alwaysApply: false, globs set | A matching file is in context |
| Apply Intelligently | alwaysApply: false, description only | Agent judges it relevant |
| Apply Manually | alwaysApply: false, neither field | You @-mention the rule |
Read that table as a checklist when a rule misbehaves. An empty description plus empty globs produces a rule nobody ever invokes.
Note: Rules shape what your coding agent writes. They cannot tell you the result works. Start verifying on TestMu AI free and check the output on real browsers.
Every troubleshooting guide on this topic teaches you to check whether a rule attached. None of them checks whether the code the rule produced actually runs.
Those are different questions. A rule is an instruction, not a gate.
This is where an external verifier belongs. Kane CLI from TestMu AI validates rendered UI in a real Chrome browser from a natural-language objective, then returns a pass or fail.
There is no Cursor-specific skill today. You install the Codex CLI skill file, and Cursor picks it up through AGENTS.md, which keeps the author and the approver separate.
Setup and the full command reference live in the Kane CLI introduction documentation.
A rule is frontmatter followed by markdown. Cursor documents exactly three frontmatter fields, and there is no fourth.
The example below targets every Playwright spec in a repository, so it loads only when the agent touches test code.
---
description: Playwright test conventions for this repo
globs: tests/**/*.spec.ts, e2e/**/*.spec.ts
alwaysApply: false
---
- Use getByRole and getByLabel locators. Never use CSS or XPath selectors.
- Assert on user-visible state, not on implementation details.
- One behaviour per test. Do not chain unrelated assertions.
- Reuse the fixtures in @tests/fixtures.ts instead of writing new setup.Two details in that file are easy to miss. Separate multiple glob patterns with commas, and use @filename to pull another file into the rule's context.
The extension is not cosmetic. A plain .md file inside .cursor/rules is ignored, because it carries no frontmatter to specify the three fields.
Globs are where most rules go wrong, so it helps to see the documented patterns rather than guess at them.
| Pattern | What it matches |
|---|---|
| **/*.ts | Every TypeScript file in the project |
| src/**/*.tsx | React components under src only |
| docs/**/*.md, docs/**/*.mdx | Two patterns, comma separated |
| tailwind.config.* | One config file whatever its extension |
Cursor documents three ways to create a rule, and the one you pick makes no difference to the result.
Cursor also publishes what to leave out, which is more useful than most best-practice lists.
Cursor's documentation says almost nothing here. Testing appears twice, once as an example rule topic and once in an argument for writing fewer rules.
So treat what follows as practitioner convention rather than documented guidance. These four constraints do the most work on generated test code.
---
description: Ban flaky patterns in generated tests
globs: **/*.spec.ts, **/*.test.ts
alwaysApply: false
---
- Never use page.waitForTimeout or any fixed sleep. Wait on state.
- Never assert on a CSS class name. Assert on what the user sees.
- Every test must clean up the data it created.Scope these with globs rather than alwaysApply. Test conventions loaded into every unrelated chat waste context and dilute your other rules.
A packaged alternative exists if you would rather not maintain conventions by hand. Our walkthrough of the Playwright Skill covers installing one into Cursor agent mode.
Start with the surface you are working on. Rules only apply to Agent chat, and they never reach Tab completion, Inline Edit, or Bugbot pull request reviews.
That single documented sentence explains a large share of the complaints about rules being ignored. The rule was fine, and the surface simply never received it.
Work down this list when a rule misfires in Agent chat itself.
If none of that explains it, check what the agent actually pulled. Cursor gives the Agent a Fetch Rules tool that retrieves rules by type and description, and its output tells you which rules landed.
Most guides on this topic fill the gaps with confident guesses. It is more useful to know exactly where the documentation stops.
Each item below was checked against Cursor's published pages and is genuinely absent, not merely hard to find.
Treat advice about any of those as someone's experiment rather than a specification. That includes advice in this article.
One documented caveat deserves repeating, because rules feel more authoritative than they are. Cursor states plainly that AI guidance should not be your only security control.
Rules written as .mdc files are Cursor-specific. Most teams now run more than one agent, so portability has become the real design question.
Cursor reads two portable formats alongside its own, which gives you a genuine choice about where conventions live.
| Format | Targets specific files | Portable beyond Cursor |
|---|---|---|
| .cursor/rules .mdc | Yes, through globs | No |
| AGENTS.md | No, plain markdown only | Yes, a shared convention |
| CLAUDE.md | No, plain markdown only | Yes, also read by Claude Code |
Two behaviours matter before you pick. CLAUDE.md files are always applied to every conversation regardless of any alwaysApply setting, and nested AGENTS.md files let more specific instructions take precedence.
The direction of travel is worth watching. Cursor 2.4 ships a migrate-to-skills command described in the Cursor skills documentation, which converts dynamic rules into skills.
Skills are becoming the shared format across editors. We covered that shift for test work in our guide to agent skills, and compared two harnesses in Claude Code vs Antigravity.
Resist writing a large rule on day one. Start with the conventions your team already corrects in code review.
Cursor's own guidance on organisation is in the Cursor rules customization help, which recommends a flat structure over nested folders.
For a wider view of how these editors compare, our roundup of agentic coding CLI tools covers the terminal-native field.
A good rule makes the agent write the code you would have written. It still cannot tell you the code works.
Author
Chaitanya Sharma is an AI Product Manager at TestMu AI (formerly LambdaTest), where he builds agentic AI capabilities focused on computer vision and multi-modality, moving testing beyond static script execution toward autonomous, agent-driven workflows. Before TestMu AI he shipped 135+ features at Sprinklr for a no-code community and website builder used by Fortune 500 enterprises including Dell, Samsung, and Polestar. At Policybazaar he led the zero-to-one launch of a digital lending and insurance marketplace embedded in Bahrain's dominant payments app, building a risk-intelligence engine that compressed loan-approval times by 80%. He explored machine learning and NLP through research at the University of Cambridge, and holds a B.Tech from Delhi Technological University.
Reviewer
Anubhav Singhmaar is an AI Product Manager at TestMu AI driving Kane CLI, the command-line tool that brings browser automation to the terminal, turning natural-language flows into runs in a real Chrome browser that return pass or fail with shareable proof. He owns the roadmap and prioritization and works with engineering to ship developer-facing features. Before TestMu AI, he spent over four years at Sprinklr owning enterprise voice AI across APAC and EMEA. A mechanical engineer turned product manager, he grounds guidance in real QA workflows.
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance