Cursor Tutorial
Learn how to use Cursor.sh for intelligent code completion and refactoring.
Getting Started with Cursor
Cursor is an AI-powered code editor that helps you write better code faster. It integrates with various AI models to provide smart completions, refactoring suggestions, and code explanations as you work.
- Install Cursor from cursor.sh
- Set up your OpenAI API key or other model provider keys
- Start coding with AI assistance and explore the features
Compatible AI Models
Cursor supports a wide range of AI models from various providers. Here's a comprehensive list of compatible models:
| Model | Provider | Features/Notes |
|---|---|---|
| Anthropic Claude Models | ||
| claude-3-5-sonnet-20241022 | Anthropic | Latest Claude 3.5 Sonnet model with specific version |
| claude-3-opus | Anthropic | Most powerful Claude model, excellent for complex coding tasks |
| claude-3-5-haiku | Anthropic | Fastest Claude model, good for simple coding tasks |
| claude-3-5-sonnet | Anthropic | Balanced performance and speed for daily coding |
| claude-3-7-sonnet | Anthropic | Latest Claude 3.7 model with improved coding capabilities |
| claude-3-7-sonnet-max | Anthropic | Claude 3.7 with extended context window |
| Google Gemini Models | ||
| gemini-2-0-flash | Fast response times with good code understanding | |
| gemini-2-0-flash-exp | Experimental flash model with additional features | |
| gemini-2-0-pro-exp | Experimental professional model with enhanced capabilities | |
| gemini-2-5-flash-preview-04-17 | Preview version of next-gen flash model | |
| gemini-2-5-pro-exp-03-25 | Experimental pro model with specific version | |
| gemini-2-5-pro-max | Maximum context window and capabilities | |
| gemini-exp-1206 | Experimental model with specific version | |
| OpenAI GPT Models | ||
| gpt-4 | OpenAI | Powerful language model with strong coding abilities |
| gpt-4.1 | OpenAI | Updated GPT-4 with incremental improvements |
| gpt-4.5-preview | OpenAI | Preview of next generation GPT-4.5 |
| gpt-4o | OpenAI | Latest "Omni" model, optimized for coding |
| gpt-4o-mini | OpenAI | Smaller, faster version of GPT-4o |
| Alternative API Models | ||
| o1 | Anthropic | Alternative API for Claude |
| o1-mini | Anthropic | Smaller alternative API for Claude |
| o1-preview | Anthropic | Preview of newer alternative API |
| o3 | Anthropic | Latest alternative API version |
| o3-mini | Anthropic | Smaller version of the latest API |
| o4-mini | Anthropic | Next-gen mini model via alternative API |
| Additional Models | ||
| cursor-small | Cursor | Lightweight model developed by Cursor |
| deepseek-r1 | DeepSeek | Specialized coding model from DeepSeek |
| deepseek-v3 | DeepSeek | Updated DeepSeek model |
| deepseek-v3.1 | DeepSeek | Latest increment of DeepSeek model |
| grok-3-beta | xAI | Beta version of Grok AI model |
| grok-3-mini-beta | xAI | Lightweight version of Grok AI model |
Note: Model availability may change as providers update their offerings. You can add custom model names in Cursor's settings.
Setting Up Your Preferred Model
To configure which AI model Cursor uses:
- Click on the settings icon in the bottom left corner
- Select "AI" from the settings menu
- Choose your preferred model from the dropdown
- Enter any required API keys for the selected provider
Pro Tip
You can switch between models based on your tasks. Use faster models like GPT-3.5 or Claude Haiku for simple completions, and more powerful models like GPT-4 or Claude Opus for complex problems.
Key Features
Smart Code Completion
Cursor provides intelligent code suggestions based on your project's context, helping you write code faster and with fewer errors.
Press Ctrl+K to trigger AI completion
AI-Powered Refactoring
Ask Cursor to improve your existing code's structure, readability, and performance without changing functionality.
"Refactor this function to be more efficient"
Real-time Suggestions
Get instant feedback and suggestions while you code, including best practices, potential bugs, and optimization tips.
"Explain potential issues in this code"
System Prompts in Cursor
System prompts are instructions that guide how AI models behave when assisting with your code. In Cursor, you can customize system prompts to:
- Make AI follow specific coding standards
- Specify preferred frameworks or libraries
- Set boundaries for AI responses
- Include project-specific context
Pro Tip
A well-crafted system prompt can dramatically improve the quality and relevance of AI assistance. Be specific about your coding style, error handling preferences, and documentation requirements.
To set a custom system prompt in Cursor:
- Click on the settings icon in the bottom left corner
- Select "AI" from the settings menu
- Scroll to the "System Prompt" section
- Edit the default prompt or add your custom instructions
Using .cursorrules Files
A .cursorrules file is a powerful way to configure AI behavior for specific projects or repositories in Cursor. This file allows you to define project-specific AI settings that will be applied automatically when working within that project.
Creating a .cursorrules File
To create a .cursorrules file:
- Create a new file named
.cursorrulesin your project root directory - Format the file using JSON syntax
- Define your custom rules and settings
Example .cursorrules File
{
"systemPrompt": "You are a helpful assistant that specializes in this project. Follow these guidelines:
- Use TypeScript for all new code
- Follow the repository's existing code style
- Use React functional components with hooks
- Document all functions with JSDoc comments",
"defaultModel": "claude-3-opus",
"excludeFromContext": [
"node_modules/**",
"build/**",
"*.log"
],
"includeInContext": [
"src/**/*.ts",
"src/**/*.tsx"
]
}
Key Configuration Options
- systemPrompt: Custom instructions for the AI when working in this project
- defaultModel: The preferred AI model to use for this project
- excludeFromContext: File patterns to exclude from AI context
- includeInContext: File patterns to prioritize in AI context
- aiCommand: Custom slash command configuration
- autoComplete: Settings for auto-completion behavior
Pro Tip
Use .cursorrules files to standardize AI behavior across your team. This ensures all developers receive consistent AI assistance that aligns with project requirements and coding standards.