Cursor AI has transformed how developers write code. Instead of Googling syntax, copying from Stack Overflow, and wrestling with boilerplate, you describe what you want and Cursor generates it.
But there's a massive gap between developers who treat Cursor like autocomplete and those who use it as a force multiplier.
The difference? Custom rules and optimized prompts.
I've spent 200+ hours testing Cursor workflows across seven production SaaS apps. This guide shares the exact rules, prompts, and configurations that 10x my development speed.
Cursor rules are instructions that shape how the AI generates code. Think of them as a .cursorrules file that tells Cursor your preferences, conventions, and constraints.
Without rules, Cursor generates generic code: - Inconsistent naming conventions - Missing error handling - No TypeScript types - Doesn't follow your project patterns
With optimized rules, Cursor generates production-ready code: - Matches your codebase style - Includes error handling by default - Uses your preferred libraries - Follows your architectural patterns
Without rules, I asked: "Create a user signup form"
Cursor generated:
function SignupForm() {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const handleSubmit = (e) => {
e.preventDefault()
// TODO: implement signup
}
return (
<form onSubmit={handleSubmit}>
<input type="email" value={email} onChange={e => setEmail(e.target.value)} />
<input type="password" value={password} onChange={e => setPassword(e.target.value)} />
<button type="submit">Sign Up</button>
</form>
)
}
This code is technically correct but useless in production. No validation, no error states, no accessibility, no styling.
With my custom rules, same prompt:
Cursor generated:
'use client'
import { useState } from 'react'
import { signUp } from '@/app/actions/auth'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { useFormState } from 'react-dom'
export default function SignupForm() {
const [state, formAction] = useFormState(signUp, null)
return (
<form action={formAction} className="space-y-4">
<div>
<Label htmlFor="email">Email</Label>
<Input
id="email"
name="email"
type="email"
required
autoComplete="email"
aria-describedby={state?.errors?.email ? 'email-error' : undefined}
/>
{state?.errors?.email && (
<p id="email-error" className="text-sm text-red-600 mt-1">
{state.errors.email}
</p>
)}
</div>
<div>
<Label htmlFor="password">Password</Label>
<Input
id="password"
name="password"
type="password"
required
minLength={8}
autoComplete="new-password"
aria-describedby={state?.errors?.password ? 'password-error' : undefined}
/>
{state?.errors?.password && (
<p id="password-error" className="text-sm text-red-600 mt-1">
{state.errors.password}
</p>
)}
</div>
<Button type="submit" className="w-full">
Sign Up
</Button>
{state?.errors?.general && (
<p className="text-sm text-red-600 text-center">{state.errors.general}</p>
)}
</form>
)
}
Same prompt. Completely different output. This code is production-ready with proper TypeScript types, error handling, accessibility attributes, and shadcn/ui components.
That's the power of custom rules.
Here are the rules I use across all projects.
# Framework: Next.js 15 with App Router
- Use Server Components by default
- Only use 'use client' when necessary (interactivity, hooks, browser APIs)
- Prefer Server Actions over API routes for mutations
- Use proper TypeScript types throughout
# State Management
- Use React Server Components for server state
- Use URL search params for shareable state
- Use React hooks (useState, useReducer) for local UI state
- Avoid Redux/Zustand unless explicitly needed
This rule ensures Cursor generates modern Next.js patterns instead of outdated Pages Router code.
# Component Guidelines
- One component per file
- Use TypeScript interfaces for props
- Include JSDoc comments for complex components
- Use shadcn/ui components when available
- Follow this structure:
1. Imports
2. Type definitions
3. Component function
4. Export statement
# Example:
import { Button } from '@/components/ui/button'
interface MyComponentProps {
title: string
onAction: () => void
}
/**
* Displays a card with title and action button
*/
export default function MyComponent({ title, onAction }: MyComponentProps) {
return (
<div className="border p-4 rounded-lg">
<h2>{title}</h2>
<Button onClick={onAction}>Action</Button>
</div>
)
}
# Error Handling Requirements
- Always wrap async operations in try-catch
- Return user-friendly error messages
- Log errors to console in development
- Use error boundaries for component errors
- Validate user input before processing
# Server Actions must return { error?: string, data?: T }
This prevents Cursor from generating code that crashes on errors.
# Database Guidelines (Prisma)
- Always include error handling for queries
- Use transactions for multi-step operations
- Include proper TypeScript types from Prisma Client
- Use select to limit returned fields
- Add indexes for frequently queried fields
- Use proper cascading deletes
# Example:
try {
const user = await prisma.user.findUnique({
where: { id: userId },
select: { id: true, email: true, name: true },
})
if (!user) {
return { error: 'User not found' }
}
return { data: user }
} catch (error) {
console.error('Failed to fetch user:', error)
return { error: 'Database error' }
}
# Styling Guidelines
- Use Tailwind CSS utility classes
- Prefer shadcn/ui components over custom components
- Use semantic HTML (header, main, section, article)
- Include proper ARIA labels for accessibility
- Mobile-first responsive design
- Use consistent spacing scale (4, 8, 16, 24, 32, 64)
# Color Classes
- Primary: bg-blue-600 hover:bg-blue-700
- Destructive: bg-red-600 hover:bg-red-700
- Text: text-gray-900 dark:text-gray-100
# Security Requirements
- Never expose API keys or secrets in client code
- Validate all user input on the server
- Use prepared statements (Prisma handles this)
- Sanitize user-generated content before display
- Implement rate limiting on sensitive endpoints
- Use HTTPS-only cookies for sessions
- Validate user permissions before data access
# Testing Guidelines
- Write testable code (pure functions where possible)
- Avoid tight coupling to external services
- Use dependency injection for easier mocking
- Include edge cases in logic (empty arrays, null values, etc.)
Beyond rules, specific prompts dramatically improve output quality.
Bad prompt: "Create a task list"
Good prompt: "Create a task list component with: - Server Component that fetches tasks from Prisma - Client Component for task items with checkbox and delete button - Server Actions for creating, toggling, and deleting tasks - Optimistic updates using useOptimistic - Error handling and loading states - Use shadcn/ui Button and Checkbox components - TypeScript types for all props and functions"
The specific prompt gets specific output.
Bad prompt: "Improve this code"
Good prompt: "Refactor this component to: - Extract repeated logic into custom hooks - Move inline styles to Tailwind classes - Add TypeScript types for all variables - Extract magic numbers into named constants - Add error handling for async operations - Improve accessibility with ARIA labels"
Bad prompt: "Create a database schema for a blog"
Good prompt: "Create a Prisma schema for a blog with: - User model (id, email, name, createdAt) - Post model (id, title, slug, content, published, authorId, createdAt, updatedAt) - Comment model (id, content, postId, authorId, createdAt) - Proper relations (User has many Posts, Post has many Comments) - Cascade deletes (deleting User deletes their Posts) - Unique constraints on slug - Indexes on frequently queried fields (authorId, postId, published)"
Bad prompt: "Create an API route for creating posts"
Good prompt: "Create a Server Action for creating blog posts: - Accept title, content, and published status - Validate user is authenticated - Validate title is 1-200 characters - Validate content is not empty - Generate URL-safe slug from title - Check slug uniqueness, append number if needed - Insert post using Prisma transaction - Return { error?: string, data?: Post } - Revalidate /blog path on success - Include proper TypeScript types"
Bad prompt: "Create a contact form"
Good prompt: "Create a contact form with: - Client Component using useFormState for Server Action - Fields: name (required), email (required, validated), message (required, min 10 chars) - shadcn/ui Input, Textarea, and Button components - Display field-level validation errors - Disable submit button while submitting - Show success message after submission - Reset form on success - Full TypeScript types - ARIA labels for accessibility"
Creating comprehensive rules takes time. I've spent 200+ hours optimizing rules for different tech stacks.
CursorRules Pro ($14) includes production-ready rule sets for:
1. Next.js 15 Full-Stack SaaS - App Router patterns - Server Components and Server Actions - Prisma database operations - NextAuth authentication - Stripe payment integration - Email handling with React Email - 15 pages of detailed rules
2. Next.js + Supabase - Supabase client setup - Row-level security patterns - Real-time subscriptions - File upload handling - Auth best practices
3. React + TypeScript Best Practices - Component patterns - Custom hooks - State management - Performance optimization - Testing considerations
4. Tailwind + shadcn/ui - Component usage patterns - Styling conventions - Accessibility requirements - Responsive design rules
5. API Development (Node/Express) - RESTful endpoint structure - Error handling middleware - Input validation with Zod - Authentication patterns - Rate limiting
6. Database Patterns (Prisma + PostgreSQL) - Schema design best practices - Query optimization - Transaction handling - Migration strategies - Index recommendations
7. Testing (Jest + React Testing Library) - Component test patterns - Integration test structure - Mocking strategies - Coverage requirements
CursorRules Pro includes 50+ prompt templates for common tasks: - "Create CRUD operations for [model]" - "Add authentication to [route]" - "Refactor [component] for performance" - "Add TypeScript types to [file]"
Get CursorRules Pro ($14) and save 20+ hours of rule creation.
Beyond rules and prompts, these techniques multiply effectiveness.
Cursor's context window is limited. Help it focus:
Instead of: "Fix the bugs in this project"
Do this: 1. Open the specific buggy file 2. Highlight the problematic function 3. Prompt: "Fix the bug in this function where users can't submit forms when errors are present"
Narrow context = better results.
Don't expect perfect code on first generation.
Workflow: 1. Generate initial code with detailed prompt 2. Review output, identify issues 3. Prompt: "Refactor this to handle the edge case where [specific scenario]" 4. Repeat until production-ready
Use Cursor to review your own code:
Prompt: "Review this component for: - Security vulnerabilities - Performance issues - Accessibility problems - TypeScript type safety - Error handling gaps"
Cursor often catches issues you miss.
Prompt: "Add JSDoc comments to all functions in this file explaining: - Purpose - Parameters and their types - Return value - Example usage"
Instant documentation.
Prompt: "Generate Jest tests for this component covering: - Successful render with valid props - Error handling when API fails - User interactions (button clicks, form submissions) - Edge cases (empty data, null values)"
Problem: "Make this better"
Fix: "Refactor this to use Server Actions instead of API routes, add TypeScript types, and improve error handling"
Be specific.
Problem: Using generated code without review
Fix: Always review, test, and iterate. Cursor is a tool, not a replacement for judgment.
Problem: Using default Cursor without configuration
Fix: Spend 30 minutes creating rules or use CursorRules Pro.
Problem: 50-page rule documents that Cursor can't process
Fix: Keep rules concise and focused. 5-10 pages max.
Problem: Cursor generates code that doesn't match your existing patterns
Fix: Include examples of your preferred patterns in rules.
Here's what happened when I optimized Cursor usage across projects:
Before (no rules): - 6 hours to build auth flow - 12 bugs found in testing - Inconsistent error handling - Missing TypeScript types
After (with optimized rules): - 2 hours to build auth flow - 3 bugs found in testing - Consistent error handling throughout - Full TypeScript coverage
Time saved: 4 hours + debugging time
Before: - 8 hours reading Stripe docs and Stack Overflow - Webhook handling broke twice - Missing edge case handling
After: - 2 hours using CursorRules Pro Stripe templates - Webhook handling worked first try - Edge cases handled by default
Time saved: 6 hours
Before: - 5 hours manually updating schema - Broke relations in 3 places - Forgot to add indexes
After: - 1 hour using Cursor with Prisma rules - Relations automatically correct - Indexes suggested and added
Time saved: 4 hours
Total time saved across 3 projects: 14+ hours
At my consulting rate of $150/hour, that's $2,100 in value from a $14 investment.
Cursor works even better when combined with complementary tools:
LaunchFast ($59) is a Next.js SaaS starter kit with all boilerplate pre-built.
Workflow: 1. Start with LaunchFast foundation (auth, payments, database, UI) 2. Use Cursor to build custom features on top 3. Use CursorRules Pro to match LaunchFast's code patterns
This combination is unstoppable. LaunchFast handles boilerplate, Cursor handles custom logic.
PromptVault ($19) stores and organizes your best prompts.
Save prompts that work well, reuse them across projects.
Complete Bundle ($99) includes: - LaunchFast (SaaS starter) - CursorRules Pro (AI rules) - PromptVault (prompt storage) - SEO Blog Engine (content marketing) - Indie Hacker Toolkit (templates and guides)
Everything you need to build and launch SaaS products faster.
Before buying CursorRules Pro, try these basic rules:
# Basic Development Rules
## TypeScript
- Use TypeScript for all files
- Avoid `any` types
- Use interfaces for objects
- Use type for unions/primitives
## Components (React/Next.js)
- One component per file
- Use functional components
- Props should have TypeScript interfaces
- Use destructuring for props
## Styling
- Use Tailwind CSS utility classes
- Mobile-first responsive design
- Consistent spacing: 4, 8, 16, 24, 32
## Error Handling
- Wrap async operations in try-catch
- Return user-friendly error messages
- Log errors in development
## Code Quality
- Use descriptive variable names
- Add comments for complex logic
- Keep functions small (< 50 lines)
- Extract repeated code into functions
Save this as .cursorrules in your project root.
Create complete CRUD operations for [MODEL] with:
- Server Component listing all [MODEL]s with loading state
- Client Component with create/edit modal using shadcn Dialog
- Server Actions for create, update, delete operations
- Form validation using Zod
- Error handling and success messages
- Optimistic updates using useOptimistic
- TypeScript types for all operations
- Include proper Prisma queries with error handling
Refactor this component for performance:
- Memoize expensive calculations with useMemo
- Memoize callbacks with useCallback
- Add React.memo where appropriate
- Lazy load heavy components
- Optimize re-renders
- Explain each optimization
Add authentication to this Server Component:
- Check user session with auth()
- Redirect to /login if not authenticated
- Verify user has required permissions
- Return 403 if insufficient permissions
- Include proper TypeScript types
- Handle edge cases (deleted user, expired session)
Generate comprehensive Jest tests for this component:
- Test successful render with valid props
- Test all user interactions
- Test error states
- Test loading states
- Test edge cases (null, undefined, empty data)
- Use React Testing Library best practices
- Achieve 90%+ code coverage
Track these metrics to measure improvement:
Development Speed: - Time to implement features (before vs after) - Number of bugs in initial implementation - Time spent debugging
Code Quality: - TypeScript coverage percentage - Number of type errors - Linter warnings/errors
Consistency: - Code review feedback volume - Style inconsistencies across files
My results after optimizing Cursor: - 40% faster feature development - 60% fewer initial bugs - 80% reduction in TypeScript errors - Consistent code style without manual enforcement
Cursor doesn't replace developer skill. It multiplies it.
A senior developer with optimized Cursor rules outputs 2-3x more code at the same quality level.
A junior developer with good rules writes code at mid-level quality.
The key is intentional configuration. Cursor is only as good as the rules and prompts you provide.
Don't use Cursor like autocomplete. Use it like a junior developer who follows instructions perfectly.
Give it clear rules, specific prompts, and narrow context. Review and iterate on output.
That's how you 10x your development speed.
Get CursorRules Pro ($14) — Production-ready rules for Next.js, React, TypeScript, Prisma, and more. Save 20+ hours of rule creation.
Get Complete Bundle ($99) — CursorRules Pro + LaunchFast + PromptVault + 4 other tools at 60% off.
Stop fighting Cursor. Configure it properly and watch your productivity soar.
Build better software faster. The best developers aren't the ones who code the most — they're the ones who ship the most.