Universal .cursorrules
A battle-tested AI config for Cursor, Windsurf, or any agent that reads project rules. Sets coding standards, forbidden patterns, and response format.
15-20 min|Advanced
BuildStrategicDeveloper
Prompt Template
# Project Rules for AI-Assisted Coding # Save as: .cursorrules (Cursor) or .windsurfrules (Windsurf) or CLAUDE.md (Claude Code) ## Project Context - Project: [your project name] - Stack: [e.g., Next.js 15, TypeScript, Tailwind CSS v4, Supabase] - Architecture: [e.g., App Router, Server Components, Drizzle ORM] - Hosting: [e.g., Vercel, Railway, Fly.io] ## Coding Standards - Language: TypeScript strict mode. Never use `any`. - Styling: Tailwind utility classes only. No inline styles. No CSS modules. - Components: Functional components only. No class components. - State: Server-first. Default to server components. Add "use client" only for interactivity. - Data: Server components fetch data directly. Client components use server actions. - Files: kebab-case for filenames, PascalCase for components. - Imports: Use path aliases (@/components, @/lib). No relative paths beyond one level (../). ## Response Format - Lead with the code change, then explain. - Show complete file content for new files. - Show only the changed function/block for edits. - Never add comments that restate what the code does. - Never generate TODO or placeholder comments. ## Forbidden Patterns - No `var`. Use `const` by default, `let` only when reassigning. - No `enum`. Use `as const` objects or union types. - No wrapper components for single-use cases. - No try/catch without a specific recovery strategy. - No new package installs without stating why + checking bundle size. - No placeholder or lorem ipsum content. - No `console.log` left in production code. ## Testing - Test business logic, not UI rendering. - Use the testing framework already in the project. - Test behavior and outcomes, not implementation details. ## When Unsure - Ask before making architectural decisions. - Propose 2-3 options with trade-offs instead of picking one silently. - If a change touches more than 3 files, outline the plan before coding.
The AI reads this before every task, so it never asks you to repeat your stack choices or invent its own conventions. One-time investment, permanent payoff.
At the start of any project. Save as .cursorrules, .windsurfrules, or CLAUDE.md depending on your tool.