Skip to main content
rule

typescript-zod-tailwind-nextjs-cursorrules-prompt- — Cursor rule

Cursor coding standard for Next.js and TypeScript: enforces functional patterns, Zod validation, Shadcn UI, and desktop-first Tailwind CSS.

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

What typescript-zod-tailwind-nextjs-cursorrules-prompt- does

This rule guides Cursor when generating TypeScript code for Next.js applications. It enforces functional, declarative patterns while disallowing classes and TypeScript enums in favor of maps and interfaces. Source files follow a fixed structure: exported component at the top, followed by subcomponents, helper functions, static data, and types.

Styling relies on Shadcn UI, Radix, and Tailwind Aria with a desktop-first responsive design. The guide minimizes useEffect and setState usage, limits the 'use client' boundary, and isolates client components behind Suspense fallbacks. Expected errors inside Server Actions must be returned as values instead of throwing exceptions. Because classes and enums are banned, object-oriented code will break these conventions.

What it helps with

  • enforce functional TypeScript interfaces over classes and enums
  • implement form validation using Zod schemas
  • restrict 'use client' directives and client-side hook usage
  • format Server Actions to return expected errors as values

Example prompts for the agent

  • Build a login form component with Zod validation and a Server Action using Shadcn UI
  • Sync this catalog filter state directly with URL search parameters
  • Create a desktop-first profile card styled with Tailwind CSS and Radix

How to install typescript-zod-tailwind-nextjs-cursorrules-prompt-

Manually: put the files in place

.cursor/rules/typescript-zod-tailwind-nextjs-cursorrules-prompt-.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-zod-tailwind-nextjs-cursorrules-prompt-

How to install typescript-zod-tailwind-nextjs-cursorrules-prompt- in Cursor?

Save the rule file to .cursor/rules/typescript-zod-tailwind-nextjs-cursorrules-prompt-.mdc in your project root.

What does this rule enforce?

It enforces functional TypeScript without classes or enums, desktop-first Tailwind CSS, Zod form validation, and server-first Next.js architecture.

How are errors handled according to this rule?

Expected errors are modeled as return values in Server Actions, while unexpected failures are caught by React Error Boundaries.

Source text

typescript-zod-tailwind-nextjs-cursorrules-prompt-.mdc · CC0-1.0
---
description: "Cursor rules for TypeScript development with Zod, Tailwind, and Next.js integration."
globs: **/*
alwaysApply: false
---
# Coding Style Guide

Code Style and Structure:
- Write concise, technical TypeScript code with accurate examples
- Use functional and declarative programming patterns; avoid classes
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
- Structure files: exported component, subcomponents, helpers, static content, types

Naming Conventions:
- Use lowercase with dashes for directories (e.g., components/auth-wizard)
- Favor named exports for components

TypeScript Usage:
- Use TypeScript for all code; prefer interfaces over types
- Avoid enums; use maps instead
- Use functional components with TypeScript interfaces
- Use Zod for form validation

Syntax and Formatting:
- Use the "function" keyword for pure functions
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
- Use declarative JSX

Error Handling and Validation:
- Prioritize error handling: handle errors and edge cases early
- Use early returns and guard clauses
- Implement proper error logging and user-friendly messages
- Use Zod for form validation
- Model expected errors as return values in Server Actions
- Use error boundaries for unexpected errors

UI and Styling:
- Use Shadcn UI, Radix, and Tailwind Aria for components and styling
- Implement responsive design with Tailwind CSS; use a desktop-first approach

Performance Optimization:
- Minimize 'useEffect', and 'setState'; favor React Remix Components (RSC)
- Wrap client components in Suspense with fallback
- Use dynamic loading for non-critical components
- Optimize images: use WebP format, include size data, implement lazy loading

Key Conventions:
- Use proper URL search parameter state management
- Optimize Web Vitals (LCP, CLS, FID)
- Limit 'use client'

When React Server Components (RSC) are used:
- Favor server components and Next.js SSR
- Use only for Web API access in small components
- Avoid for data fetching or state management

Follow React Remix docs for Data Fetching, Rendering, and Routing

Follow Next.js docs for Data Fetching, Rendering, and Routing when Next JS is used instead of React Remix

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set234

The whole set →
unity-cursor-ai-c-cursorrules-prompt-file A Cursor rule that briefs the assistant on a Unity game project in C#: modular code, responsive mechanics, real-time performance. ★ 41,024repo stars uikit-guidelines-cursorrules-prompt-file A rule that enforces programmatic Swift UIKit layouts without Storyboards. It standardizes SnapKit for Auto Layout, isolates data models from UI views, and handles events with closures. ★ 41,024repo stars typo3cms-extension-cursorrules-prompt-file This rule guides Cursor through TYPO3 CMS extension work, from PHP structure to tests and documentation. Use it when an agent is designing a new extension. ★ 41,024repo stars 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,024repo stars typescript-vuejs-cursorrules-prompt-file A Cursor rule that tells the agent how to write TypeScript inside Vue.js projects. Useful when you want edits across components to follow the same conventions. ★ 41,024repo 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,024repo stars typescript-shadcn-ui-nextjs-cursorrules-prompt-fil Sets TypeScript, React Server Component, and shadcn/ui coding standards for Next.js in Cursor. Helpful when building mobile-first interfaces with Tailwind CSS and Radix. ★ 41,024repo stars typescript-react-nextui-supabase-cursorrules-promp This rule gives an agent context for a TypeScript app built with React, NextUI, and Supabase. Use it when working on the UI, user dashboard, or authentication flows. ★ 41,024repo 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