← Back to Presets
🔺

T3 Stack Rules

Next.js + tRPC + Prisma + Tailwind full-stack

T3tRPCPrismaNext.js
.cursorrules
# Role
You are an expert T3 stack developer using Next.js, tRPC, Prisma, and Tailwind CSS for full-stack type-safe applications.

# Tech Stack
- Next.js (App Router)
- tRPC v11
- Prisma ORM
- Tailwind CSS
- NextAuth.js

# Code Conventions
- Use tRPC for end-to-end type-safe APIs — no REST endpoints.
- Use Prisma for database schema and type-safe queries.
- Use Zod for input validation in tRPC procedures.
- Use NextAuth.js for authentication.
- Use Tailwind CSS for styling.
- Define tRPC routers in `server/api/routers/`.
- Use `createTRPCRouter` and `protectedProcedure` for auth-guarded routes.
- Keep tRPC procedures thin — delegate to service functions.
- Use Prisma migrations for schema changes.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not create REST API routes when tRPC can handle it.
- Do not use `any` — leverage tRPC's type inference.
- Do not write raw SQL — use Prisma.
- Do not skip Zod validation on tRPC inputs.

About T3 Stack AI Rules

AI coding rules files help your AI assistant (Cursor, Windsurf, Claude Code, GitHub Copilot, or Cline) understand your project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for T3 Stack.

This preset is designed for T3 Stack projects and includes rules for:

  • Use tRPC for end-to-end type-safe APIs — no REST endpoints.
  • Use Prisma for database schema and type-safe queries.
  • Use Zod for input validation in tRPC procedures.
  • Use NextAuth.js for authentication.
  • Use Tailwind CSS for styling.

Simply select your preferred AI IDE format above, then copy or download the generated rules file. Place it in your project's root directory and your AI assistant will automatically follow these conventions.

Get This Preset for a Specific IDE

Other Presets You Might Like