Write a focused Cursor project rule | DevPrompt Lab

Create a scoped .mdc rule with clear file patterns and actionable project conventions.

rule · AI tooling · beginner

English Tiếng Việt

A guide for Cursor rule files that avoids vague repository-wide instructions and obsolete command examples.

Reusable content

Create a Cursor project rule in `.cursor/rules/<name>.mdc`. Use YAML frontmatter with a concise description, relevant `globs`, and an intentional `alwaysApply` value. Write short, actionable instructions that apply to the matched files. Include existing commands only after verifying them. Avoid repeating general coding advice, exposing secrets, or placing unrelated product requirements in one rule. If conventions differ by directory, create separate narrowly scoped rules.

File globs: {{GLOBS}}

Project conventions: {{PROJECT_CONVENTIONS}}

Verified commands: {{COMMANDS}}

How to use it

Check the current Cursor documentation and repository's existing `.cursor/rules` files before creating or replacing a rule.

Example

---

description: PHP API conventions

globs: backend/src/**/*.php

alwaysApply: false

---

Use the existing Http response helpers and parameterized PDO queries.