Best Practices for Cursor
A tutorial by Cursor. Featured in the OTF curated resource library.
Configuring Cursor
Proper configuration ensures Cursor understands your project from the start.
Create .cursorrules
Add a .cursorrules file to your project root. This file tells Cursor about your tech stack, coding standards, and preferred patterns. It is read at the beginning of every agent session.
Configure .cursorignore
Like .gitignore, this file tells Cursor which files and directories to exclude from indexing. Exclude build artifacts, node_modules, and large generated files.
Set up your model preferences
Choose the right model for each task type in Cursor settings. Use faster models for autocomplete and more capable models for agent tasks.
Writing Effective Rules
Be explicit about patterns
Don't assume Cursor knows your conventions. Spell out naming patterns, file organization, and import ordering preferences.
Include anti-patterns
Tell Cursor what NOT to do. For example: 'Never use any as a TypeScript type' or 'Do not add console.log statements'.
Reference key files
Point Cursor to example files: 'For component patterns, reference src/components/UserCard.tsx'.
Context Management
Cursor's agent mode works best when it has the right context. Use @file references to explicitly include relevant files in your prompt. Use @folder to include entire directories.
For complex tasks, provide a brief overview of the architecture before asking for changes. The agent performs better when it understands how components relate to each other.
Tip: Keep your codebase indexed by letting Cursor's background indexer run. This powers the semantic search that the agent uses to find relevant code.
Agent Workflows
The most productive Cursor users follow an iterative workflow:
1. Describe the goal at a high level
2. Review the agent's plan before it executes
3. Accept or modify the proposed changes
4. Test incrementally after each change
Avoid making too many changes in a single agent turn. Smaller, focused tasks produce more reliable results than large multi-file rewrites.