AI Model Wiki

    Skip to main content
    6 min read
    Lesson 4 of 5

    Project Configuration & .cursorrules

    From the course Cursor & AI-Native Code Editors

    The .cursorrules file is your secret weapon for getting consistently high-quality AI suggestions tailored to your project's coding standards.

    What Is .cursorrules?

    A .cursorrules file in your project root tells Cursor how your project works. Every AI interaction — Tab, Cmd+K, Chat, and Composer — respects these rules. It's like a style guide that the AI actually follows.

    Example .cursorrules File

    # Project: E-commerce Platform
    # Stack: Next.js 14, TypeScript, Tailwind CSS, Prisma, PostgreSQL
    
    ## Code Style
    - Use functional components with arrow functions
    - Prefer named exports over default exports
    - Use TypeScript strict mode — no 'any' types
    - Use Tailwind classes for styling — never inline styles or CSS modules
    - Prefer server components; use 'use client' only when needed
    
    ## Naming Conventions
    - Components: PascalCase (UserProfile.tsx)
    - Utilities: camelCase (formatDate.ts)
    - Constants: SCREAMING_SNAKE_CASE
    - Database models: singular PascalCase (User, Product, Order)
    
    ## Architecture
    - API routes go in app/api/
    - Shared components in components/ui/
    - Page-specific components colocated with their page
    - Business logic in lib/ — keep components thin
    - Use Zod for all input validation
    
    ## Testing
    - Write tests for all utility functions
    - Use React Testing Library for component tests
    - Test user behavior, not implementation details
    

    Why .cursorrules Matters

    Without rules, Cursor's AI defaults to generic patterns that may not match your project. With rules:

    • Tab completions follow your naming conventions
    • Composer creates files in the right directories
    • Generated code uses your preferred libraries and patterns
    • Consistency across AI-generated and human-written code

    Indexing Your Codebase

    Cursor automatically indexes your project for codebase-aware suggestions. You can:

    • Check indexing status in Settings → Features → Codebase Indexing
    • Exclude files/folders with .cursorignore (works like .gitignore)
    • Re-index after major changes

    Custom Documentation

    Add custom docs that Cursor can reference:

    1. Settings → Features → Docs
    2. Add URLs to your team's documentation, API references, or style guides
    3. Reference them in prompts with @docs

    This is powerful for internal APIs, proprietary frameworks, or company-specific conventions.

    Privacy & Security

    Cursor offers a Privacy Mode that ensures:

    • Your code is never stored on Cursor's servers
    • Code is not used for training AI models
    • Only sent to the AI provider for the current request, then discarded

    Enable in Settings → Privacy → Privacy Mode. Essential for proprietary codebases.

    Key Takeaways

    • •.cursorrules defines project conventions that all AI features respect
    • •Include stack info, naming conventions, architecture patterns, and testing standards
    • •Cursor auto-indexes your codebase for context-aware suggestions
    • •Add custom docs for internal APIs and frameworks via Settings
    • •Privacy Mode ensures code is never stored or used for training
    0 of 5 lessons marked complete

    Progress is kept in this browser only.