Help Cursor Index Your Codebase Well
What it is
Why it works
Cursor answers 'about your codebase' questions by retrieving from the index. If the index is full of build output, vendored code, and generated files, retrieval surfaces noise and the model reasons over the wrong things. Excluding junk sharpens every @codebase query and every agent edit.
When to use it
Any repo bigger than a few files, especially monorepos or projects with large generated/vendored directories. Set it up once when you open the project in Cursor.
When not to use it
Tiny single-purpose repos where everything is relevant — there's nothing to exclude, so tuning the index is busywork.
Prompt
Add a `.cursorignore` for anything that isn't source you reason about:
"node_modules/
dist/
build/
*.min.js
coverage/
*.snap
generated/"
Then use scoped retrieval instead of dumping everything:
"@codebase where is auth session validated?"Example
In a repo where a 40k-line generated GraphQL types file dominated retrieval, adding it to .cursorignore made @codebase answers instantly more relevant — Cursor stopped quoting generated code as if you'd written it.
Advanced version
For monorepos, reason one package at a time: scope questions with a path (@packages/api/...) rather than the whole tree, so retrieval competes within the relevant boundary. Re-index after large refactors so the map matches reality.
Common mistakes
- Leaving
node_modulesand build output indexed, drowning your real code in noise. - Asking whole-monorepo questions when you mean one package, so retrieval is diluted.
- Never re-indexing after a big move, so Cursor references files that no longer exist.