1+ # Project-specific rules for Cursor AI
2+ [project]
3+ name = "wishonia"
4+ framework = "next.js"
5+ version = "15.0"
6+ router = "app"
7+ style = "tailwind"
8+ typescript = true
9+
10+ # Define the project's architecture and conventions
11+ [architecture]
12+ # All page.tsx files are server components by default
13+ server_components = [
14+ "app/**/page.tsx",
15+ "app/**/layout.tsx",
16+ "app/**/template.tsx"
17+ ]
18+ client_components = [
19+ "components/**/*.tsx",
20+ "app/**/components/*.tsx"
21+ ]
22+ hooks = ["lib/hooks/**/*.ts"]
23+ utils = ["lib/**/*.ts"]
24+ config = ["config/**/*.ts"]
25+ types = ["types/**/*.ts"]
26+
27+ # Authentication patterns
28+ [auth]
29+ server_components = """
30+ Import server-side auth:
31+ import { getServerSession } from "next-auth/next"
32+
33+ Usage:
34+ const session = await getServerSession()
35+ """
36+
37+ client_components = """
38+ Import client-side auth:
39+ import { useSession } from 'next-auth/react'
40+
41+ Usage:
42+ const { data: session } = useSession()
43+ """
44+
45+ # Next.js App Router conventions
46+ [next]
47+ routing = """
48+ - Use app directory for all routes
49+ - page.tsx files are automatically server components
50+ - loading.tsx for loading states
51+ - error.tsx for error handling
52+ - layout.tsx for shared layouts
53+ """
54+
55+ server_components = """
56+ IMPORTANT: Never add 'use client' to page.tsx files
57+ - Pages are server components by default
58+ - Create separate client components for interactive elements
59+ - Import client components into server components as needed
60+ """
61+
62+ data_fetching = """
63+ - Use server components for data fetching when possible
64+ - Leverage React Server Components for better performance
65+ - Use route handlers (route.ts) for API endpoints
66+ """
67+
68+ # Database and type safety
69+ [database]
70+ prisma = """
71+ - Import types directly from Prisma client
72+ - Use Prisma-generated types for all database operations
73+ - Always prefer schema.prisma types over creating new ones
74+ Example:
75+ import { Post, User } from '@prisma/client'
76+ """
77+
78+ # Component structure rules
79+ [components]
80+ organization = """
81+ For interactive features:
82+ 1. Create client component in separate file:
83+ components/MyInteractiveComponent.tsx
84+ 2. Import into server component page:
85+ app/my-page/page.tsx
86+ """
87+
88+ client_components = """
89+ Only add 'use client' when component:
90+ - Uses hooks (useState, useEffect, etc.)
91+ - Needs browser APIs
92+ - Has user interactions
93+ - Uses client-side libraries
94+
95+ Example location:
96+ app/my-feature/components/InteractiveComponent.tsx
97+ """
98+
99+ server_components = """
100+ Keep pages as server components:
101+ - No 'use client' directive
102+ - No hooks or browser APIs
103+ - Import client components as needed
104+ - Fetch data server-side when possible
105+
106+ Example:
107+ app/my-feature/page.tsx
108+ """
109+
110+ # File patterns to ignore
111+ [ignore]
112+ patterns = [
113+ "node_modules",
114+ ".next",
115+ "build",
116+ "dist",
117+ "public/assets",
118+ ".git"
119+ ]
120+
121+ # Custom rules for the project
122+ [rules]
123+ component_patterns = """
124+ ✅ DO:
125+ - Keep pages as server components
126+ - Create separate client components for interactivity
127+ - Use Prisma types for database operations
128+ - Use proper auth imports based on component type
129+ - Use self-documenting names for variables, fields, and models
130+ - Always choose the simplest implementation to minimize complexity
131+
132+ ❌ DON'T:
133+ - Add 'use client' to page.tsx
134+ - Mix client and server code in same component
135+ - Use wrong auth import for component type
136+ - Create new types when Prisma schema types are available
137+ - Use cryptic or abbreviated names
138+ """
139+
140+ auth_patterns = """
141+ Server Components:
142+ import { getServerSession } from "next-auth/next"
143+ const session = await getServerSession()
144+
145+ Client Components:
146+ import { useSession } from 'next-auth/react'
147+ const { data: session } = useSession()
148+ """
149+
150+ # Type safety rules
151+ types = """
152+ - Use TypeScript strict mode
153+ - Import Prisma types directly from @prisma/client
154+ - Create interfaces for component props
155+ - Avoid 'any' type
156+ """
157+
158+ # Performance guidelines
159+ performance = """
160+ - Keep pages as server components when possible
161+ - Use client components only when necessary
162+ - Implement proper code splitting
163+ - Use React Suspense boundaries wisely
164+ """
165+
166+ # Testing guidelines
167+ [testing]
168+ jest = """
169+ - Always set @jest-environment node at the top of test files
170+ - Write tests that can safely run against production (so don't delete data or do cleanup)
171+ - Use real implementations instead of mocks where possible
172+ Example test header:
173+ /**
174+ * @jest-environment node
175+ */
176+ """
0 commit comments