67 typescript rules available
Cursor's TypeScript collection is the largest in the directory: 67 exact matches, of which the page lists the top 50 by downloads. It mixes React, Next.js, Vue, Svelte, Prisma and Node.js rules with advanced-type topics (branded types, variance, template literal types). The file below is the shared strict-typing baseline those rules assume.
Cursor applies project rules stored as .mdc files in .cursor/rules. Each rule's frontmatter (description, globs, alwaysApply) decides whether it is always included, attached to matching files, chosen by the agent from its description, or only used when you @-mention it. Cursor also reads AGENTS.md in the project root and subdirectories for plain-Markdown instructions.
.cursor/rules/typescript.mdcStarting point, not a tested configuration for your repository. Attached when files matching the globs are in context (alwaysApply: false with globs). Review the instructions, adapt the file paths and run your project's existing checks.
--- description: "TypeScript development project conventions" globs: "**/*.ts,**/*.tsx" alwaysApply: false --- # TypeScript instructions for Cursor ## Focus for this project - Use branded types for IDs that must not be mixed (UserId vs OrderId) where the project already does. - Prefer satisfies over as when checking object literals against a type. - Export types from the module that owns them; avoid a global types.ts dumping ground. ## TypeScript conventions - Keep "strict": true. Note that noUncheckedIndexedAccess is a separate flag that strict does not enable; respect whichever setting tsconfig.json has. - Use unknown, not any, for untrusted data and narrow it with type guards or a schema validator before use. - Model variants as discriminated unions and end switch statements with an exhaustive never check. - Do not add non-null assertions (!) or as casts to silence an error; fix the type instead and explain any cast that remains. ## Before you finish - Run npx tsc --noEmit plus the project's lint and test scripts and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - If another attached Cursor rule conflicts with this one, name both rules and follow the one with the narrower globs.
Create your own Cursor rules for TypeScript and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Cursor's docs recommend keeping individual rules under 500 lines and splitting large rules into composable ones. Cursor's documentation states that it supports AGENTS.md in the project root and in subdirectories. Use AGENTS.md for plain-Markdown instructions you also want other tools to read, and .mdc rules when you need Cursor's scoping options (globs, description-based selection, always-apply).
Documentation checked 2026-11-05: Cursor docs: Rules
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You ask Cursor's agent to model API errors and want discriminated unions with exhaustive handling rather than optional fields and casts.
Model the result of createOrder() so callers must handle validation, payment and stock errors separately.
A discriminated union Result type, createOrder returning it, a caller switch with a never-typed default, and tsc --noEmit output.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Cursor rules for strict TypeScript: compiler checks beyond strict, interfaces vs type aliases, real type guards, discriminated unions, utility types and branded IDs.