Scope matches the files
Use a precise glob for file-specific guidance; reserve always-on rules for truly universal constraints.
Rule builder
Cursor project rules live in .cursor/rules. A strong rule is narrow, concrete, and easy to verify—not a second README or a collection of vague preferences.
Save the example as an .mdc file under .cursor/rules/, then replace the scope, commands, and standards with facts from your repository.
---
description: Standards for API route changes
globs:
- "src/app/api/**/*.ts"
alwaysApply: false
---
# API route standards
- Validate every external input before using it.
- Return structured errors with an appropriate HTTP status.
- Never log secrets, tokens, or complete personal records.
- Add or update tests for success and failure paths.
- Run `pnpm test` before marking the change complete.
Use a precise glob for file-specific guidance; reserve always-on rules for truly universal constraints.
Replace words like “clean” or “robust” with commands, thresholds, patterns, and observable outcomes.
Confirm paths, package names, framework versions, and scripts against the actual codebase.
Split unrelated concerns so the agent receives only the context relevant to the task.
Call out sensitive paths, data handling rules, approval requirements, and prohibited actions.
A contradictory example is often followed more readily than an abstract instruction.
Cursor's documentation treats the root .cursorrules file as a legacy format. Existing examples can still be useful for their content, but new rules should use project rule files so they can be scoped and composed.