Best Practices Intermediate

Get the most out of Cursor by configuring it for your team's workflow, choosing the right model for each task, protecting sensitive code with privacy mode, and following proven prompting strategies.

The .cursorrules File

The .cursorrules file is placed at the root of your project and tells Cursor's AI how to behave when working on your codebase. It is similar to Claude Code's CLAUDE.md but specific to Cursor.

.cursorrules
# Project: E-commerce Platform
# Stack: Next.js 14, TypeScript, Prisma, PostgreSQL, Tailwind CSS

You are an expert in TypeScript, Next.js App Router, and Prisma ORM.

Key Conventions:
- Use functional components with TypeScript interfaces (not types)
- Use the App Router (app/ directory), not Pages Router
- Server Components by default; add "use client" only when needed
- Use Prisma for all database operations
- Follow the repository pattern: src/repositories/
- Use Zod for all input validation

Code Style:
- Use named exports, not default exports
- Use early returns to reduce nesting
- Prefer const over let; never use var
- Use template literals for string concatenation
- Add JSDoc comments to all exported functions

Error Handling:
- Use custom error classes from src/errors/
- Always catch and log errors with structured logging
- Return appropriate HTTP status codes in API routes

Testing:
- Write tests using Vitest
- Follow Arrange-Act-Assert pattern
- Mock external services using vi.mock()
- Minimum 80% code coverage for new code
Why .cursorrules matters: Without a .cursorrules file, Cursor's AI makes generic assumptions about your coding style. With one, every suggestion, completion, and Composer edit follows your team's specific conventions. Commit this file to your repo so all team members benefit.

Choosing the Right Model

Task Recommended Model Why
Tab completion cursor-small (default) Fastest response; optimized for inline completions
Quick Cmd-K edits GPT-4o or Claude Sonnet Good balance of speed and quality for focused edits
Chat Q&A Claude Sonnet Excellent reasoning and long context for codebase questions
Complex Composer tasks Claude Opus Best quality for multi-file refactors and architecture changes
Debugging Claude Sonnet or Opus Strong reasoning about code flow and edge cases

Privacy Mode

Cursor offers a Privacy Mode that ensures your code is not stored on any servers:

Privacy Mode Details:
  • Your code is sent to AI providers for processing but not stored or used for training
  • Enable in Settings > Cursor > General > Privacy Mode
  • Available on all plans, including the free Hobby tier
  • For maximum privacy, use the Business plan with SOC 2 compliance
  • Consider using a local model via Ollama integration for the most sensitive code

Prompt Engineering for Cursor

Principle Bad Prompt Good Prompt
Be specific "Fix this" "Fix the null reference error on line 42 when user.email is undefined"
Provide context "Add validation" "Add Zod validation to the /api/users POST endpoint using the schema from @types/user.ts"
Reference patterns "Create a service" "Create OrderService following the same pattern as @services/UserService.ts"
Specify constraints "Write tests" "Write Vitest tests with at least 5 test cases covering happy path, edge cases, and error handling"

Team Workflow

  1. Commit .cursorrules to the repo

    Every team member gets consistent AI behavior when they open the project.

  2. Review AI-generated code in PRs

    Treat AI-generated code the same as human code in code review. Check for correctness, edge cases, and adherence to standards.

  3. Use Cursor for code review

    Open a PR diff in Cursor and use Chat to ask "Are there any bugs or edge cases in this diff?"

  4. Share effective prompts

    When a team member discovers a great prompt pattern, share it in your team wiki or Slack channel.

Managing Your Request Budget

Save requests by:
  • Using Tab completion (free/unlimited on most plans) instead of Chat for simple completions
  • Writing clear, specific prompts to avoid back-and-forth iterations
  • Using the "slow" model option for non-urgent tasks (does not count against fast request limits)
  • Combining multiple changes into a single Composer prompt instead of separate requests

Course Complete!

You are now equipped to use Cursor IDE like a pro. Create a .cursorrules file for your project, experiment with different models, and start building faster with AI-powered coding. Return to the course overview to review any lessons.

← Course Overview

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.