typescript-code-convention — Cursor rule: what it does, how to install
A Cursor rule that pins down TypeScript code style for Next.js App Router, React, Expo, tRPC and Tailwind projects. Useful when the agent writes code inconsistently.
.cursor/rules/typescript-code-convention-cursorrules-prompt-file.mdcWhat typescript-code-convention-cursorrules-prompt-file does
The rule spells out how the agent should write code: naming conventions, TypeScript usage, syntax and formatting, error handling and validation, UI and styling. Separate sections cover Next.js and Expo, pointing to their docs for data fetching, rendering and routing.
It ships as a single prompt file. The agent is told to act as an expert in TypeScript, Node.js, Next.js App Router, React, Expo, tRPC, Shadcn UI, Radix UI and Tailwind, and every section assumes that stack. On a different framework the structure and routing advice won't match your code.
The frontmatter sets globs: **/* and alwaysApply: false. So it does not switch itself on: attach it to files or invoke it by hand, or Cursor will skip it.
What it helps with
- keep agent-written TypeScript consistent across a repo
- settle naming for variables and types before code generation
- get validation and error handling in one shape
- align component work with Tailwind and Radix UI
- apply Next.js App Router practices when generating pages
Example prompts for the agent
- Generate a React form component with validation following the project rules
- Rewrite this file to match the naming conventions in the rule
- Add error handling to this tRPC route the way the project does it
How to install typescript-code-convention-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/typescript-code-convention-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/typescript-code-convention-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/typescript-code-convention-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/typescript-code-convention-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/typescript-code-convention-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about typescript-code-convention-cursorrules-prompt-file
How do I install typescript-code-convention in Cursor?
Create .cursor/rules/typescript-code-convention-cursorrules-prompt-file.mdc at the project root and paste the rule contents into it.
What does this rule do?
It tells the agent how to handle naming, types, formatting, error handling and styling in TypeScript projects built on Next.js, React, Expo and tRPC.
Why doesn't the rule apply on its own?
The frontmatter has alwaysApply: false, so you have to attach it to files via globs or invoke it manually.
Source text
typescript-code-convention-cursorrules-prompt-file.mdc · CC0-1.0
--- description: "Cursor rules for TypeScript development with code convention integration." globs: **/* alwaysApply: false --- You are an expert in TypeScript, Node.js, Next.js App Router, React, Expo, tRPC, Shadcn UI, Radix UI, and Tailwind. Code Style and Structure: Naming Conventions: TypeScript Usage: Syntax and Formatting: Error Handling and Validation: UI and Styling: Key Conventions: Performance Optimization: Next.js Specific: Expo Specific: Follow Next.js and Expo documentation for best practices in data fetching, rendering, and routing.
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules