Module 04
Module 04
20 min

Working with AI

Master prompting strategies and Cursor rules

The Three Ways to Talk to AI in Cursor

Cursor offers three interaction modes:

  • Chat (Cmd/Ctrl + L) — Ask questions, get explanations, plan features
  • Inline Edit (Cmd/Ctrl + K) — Select code and ask for changes
  • Composer (Cmd/Ctrl + I) — Multi-file editing and generation

Writing Effective Prompts

The quality of AI output depends heavily on how you ask. Good prompts are specific, contextual, and constrained.

Weak Prompts

  • 'Make this better'
  • 'Add a login page'
  • 'Fix the bug'
  • 'Style this nicely'

Strong Prompts

  • 'Refactor this function to use async/await instead of callbacks'
  • 'Create a login page with email/password fields, using our existing Button component'
  • 'The form submits twice when clicked. Find and fix the duplicate submission'
  • 'Add Tailwind classes for a minimal, clean look matching our existing pages'

Setting Up Cursor Rules

Cursor Rules are persistent instructions that the AI follows for every request. They save you from repeating context.

User Rules apply to all your projects. Project Rules (in .cursor/rules) apply to a specific codebase.

Common rules to set:

  • Preferred technologies (e.g., 'Use TypeScript and Tailwind CSS')
  • Coding style (e.g., 'Use functional components, avoid classes')
  • Project context (e.g., 'This is a Next.js 14 app with App Router')
  • Output preferences (e.g., 'Keep explanations brief and code-focused')

Prompting Strategies

Advanced techniques:

  • Chain of thought — Ask AI to explain its reasoning before coding
  • Incremental building — Make small changes, test, then continue
  • Reference existing code — Point to patterns already in your codebase
  • Constrain scope — Limit changes to specific files or functions

Cursor User Rules Template

Template for creating global Cursor user rules that apply across all projects

## Personal Coding Standards - Always use TypeScript when possible with strict mode enabled - Prefer single quotes for strings in JavaScript/TypeScript - Use 2-space indentation consistently - Maximum line length of 100 characters - Prefer const over let, avoid var entirely ## Code Quality Practices - Write JSDoc comments for all exported functions - Include error handling in all async operations - Use descriptive variable names over explanatory comments - Prefer early returns to reduce nesting ## React Preferences - Prefer functional components with hooks - Use React.memo for performance optimization when needed - Custom hooks should start with 'use' prefix - Keep components under 100 lines ## Tool Preferences - Use Prettier for code formatting - Prefer Tailwind CSS for styling when available - Use Zod or similar for runtime schema validation - ESLint with recommended rules

View full prompt

Cursor Project Rules Template

Template for creating .cursorrules file with project-specific coding standards

# Project: [Project Name] [Brief description of what you're building] ## Tech Stack - [Framework] (e.g., React 18 with TypeScript) - [Build tool] (e.g., Vite) - [State management] (e.g., TanStack Query, Zustand) - [Styling] (e.g., Tailwind CSS) - [Backend] (e.g., Supabase) ## Code Style & Conventions - Use functional components exclusively - File naming: kebab-case for files, PascalCase for components - Use absolute imports with @ alias for src directory - Maximum line length: 100 characters ## State Management Rules - Use [state library] for global client state - Use [data fetching library] for all server state - Never mix server state with client state ## Things to Avoid - Don't use useEffect for data fetching - Don't mutate state directly - Don't use inline styles - Don't use index as key in dynamic lists

View full prompt

Module Complete!

Great work! Continue to the next module.