Skip to main content
rule

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.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/typescript-code-convention-cursorrules-prompt-file.mdc
Open on GitHub

What 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.mdc

Frontmatter: description, globs, alwaysApply

Step 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

Similar IDE rules

All IDE rules for Programming languages →

From the same set68

typescript A Cursor rule that pins down how the agent writes TypeScript: types, naming, error handling. Useful when several people touch the same codebase. ★ 41,011repo stars typescript-vite-tailwind-cursorrules-prompt-file A Cursor rule that pins down TypeScript code style for Vue projects built with Vite and styled with Tailwind. Useful when you want the agent's output to stay predictable. ★ 41,011repo stars typescript-nodejs-nextjs-react-ui-css-cursorrules- A Cursor rule that pins down how the agent writes TypeScript, Next.js App Router, React and Tailwind code. Useful when generated components drift from your conventions. ★ 41,011repo stars typescript-nextjs-supabase-cursorrules-prompt-file A Cursor rule that keeps TypeScript work on Next.js App Router and Supabase consistent: server components first, Shadcn UI, Tailwind. ★ 41,011repo stars tauri-svelte-typescript-guide-cursorrules-prompt-f A Cursor rule that sets how the agent writes desktop apps with Tauri: Svelte on the frontend, TypeScript for types. ★ 41,011repo stars tanstack-router A Cursor rule that sets agent conventions for TanStack Router v1: file-based routes, typed params and loader-based data fetching. ★ 41,011repo stars tanstack-query-v5-cursorrules-prompt-file A Cursor rule that tells the agent how to write TanStack Query v5 code: query keys, mutations, optimistic updates, Suspense and prefetching. ★ 41,011repo stars tailwind-react-firebase-cursorrules-prompt-file A Cursor rule that sets conventions for a mobile-first web app built with Tailwind, React and Firebase. ★ 41,011repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor