Cursor — Configuration & Rules
Configure Cursor IDE for optimal AI coding. .cursorrules setup, Cursor settings, model selection, .cursor/ directory conventions, and integration with cursor rules templates.
Cursor — Configuration & Rules
Cursor's AI behavior is controlled by .cursorrules files, Cursor Settings, and model configuration. The rules system is the most important — it's Cursor's equivalent of a system prompt.
.cursorrules — The System Prompt
.cursorrules at project root is read by Cursor for every AI interaction. It's the most impactful configuration you can make.
Basic .cursorrules
You are a senior TypeScript developer working on a Next.js project.
## Commands
- `npm run dev` — Start development server
- `npm run build` — Production build
- `npx vitest run` — Run tests
## Code Style
- Use TypeScript strict mode
- Prefer server components unless interactivity is needed
- Use `@/` path alias for internal imports
- Error boundaries wrap every route segment
## Constraints
- Never modify next.config.ts without asking
- Never install packages without asking
- Always run type check after code changes
.cursor/rules/ — Multiple Rule Files
For larger projects, split rules by concern:

.cursor/rules/
├── typescript.mdc # "alwaysApply: true"
├── react.mdc # "alwaysApply: false, description: React rules"
├── testing.mdc # "alwaysApply: false, globs: **/*.test.*"
├── api-design.mdc # "alwaysApply: false, description: API design"
└── database.mdc # "alwaysApply: false, globs: prisma/**"
Rule file format:
---
alwaysApply: true
---
# TypeScript Conventions
- No `any` types. Use `unknown` and type guards
- Prefer `interface` for object shapes, `type` for unions
- Use `satisfies` operator for config objects
---
alwaysApply: false
description: React component patterns
globs: **/*.tsx
---
# React Conventions
- Server components by default
- `'use client'` directive only for interactivity
- Extract data fetching from component body
| Frontmatter Field | Description |
|---|---|
alwaysApply | Apply to every request (true) or only matched (false) |
description | Shown in rule picker (required when alwaysApply is false) |
globs | File patterns to match (required when alwaysApply is false) |
Conditional Rules
---
alwaysApply: false
globs: **/*.{test,spec}.{ts,tsx}
---
# Testing Rules
- Name tests: `should <expected behavior> when <condition>`
- Use `test()` not `it()` for consistency
- No business logic in tests — test behavior, not implementation
Cursor Settings
Access via Cursor → Settings → Cursor Settings (JSON):
{
"cursor.cpp.disabledLanguages": ["plaintext"],
"cursor.general.enableFreeTrial": true,
"cursor.tabCompletion": true,
"cursor.composer.model": "claude-sonnet-4",
"cursor.chat.model": "claude-sonnet-4",
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
Key Settings
| Setting | What it does |
|---|---|
cursor.tabCompletion | Enable/disable tab predictions |
cursor.composer.model | Model for Composer and Agent mode |
cursor.chat.model | Model for chat sidebar |
cursor.cpp.disabledLanguages | File types to exclude from AI |
Model Selection
Cursor supports multiple models:
| Model | Best For |
|---|---|
claude-sonnet-4 | Best overall — complex code, reasoning |
claude-opus-4 | Most capable — architecture, deep analysis |
gpt-5 | Good general coding, faster responses |
gemini-2.5-pro | 1M context for large projects |
cursor-small | Fast, free — simple completions |
Codebase Indexing
Cursor indexes your entire codebase for context. Configure what's indexed:
// .cursorignore — files to exclude from indexing
node_modules
dist
.next
build
*.min.js
*.generated.*
Integrating with Cursor Rules Template Library
Prompt Genius has 50+ framework-specific .cursorrules templates in the Cursor Rules section. Each template includes:
- Framework-specific conventions
- Common commands and scripts
- Best practices and anti-patterns
- Testing guidance
Combine the templates:
# Use the Next.js rules as base
cp .cursorrules .cursorrules.backup
cat templates/nextjs.cursorrules >> .cursorrules
cat templates/typescript.cursorrules >> .cursorrules
Related Pages
- MCP Setup in Cursor — connect external tools via MCP
- Prompt Engineering in Cursor — Agent mode, composer, inline edits
- Cursor Rules Section — 50+ .cursorrules templates by framework
- Cursor Rules Configuration Guide — Advanced .cursorrules patterns
- Tool Comparison — Cursor vs other AI coding tools
Related Articles
OfficeCLI — An Office Suite Purpose-Built for AI Agents
OfficeCLI is the first open-source Office suite designed from the ground up for AI agents. Single binary, no Office installation required, with a built-in rendering engine that closes the create-view-fix loop autonomously. Here's why this fills a critical gap in enterprise agent tooling.
GitHub Copilot — AI Coding Assistant
Complete guide to GitHub Copilot, the AI coding assistant. Covers prompt engineering, configuration, copilot-instructions.md, agent mode, and GitHub workflow integration.
OpenCode — AI Coding Agent
Complete guide to OpenCode, the terminal-based AI coding agent. Covers installation, prompt engineering, configuration, providers, skills, and best practices.