# Cursor Features and Practical Usage
📏 "Always validate APIs with zod" — you shouldn't have to retype that policy every prompt. Cursor's Rules give the AI persistent memory.
🏷️ Title: Persistent Instructions (Project/Team/AGENTS.md)
🔗 URL:
📘 Overview
Rules provide persistent, system-level instructions to Cursor's Agent. Since LLMs don't retain memory between completions, Rules supply reusable context at the prompt level. They bundle prompts, scripts, and guidance so workflows stay reusable across a team.
⚙️ How It Works
Cursor supports several kinds of Rules.
・Project Rules: `.mdc` files under `.cursor/rules`, version-controlled and scoped to your codebase.
・User Rules: global preferences defined in Cursor Settings, applied across all projects.
・Team Rules: org-wide rules managed from the dashboard (Team/Enterprise plans).
・AGENTS.md: a plain-markdown alternative in the project root or subdirectories, no frontmatter needed and nestable (more specific instructions take precedence over parent ones).
Project Rule frontmatter controls behavior: `alwaysApply: true` applies to every chat, `globs` with `alwaysApply: false` auto-attaches when matching files are in context, `description` only lets the Agent apply it when relevant, and with none of these it applies only via `@`-mention.
🛠️ Practical Usage
・Scope rules to file types with globs, e.g. `src/**/*.tsx`, comma-separating multiple patterns. This auto-applies "always validate APIs with zod" whenever matching files are edited.
・Generate rules in chat with `/create-rule`, or via `Cursor Settings > Rules, Commands` → "+ Add Rule."
・Example `.mdc`: a frontmatter with `globs: src/api/**/*.ts` and `alwaysApply: false`, followed by rules like "validate every incoming payload with a zod schema" and "on failure, return 400 with a unified error shape."
・For teams, remember the application order Team Rules → Project Rules → User Rules, and enforce company-wide conventions via Team Rules.
💡 Use Cases
Turn repeated policies — "validate APIs with zod," "use Conventional Commits," "structured JSON logging" — into Rules, auto-applied only to matching files via globs. Check them into Git so the whole team benefits from the same conventions.
⚠️ Caveats
Keep each rule under 500 lines and split larger ones. Avoid copying style guides (use linters), and prefer referencing files over duplicating content. Target frequent patterns, not rare edge cases. Note that User Rules apply only to Agent (Chat) — not to Inline Edit, other AI features, or Cursor Tab.
#
Cursor# #
AICoding#