Спеціально для каналу Сашко пише код
Chapter 03 · A different philosophy

Cursor Rules.
Four modes, four jobs.

Rules live in .cursor/rules/ and use .mdc files. As of Cursor 2.2, the format transitions toward folders with RULE.md.

Frontmatter

Three fields combine into four activation modes.

A rule's frontmatter exposes description, globs, and alwaysApply. The combination tells Cursor when the rule should enter the chat.

Always Apply
alwaysApply: true

Injected into every chat message. Globs are ignored.

Specific Files
globs set · alwaysApply: false

Auto-attaches when a referenced/open file matches the glob.

Intelligently
description only

Agent decides whether to load it based on the description.

Manually
all empty

Only loads when the user types @rule-name.

A React component example.

A rule that auto-attaches on .tsx files.

---
description: "React component standards for frontend UI files"
globs: src/components/**/*.tsx, src/components/**/*.ts
alwaysApply: false
---

# React Component Guidelines

- Define the props 'interface' at the top of the file
- Export as a named export (no default exports)
- Use Tailwind utility classes; avoid inline style={} objects
- Use TanStack Query for server state; never useEffect + fetch

@component-template.tsx
Precedence & scope

Team Rules → Project Rules → User Rules.

Cursor has four scopes layered in precedence order. Commands (a passive context, command set) is a newer surface — 2.0 added that, and the CLI ships built-in slash commands like /summarize.

🏢

Team Rules

Enterprise plans — set admin-wide, no frontmatter needed.

📦

Project Rules

Live in the repo and get committed. The format configured with the .cursor/ tree.

👤

User Rules

Apply only to Agent (Chat) and Inline Edit — and do not influence Cursor's Tab autocomplete.

Commands

Keep large rules out of 500 lines; split into composable commands. Communities like cursor.directory distribute ~3.5k-star shared packs.