Cursor Rules
Cursor Rules Examples (by Framework & Use Case)
By The Field Academy Editorial TeamUpdated
Good Cursor rules are short, scoped .mdc files under .cursor/rules/, one concern each, targeted with globs. Below are starting points for TypeScript/React, Python, testing, and security that you can adapt — keep them specific and example-driven so Cursor follows them.
A TypeScript / React rule
// .cursor/rules/react.mdc--- description: TypeScript & React conventions globs: ["**/*.ts", "**/*.tsx"] --- - Function components + hooks only. - Use our `@/lib/logger`, never console.log. - Co-locate component + test; name tests *.test.tsx. - Prefer server components; mark client files with "use client".
A Python rule
// .cursor/rules/python.mdc--- description: Python conventions globs: ["**/*.py"] --- - Type-hint all public functions. - Use ruff for lint/format; no unused imports. - Raise specific exceptions, never bare except.
How do I scope rules so Cursor applies them?
- Set `globs` so a rule only loads for the files it's about.
- Keep each file to one concern (style, testing, security).
- Use
alwaysApply: truesparingly — only for truly global conventions. - Prefer a one-line example over a paragraph of description.
Frequently asked questions
Where do community Cursor rules live?
The largest collection is the awesome-cursorrules repo on GitHub. Treat them as starting points and adapt to your stack — and note documented gaps in areas like ML, cloud infra, and compliance.
How many rules should a project have?
A handful of short, scoped files beats one giant rule. Split by concern and use globs; long or contradictory rules get diluted and ignored.
Sources & last verified
Cursor ships frequently. Facts verified against primary sources on June 15, 2026.