2026-09-15
Cursor rules best practices: write rules your agent won't ignore
Cursor Rules (.cursorrules) only work if the agent can follow them. Most teams write a wall of text and wonder why nothing changes.
Be specific and actionable
Replace "write clean code" with "run pnpm lint before marking a task done." Agents follow concrete commands far better than adjectives.
Keep it short
The rules are injected into context on every request. A 200-line file burns tokens and buries the important bits. Aim for the load-bearing conventions only.
One rule, one concern
- Imports: barrel files only, no deep relative paths.
- Tests: co-locate next to source, name
*.test.ts. - Types: prefer inferred; explicit only at module boundaries.
Generate, then trim
Start from a scan-based draft so the rules reflect your actual repo, then cut anything generic. Generate Cursor rules from your repository and keep the 10% that matters.