Skip to content
FeaturesPricingBlogDownload

← All posts

Cursor rules and Markdown docs as project context

Cursor rules are short .mdc files in .cursor/rules that Cursor adds to the model's context. Keep them brief and point them to Markdown docs for longer detail.

Diagram card on a light background showing Cursor rules and an architecture doc providing stack, patterns and testing context

Cursor rules are instruction files that Cursor adds to the model's context when its agent works on your project. Project rules live in .cursor/rules/ as .mdc files, each with a few lines of front matter that decide when the rule applies: always, for matching files, when the agent judges it relevant, or only when you mention it. Rules work well when they are short. The longer material they depend on, such as architecture notes, API conventions and runbooks, is better kept as ordinary Markdown docs in the repository, which the rules point to and the agent reads when it needs them.

This post covers the rule types, the front matter fields, how rules and docs divide the work, and how to keep both readable by tools other than Cursor.

What kinds of Cursor rules are there?

Cursor's rules documentation (checked November 2026) lists four:

Type Where it lives Scope
Project rules .cursor/rules/*.mdc, in the repository This codebase; shared through version control
User rules Cursor's settings (Customize > Rules in the current docs) All your projects; used by Agent (Chat)
Team rules The Cursor dashboard, on Team and Enterprise plans Everyone on the team
AGENTS.md The project root, and subdirectories This codebase; plain Markdown, no metadata

When rules from different levels apply, the documentation gives the precedence as Team rules, then Project rules, then User rules. When a rule applies, "rule contents are included at the start of the model context." The FAQ adds that rules "do not impact Cursor Tab or other AI features", so they shape the agent, not autocomplete.

How do you write a project rule?

Create a file in .cursor/rules/ with the .mdc extension. The documentation is specific about this: "Project rules must use the .mdc extension," and a plain .md file in that folder is ignored by the rules system because it has no front matter. Subfolders are allowed, such as .cursor/rules/frontend/components.mdc.

Each rule has front matter with up to three fields, description, globs and alwaysApply, followed by the rule text:

---
description: Conventions for API route handlers and request validation
globs: src/api/**/*.ts
alwaysApply: false
---

- Validate every request body with the schemas in `src/api/schemas/`.
- Return errors in the shape described in `docs/api-errors.md`.
- New endpoints need a test in `src/api/__tests__/`.

You can also type /create-rule in the agent and describe the rule; Cursor writes the file with the front matter filled in.

When does a rule apply?

The combination of fields sets the mode. These are the four modes as the documentation maps them:

Mode Front matter When it is used
Always Apply alwaysApply: true Every agent request; globs and description are ignored
Apply Intelligently alwaysApply: false, a description, no globs When the agent judges the description relevant
Apply to Specific Files alwaysApply: false, globs set When files matching the pattern are involved
Apply Manually alwaysApply: false, no description, no globs Only when you @-mention it, e.g. @api-routes

The description does real work in the second mode: it is what the agent reads to decide whether the rule is relevant. Write it as what the rule covers and when it matters, not as a title. "Conventions for API route handlers and request validation" helps the agent decide; "API rules" does not. The same idea applies to front matter in general, covered in YAML front matter for AI.

Use Always Apply sparingly. Every always-on rule takes context on every request, whether or not the task needs it.

What belongs in a rule, and what belongs in a Markdown doc?

Rules hold short, direct instructions. Docs hold explanation and detail. The documentation's own advice points this way: keep rules "under 500 lines", split large ones into smaller rules, and "reference files instead of copying their contents" so rules do not go stale.

Put in a rule Put in a Markdown doc
"Use the error shape in docs/api-errors.md" The error shape, with examples and the reasons
"Run pnpm test before finishing" How the test setup works and how to debug it
"Never edit src/generated/" How code generation works
Naming and file placement rules Architecture overview and history of decisions

There is one detail to know about references. The documentation notes that mentioning a file inside a rule, such as @service-template.ts, does not paste its contents into the rule; the agent reads the file with its tools when it needs it. So a reference keeps the rule short, and anything that must be in front of the model every time has to be written in the rule body itself.

A layout that works:

repo/
  AGENTS.md                    short, tool-neutral instructions
  .cursor/
    rules/
      api-routes.mdc           globs: src/api/**
      ui-components.mdc        globs: src/components/**
  docs/
    architecture.md
    api-errors.md
    testing.md

Writing and reviewing those docs like code is covered in docs as code.

How do you keep rules useful for tools other than Cursor?

Keep the shared instructions in plain Markdown that other tools also read, and keep Cursor-specific scoping in .mdc rules.

  • AGENTS.md for the common part. Cursor reads AGENTS.md in the project root and in subdirectories; nested files are "combined with parent directories, with more specific instructions taking precedence." Codex, Claude Code and several other agents read the same file. AGENTS.md explained covers the format.
  • Docs in docs/. Any agent can open docs/api-errors.md. Content that only lives inside an .mdc body is invisible to a teammate reading the repository on GitHub.
  • Migration paths exist. Claude Code's /init command reads Cursor rules in .cursor/rules/ or a legacy .cursorrules file when it generates a CLAUDE.md, so plain, well-scoped rules carry over.

How do you keep rules from going stale?

Treat each rule as code that runs on every matching request.

  1. Start with few rules. The documentation says to "start simple" and add a rule when the agent repeats the same mistake.
  2. Check them into Git. Rule changes then go through review like any other change.
  3. Do not copy a style guide into a rule. A linter enforces formatting more reliably than prose.
  4. Delete rules for code that is gone. A rule that names a removed folder confuses the agent on every request that triggers it.
  5. Re-read the globs after a refactor. A rule scoped to src/api/** silently stops applying if the folder moves.

Editing rules and docs in Noteline

Noteline, which we make, is a Markdown editor for the docs/ half of this setup: open the repository folder (Cmd+O on a Mac, Ctrl+O on Windows and Linux) and the docs and AGENTS.md files appear in the sidebar as plain .md files, with headings, tables and fenced code formatted as you type. Hidden folders such as .cursor are skipped, and .mdc files are not listed, so edit the rules themselves in Cursor. Find in Folder (Cmd+Shift+F or Ctrl+Shift+F) searches every doc, which helps when a rule references a file you are about to rename. Noteline has no AI features of its own.

Start with one note. Keep the file.

Open a folder and write. Every note is a plain .md file, with no account to create.

Try desktop free for 14 days ↓Free on iPhone, iPad and Android →

Desktop: 14-day trial, then $9.99 once. Mobile apps: free. No account.

Keep reading

  • Markdown front matter
  • How to keep AI meeting notes as Markdown files you own
  • AI memory files: what your assistant should remember, kept in Markdown
  • An AI research workflow in Markdown: sources, summaries and claims

A Markdown note editor with everything you need

We’re listening

Tell us what you need or what gets in your way. If something isn’t working, write to us any time.

contact@noteline.io→

Product

  • Download
  • Pricing
  • Features
  • Changelog

Learn

  • Markdown syntax
  • Use cases
  • Blog

Compare

  • vs Obsidian
  • vs Notion

Support

  • Help
  • Support
  • Privacy
  • Terms

© 2026 Notelinecontact@noteline.io