Course contents

Cursor rules and skills: complete setup guide (2026)

beginner4 min readUpdated
  • Cursor
On this page

What Cursor reads

Cursor gives Agent project knowledge from four places (Cursor rules docs):

  • Project rules in .cursor/rules/, committed with your code.
  • AGENTS.md at the root and in subfolders, as plain Markdown.
  • User rules, set in Customize → Rules, for personal preferences across all projects.
  • Team rules, managed from the dashboard on Team and Enterprise plans.

When they conflict, Team rules come first, then Project rules, then User rules. All applicable rules are merged.

Skills live separately in skill folders (covered below). Rules don't affect Cursor Tab autocomplete; they apply to Agent.

Project rules: .cursor/rules/*.mdc

Each project rule is an .mdc file: Markdown with a small frontmatter block. The extension matters. A plain .md file inside .cursor/rules/ is ignored by the rules system. You can organize rules into subfolders.

Project layout
.cursor/
└── rules/
    ├── project.mdc          # always apply
    ├── react.mdc            # scoped to components
    └── backend/
        └── services.mdc     # pulled in by description

The four rule types

Three frontmatter fields decide when a rule loads:

alwaysApplydescriptionglobsBehavior
trueanyanyAlways included in every chat
falseanysetAttached when a matching file is in context
falsesetnot setAgent reads the description and pulls the rule in when relevant
falsenot setnot setOnly when you @-mention it, for example @services

An always-apply rule:

.cursor/rules/project.mdc
---
alwaysApply: true
---

- Package manager is pnpm. Never run npm or yarn.
- Run `pnpm test -- <file>` for the files you changed before finishing.
- Never edit anything under `src/generated/`.

A rule scoped by file pattern. globs is a comma-separated string:

.cursor/rules/react.mdc
---
description: "React component conventions for this app"
globs: "src/components/**/*.tsx, src/app/**/*.tsx"
alwaysApply: false
---

- Use named exports for components.
- Keep data fetching in Server Components; mark a file "use client" only for state or browser APIs.
- Put component tests next to the component as `*.test.tsx`.

Referencing files

You can mention a file in a rule, like @src/lib/api-template.ts. Cursor doesn't paste that file into the prompt; the agent reads it with its tools when needed. If something must always be in context, put it in the rule body.

AGENTS.md in Cursor

If you don't need frontmatter, AGENTS.md is the simpler option. Cursor supports it at the root and in subfolders. Nested files apply when the agent works on files in that folder, combined with parent files, with the more specific one taking precedence.

Skills: .cursor/skills/ and .agents/skills/

Cursor follows the Agent Skills standard (Cursor skills docs). It discovers skills from:

LocationScope
.agents/skills/Project
.cursor/skills/Project
~/.agents/skills/You, all projects
~/.cursor/skills/You, all projects

For compatibility it also reads .claude/skills/, .codex/skills/, ~/.claude/skills/ and ~/.codex/skills/.

Each skill is a folder with a SKILL.md:

.cursor/skills/release-notes/SKILL.md
---
name: release-notes
description: "Draft release notes from merged pull requests since the last tag. Use when the user asks for release notes, a changelog entry, or 'what shipped'. Not for writing commit messages."
---

# Release notes

1. Find the latest tag with `git describe --tags --abbrev=0`.
2. List merged PRs since that tag with `gh pr list --state merged --search "merged:>DATE"`.
3. Group changes into Features, Fixes and Internal.
4. Output Markdown. Don't push or publish anything.

Frontmatter fields Cursor supports:

FieldRequiredWhat it does
nameYesLowercase letters, numbers and hyphens; must match the folder name
descriptionYesWhat the skill does and when to use it; this is what Agent matches on
pathsNoGlob patterns; the skill only surfaces when the agent works with matching files
disable-model-invocationNotrue means it only runs when you invoke it with /skill-name
metadataNoYour own key-value data
icon, colorNoBadge look when the skill is used as a Custom Mode

Type / in Agent chat to run a skill by name. A skill in a nested folder, such as apps/web/.cursor/skills/, is automatically scoped to files under apps/web/.

Install a preset

npx presets-dev add nextjs --tool cursor

In an empty project this prints:

created .cursor/rules/nextjs-rules.mdc
created .cursor/skills/nextjs-code-review/SKILL.md
2 file action(s), 0 skipped. https://presets.dev

The rule uses globs for the App Router files and next.config.ts, so it attaches when you work on those files instead of loading everywhere. The skill runs when you ask for a Next.js review or type /nextjs-code-review.

If a skill with the same name already exists in .agents/skills/, the CLI skips the Cursor copy and tells you (skipped (uses shared .agents/skills/<skill>)), because Cursor would read both. Installing for Cursor together with another tool that reads .agents/skills/, such as Codex or Copilot, writes the skill there once for both.

Browse the files first: Next.js rule for Cursor and Next.js code review skill for Cursor.

Check that it loaded

  1. Open Customize in the sidebar. Rules and skills are listed with their status.
  2. Start a new Agent chat and open a file the rule's globs match.
  3. Ask a question the rule answers, for example "Where should request interception go in this app?"

Common mistakes

  • Using .md instead of .mdc in .cursor/rules/. The file is silently ignored.
  • A rule with only globs that never matches. Globs are relative to the project root. components/** won't match src/components/Button.tsx.
  • No description on an "Apply Intelligently" rule. Without it, Agent has nothing to judge relevance by.
  • Copying the same skill into .cursor/skills/ and .agents/skills/. Cursor reads both. Keep one copy.
  • Rules over 500 lines. Cursor's own guidance is to keep rules under 500 lines and split large ones.

Recap

  • Project rules are .mdc files in .cursor/rules/ with description, globs and alwaysApply.
  • AGENTS.md works at the root and in subfolders when you don't need frontmatter.
  • Skills go in .cursor/skills/ or .agents/skills/; name must match the folder.
  • Check Customize and test in a fresh chat.

Next step

Using more than one tool? Read GitHub Copilot setup next, or jump to writing rules that work.