Cursor Not Understanding My Codebase
Quick Answer
Cursor doesn't automatically read every file. Without explicit context via @file or .cursorrules, it guesses based on training data. Start with "Create .cursorrules" before making broader code changes.
You're in the right place if...
- !Generic answers that don't match your code
- !Suggests wrong import paths
- !Ignores your existing patterns
Why this happens
Cursor doesn't automatically read every file. Without explicit context via @file or .cursorrules, it guesses based on training data.
Fix
Create .cursorrules
Add a .cursorrules file to your project root with your stack details:
# .cursorrules You are an expert Next.js developer. This project uses: - Next.js 14 App Router - TypeScript strict mode - Tailwind CSS - Supabase for database and auth - Stripe for payments Always use the App Router pattern. Never use pages/ directory. Always use TypeScript. Never use 'any' type.
Use @file in prompts
Always reference specific files: '@src/lib/db.ts create a new function that queries the users table'. Cursor reads files you mention.
Prevent this next time
Create .cursorrules before writing any code. It's the single biggest improvement to Cursor's output quality.
Frequently Asked Questions
Your tech stack, coding conventions, file structure, and do/don't rules. Think of it as onboarding docs for a new developer.
Yes. Both chat and Composer read .cursorrules. It's applied to every response.
Related fixes
Weekly Newsletter
Get next week's fix before you need it.
Join developers getting weekly vibe coding tips, error fixes, and tool updates.
Subscribe on Substack →