A comprehensive set of Cursor IDE rules for building modern, scalable web applications with TypeScript, Next.js App Router, and Supabase.
This repository contains carefully crafted Cursor rules that enforce best practices for:
- RSC-First Development: Server components by default, client components when needed
- Type Safety: Strict TypeScript with no
anytypes - Supabase Integration: Proper server/client patterns with RLS
- Next.js App Router: Modern routing, data fetching, and caching patterns
- UI Components: shadcn/ui + Tailwind CSS with accessibility in mind
- Security: Authorization checks, RLS enforcement, input validation
- Testing: Unit tests with Vitest, E2E with Playwright
- Performance: Optimized patterns and DX improvements
The rules are organized into logical modules:
.cursor/rules/
├── 00-role-style.mdc # Core development philosophy & style
├── 10-structure-naming.mdc # File structure & naming conventions
├── 20-env-secrets.mdc # Environment variables & secrets
├── 30-supabase.mdc # Supabase integration patterns
├── 40-nextjs-data-caching.mdc # Next.js RSC, data fetching & caching
├── 50-api-and-actions.mdc # API routes & server actions
├── 60-ui-forms.mdc # UI components & form handling
├── 70-security-and-authz.mdc # Security & authorization
├── 80-testing-and-quality.mdc # Testing strategies
├── 90-performance-and-dx.mdc # Performance & developer experience
└── 99-checklists-and-templates.mdc # Code templates & checklists
-
Copy the rules to your project:
# In your Next.js project root mkdir -p .cursor/rules cp path/to/cursorrules/.cursor/rules/* .cursor/rules/
-
Cursor will automatically apply these rules to your development workflow
These rules are optimized for projects using:
- Next.js 14+ with App Router
- TypeScript (strict mode)
- Supabase for database & auth
- Tailwind CSS + shadcn/ui
- React Hook Form + Zod
- Vitest + Playwright
// ✅ Server component by default
export default async function Page() {
const data = await supabaseServer().from('items').select('*')
return <ItemList items={data} />
}
// ✅ Client component when needed
'use client'
export function InteractiveButton() {
const [count, setCount] = useState(0)
return <button onClick={() => setCount(count + 1)}>{count}</button>
}// ✅ Server-side data access
import { supabaseServer } from '@/lib/supabase/server'
const data = await supabaseServer().from('table').select('*')
// ✅ Client-side mutations via server actions
'use server'
export async function createItem(data: FormData) {
const result = await supabaseServer()
.from('items')
.insert(validatedData)
revalidatePath('/items')
}// ✅ Validated inputs and typed responses
const Schema = z.object({ id: z.string().uuid() })
export async function GET(req: Request) {
const parsed = Schema.safeParse(params)
if (!parsed.success) {
return NextResponse.json({ error: 'Invalid input' }, { status: 422 })
}
// ... typed response
}- Consistent file naming and organization
- TypeScript strict mode configurations
- Import/export patterns
- Error handling strategies
- Server action boilerplate
- API route handler templates
- Environment variable setup
- Supabase client configuration
- RLS policy enforcement
- Input validation patterns
- Authorization checks
- Secret management
- Component testing with Vitest
- E2E testing with Playwright
- Test organization and naming
Each rule file is a standalone module. You can:
- Disable specific rules by removing the file
- Customize patterns by editing the
.mdcfiles - Add project-specific rules by creating new files
Create new .mdc files following this format:
---
description: Your rule description
globs: ["**/*.{ts,tsx}"]
alwaysApply: true
---
# YOUR RULE TITLE
- Rule description and guidelines- Variables:
isLoading/hasErrorpattern - Files: kebab-case, Components: PascalCase
- Functions: Small, composable, pure when possible
- Dates: UTC with date-fns
- No classes: Prefer functions and hooks
The rules include an automated checklist for code submissions:
- Component needs client features? Add
"use client" - Mutations use server actions with Zod validation
- Environment variables added to
/lib/env.ts - Supabase queries respect RLS policies
- UI components are accessible
- Lint, typecheck, and tests pass
- Fork this repository
- Make your changes to the rule files
- Test with a sample Next.js project
- Submit a pull request with clear descriptions
MIT License - feel free to use these rules in your projects!
These rules are designed to accelerate development while maintaining code quality and consistency across your team.