Complete Guide to Cursor .cursorignore Configuration: 3 Key Strategies for Large Project Indexing Optimization

Last Tuesday afternoon, I opened our company’s monorepo project with over 500,000 lines of code. Cursor’s Syncing icon in the bottom right started spinning. Five minutes passed—still spinning. Ten minutes—still indexing. I made a cup of coffee and came back. It was still there, slowly churning away.
The frustration didn’t end there. After the indexing finally finished, I asked the AI to help optimize a React component. Its suggestion? “You can directly modify node_modules/react-dom/cjs/react-dom.development.js.” I stared at the screen in silence for three seconds—the AI had mistaken dependency code for my project code.
Honestly, at that moment I started wondering if Cursor just wasn’t suited for large projects. Then I discovered a configuration file called .cursorignore, and everything changed. Indexing time dropped from 12 minutes to 3 minutes, and the AI stopped making ridiculous suggestions about modifying node_modules.
If you’ve experienced slow Cursor indexing or AI accuracy issues, this article will help you solve them completely. I’ll share 3 immediately effective optimization strategies and a ready-to-use configuration template.
Why Is Your Cursor Indexing So Slow
Let’s talk about Cursor’s indexing mechanism. Every time you open a project, Cursor converts code files into embedding vectors—basically transforming code into a numerical representation the AI can understand. This process requires traversing every file, computing vectors, and storing them. The more project files, the slower this process becomes.
Here’s the question: do all files in your project really need to be understood by the AI?
Most projects have several categories of files that are large, numerous, but almost useless for AI-assisted programming:
node_modules - The Dependency Black Hole
A medium-sized frontend project can have tens of thousands of files in node_modules. A React project with a few dozen dependencies easily surpasses 10,000 files. Cursor indexes all this third-party code every time, but do you really need the AI to understand lodash’s internal implementation?
dist/build - Compiled Junk
These are compressed, minified code generated by build tools. Making the AI index a JavaScript file compressed into a single line is like asking it to read hieroglyphics—completely pointless.
.git - Historical Baggage
Git repositories hide the entire version history of your project. For large projects, the .git folder can be hundreds of MB or even GB. Indexing this historical data is a complete waste of time.
Large Static Assets
Videos, images, font files… the AI can’t even read these things. Indexing them serves no purpose.
I ran a test: a 100,000-line Next.js project with complete node_modules and .next build directory took 8 minutes to index. After configuring .cursorignore to exclude these directories, indexing time dropped to 2 minutes. That’s a 4x difference.
More importantly, there’s accuracy. When the AI’s context is stuffed with node_modules code, it easily confuses your code with dependency libraries. The result? It suggests modifying dependency packages or mistakes third-party library APIs for functions you wrote.
Complete .cursorignore Configuration Guide
The good news is that .cursorignore uses the exact same syntax as .gitignore. If you know how to write .gitignore, this configuration file is a piece of cake.
Syntax Overview
Create a .cursorignore file in your project root (note the leading dot), then follow these rules:
# Comments start with #
# Exclude specific files
config.json
# Exclude entire directories (trailing slash)
node_modules/
dist/
# Wildcard matching
*.log # All log files
**/*.test.js # Test files at any level
# Negation rules (re-include)
!important.log # Exclude all .log but keep this oneReady-to-Use Configuration Template
I’ve compiled a base configuration suitable for most projects that you can copy directly into your .cursorignore file:
# Dependency directories
node_modules/
.pnp/
.pnp.js
vendor/
packages/
# Build artifacts
dist/
build/
out/
.next/
.nuxt/
.cache/
.vite/
.turbo/
# Tests and coverage
coverage/
.nyc_output/
*.spec.js
*.test.js
__tests__/
# Logs and temporary files
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store
*.swp
*.swo
*~
# Environment config (security consideration)
.env
.env.local
.env.*.local
credentials.json
*.key
*.pem
# Version control
.git/
.svn/
.hg/
# IDE config (optional)
.vscode/
.idea/
*.sublime-*
# Large resource files (adjust as needed)
*.mp4
*.mov
*.avi
*.zip
*.tar.gz
*.pdf
public/videos/This configuration covers 90% of common scenarios. After saving, open Cursor’s Settings > Features > Codebase Indexing and click the refresh button to apply the configuration.
Advanced Configuration by Project Type
Different project types can adjust the base template:
React/Vue Projects: Exclude large files in public directory
# Add to base config
public/assets/
public/images/*.png
public/fonts/Monorepo Projects: Exclude unrelated sub-packages (this is critical)
# Assuming you're on frontend team, only care about apps/web
apps/mobile/
apps/admin/
packages/backend-utils/Full-Stack Projects: Separate frontend/backend indexing
# If you mainly do frontend
server/
api/
database/
migrations/
# Or mainly backend
client/
public/
src/components/Pro tip: If unsure whether a file is excluded, run this in terminal:
git check-ignore -v [file-path]While this is a git command, since .cursorignore uses the same syntax, it’s useful for debugging configurations.
.cursorignore vs .cursorindexingignore - Choosing the Right Tool
When I first encountered these two configuration files, I was pretty confused too. The names look similar—what’s the difference? Which should I use?
Simply put: .cursorignore is complete blocking, .cursorindexingignore is partial blocking.
Core Difference
.cursorignore: The AI cannot access these files at all. Not indexed, not read, not referenced. It’s as if these files don’t exist in Cursor’s eyes. Use this for two situations—either security-sensitive files (.env, key files), or things the AI doesn’t need to touch at all (node_modules, build artifacts).
.cursorindexingignore: Files won’t appear in codebase search results, but the AI can still read them when needed. Cursor added this feature in version 0.46, specifically for performance optimization.
For example: you have a legacy/ directory in an old project containing code from three years ago. You don’t want this code polluting search results, but occasionally the AI might need to reference these old implementations. That’s when .cursorindexingignore is perfect.
Use Case Comparison Table
| File Type | Recommended Config | Reason |
|---|---|---|
| .env, credentials.json | .cursorignore | Security first, completely block access |
| node_modules | .cursorignore | No need for AI to understand dependency internals |
| dist/build | .cursorignore | Compiled artifacts have no reference value |
| Test fixture data | .cursorindexingignore | Reduce search noise, but AI might need reference |
| Legacy code | .cursorindexingignore | Don’t want frequent appearance, preserve access |
| Documentation drafts | .cursorindexingignore | Lower indexing burden |
| Large test data files | .cursorignore | Completely useless and takes space |
Configuration Priority
Cursor processes these configurations in this order:
- First reads project’s
.gitignore(automatically respected) - Then reads
.cursorignore(can override gitignore with!syntax) - Finally applies
.cursorindexingignore
What does this mean? Say your .gitignore excludes the logs/ directory, but you want the AI to access a specific log file. You can write in .cursorignore:
!logs/important-debug.logThere’s also a useful feature called “Hierarchical Cursor Ignore.” When enabled (find it in Settings), Cursor recursively searches parent directories for .cursorignore files. Perfect for putting a global config in the root of large monorepos, with sub-projects adding their own supplementary configs.
My Usage Strategy
Honestly, in most cases .cursorignore alone is enough. .cursorindexingignore is more of a fine-tuning optimization tool, suitable for scenarios with extremely high performance requirements or particularly complex project structures.
When starting configuration, I recommend this:
- Step 1: Use only
.cursorignore, exclude things you clearly don’t need - Step 2: Observe for a week, see how the AI performs
- Step 3: If issues remain, consider using
.cursorindexingignorefor fine-tuning
Don’t overcomplicate things from the start. Gradual progression works better.
3 Optimization Strategies for Monorepo Projects
Monorepo is the project type most easily “overwhelmed” by Cursor. A single repository might contain frontend, backend, mobile, admin dashboard… the AI faces so much code, it’s easy for understanding to drift.
I learned this the hard way on a monorepo project with 12 sub-apps. When I asked the AI to help optimize a frontend component, it suggested referencing a utility function from the backend API directory. Sounds reasonable, but the problem is the frontend can’t access backend code at all—these two packages aren’t even in the same runtime environment.
Later I summarized 3 particularly useful optimization strategies:
Strategy 1: Split Indexing by Work Area
The simplest, most direct approach—exclude sub-projects you don’t need to worry about.
Say you’re a frontend team member mainly working in the apps/web directory. Just exclude all other sub-apps:
# .cursorignore
apps/mobile/
apps/admin/
apps/api/
packages/backend-utils/
packages/database/
services/This has two benefits: indexing is faster, and the AI won’t be distracted by other sub-project code. I tried keeping only the two packages I’m responsible for in a monorepo, and indexing time dropped from 15 minutes to 4 minutes.
If you’re a full-stack developer who frequently switches between frontend and backend, you can prepare two config files: .cursorignore.frontend and .cursorignore.backend, copying the appropriate one to .cursorignore based on current work.
Strategy 2: Use Project Rules to Guide AI Understanding of Project Structure
The biggest issue with monorepo is the AI can’t figure out relationships between directories. This is when you can use a .cursorrules file (note: not .cursorignore) to give the AI a project map.
Create a .cursorrules file in project root:
# Project Structure Description
This is a monorepo project containing the following sub-apps:
- apps/web: Frontend app (Next.js), port 3000
- apps/api: Backend API (Node.js + Express), port 8000
- apps/admin: Admin dashboard (React), port 3001
- packages/ui: Shared UI component library
- packages/utils: Common utility functions
## Code Reference Rules
- Frontend apps (web/admin) can only reference packages/ui and packages/utils
- Frontend cannot directly reference apps/api code
- Shared packages (packages/*) cannot depend on specific apps (apps/*)
## Current Work Focus
Currently developing apps/web, please focus optimization suggestions on frontend code.This file will be read by the AI, helping it understand project structure. The effect is obvious—after configuration, the AI rarely recommends cross-boundary code references.
Strategy 3: Split-Window Work Mode
For super-large monorepos (like those with 20+ sub-apps), even with .cursorignore configured, a single window’s context is still too large.
My approach in this case: open independent Cursor windows for each sub-app.
- Window 1: Open
apps/webdirectory - Window 2: Open
apps/apidirectory - Window 3: Open
packages/uidirectory
Each window has its own indexing and context, making AI understanding more precise. The downside is needing to switch between windows, but for large projects, this small inconvenience is worth the accuracy improvement.
Pro tip: If sub-apps have dependencies (like web depending on ui component library), you can explicitly reference in the web window using @folder:
@folder packages/ui help me check the Button component's props definitionThis keeps windows lightweight while still accessing dependency package code when needed.
Core Principle for Monorepo
To summarize, the core of monorepo optimization is: let the AI see only what it needs to see.
The larger the project, the more you need to subtract. Don’t expect the AI to understand your entire project architecture like you do. Actively help it define boundaries, and it will give more accurate suggestions.
Verifying and Maintaining Your Configuration
Configuring .cursorignore isn’t a one-and-done thing. You need to verify the config is working and maintain it regularly.
Checking If Configuration Is Working
The most intuitive way is to watch indexing time. Compare Syncing duration before and after configuration—if it’s noticeably faster, the config is working.
More accurate verification methods:
Check Indexing Status
OpenSettings > Features > Codebase Indexingto see how many files are indexed. After configuring.cursorignore, this number should drop significantly.Test AI Context Range
Try asking the AI a question using@codebaseto see if its answer still references excluded files. For example, after configuring to excludenode_modules, ask “what React components are in the project”—the AI shouldn’t list components fromnode_modules/react.Search Function Verification
Use Cursor’s code search (Cmd/Ctrl + P) to search for a filename in a directory you explicitly excluded. If you can’t find it, the config succeeded.
When to Manually Refresh Indexing
Cursor automatically detects file changes and incrementally updates indexing, but these situations require manual refresh:
- Modified
.cursorignoreconfig file - Switched to a Git branch with major changes
- Batch deleted or added many files
- AI understanding seems inaccurate, indexing might be outdated
Refresh method: Settings > Features > Codebase Indexing > Refresh. Just click once. Refresh will re-index the entire project—wait for Syncing to complete.
Daily Configuration Maintenance
.cursorignore isn’t write-once-and-forget. As projects evolve, you might need adjustments:
Monthly Checklist:
- Have new build directories been excluded (like
.output/appearing after framework upgrade)? - Are there new large file directories to exclude?
- Do previously excluded directories still exist (clean up invalid configs)?
Team Collaboration Suggestions:
For team projects, should .cursorignore be committed to Git? My recommendation varies by case:
- Common exclusion rules (node_modules, dist, etc.): Commit to Git, benefit entire team
- Personal work preferences (excluding certain sub-projects): Don’t commit, or add to
.git/info/exclude
You can also add a line in .gitignore:
.cursorignore.localThen write personal configs in .cursorignore.local and reference it in .cursorignore (if Cursor supports include syntax).
Use Comments to Record Exclusion Reasons
This is a useful habit. Add comments in .cursorignore explaining why you’re excluding a directory:
# 2025-01-15: Exclude newly added AI training data directory, too large and no need to index
data/training/
# 2025-01-10: Temporarily exclude performance test directory, contains many log files
perf-tests/Three months later when you look back at the config, you’ll thank yourself for writing comments.
Conclusion
Back to the article’s opening question: Is slow Cursor indexing and AI accuracy drift really the tool’s fault?
No. In most cases, it’s because we didn’t tell the AI what to focus on and what to ignore.
.cursorignore is such a simple yet powerful tool. Spending 5 minutes configuring it can save you hours of waiting time over the next few months of development, and more importantly, get more accurate AI suggestions.
Three-Step Action Checklist:
- Take Immediate Action: Copy this article’s base configuration template, create a
.cursorignorefile in your project root - Customize Optimization: Add targeted exclusion rules based on your project type (React/Vue/Monorepo)
- Continuous Improvement: Observe AI performance for a week, record issues, iterate configuration
Don’t pursue perfect configuration on the first try. Use the base template to solve 80% of problems, then slowly adjust the remaining 20% in actual use.
If you’re also using Cursor on large projects, give these strategies a try. Feel free to share your configuration experience or questions in the comments—you might help other developers facing the same challenges.
Complete Cursor .cursorignore Configuration Process
Detailed steps to configure .cursorignore from scratch and optimize Cursor codebase indexing
⏱️ Estimated time: 10 min
- 1
Step1: Create .cursorignore file and add base configuration
Step 1: Create .cursorignore file in project root
Base configuration template (covers 90% of scenarios):
• Dependency directories: node_modules/, vendor/, .pnp/
• Build artifacts: dist/, build/, out/, .next/, .nuxt/, .cache/
• Test files: coverage/, *.spec.js, *.test.js, __tests__/
• Log files: *.log, npm-debug.log*, yarn-error.log*
• Environment config: .env, .env.local, credentials.json, *.key
• Version control: .git/, .svn/
• Large resources: *.mp4, *.zip, *.pdf, public/videos/
Note: Same syntax as .gitignore, directories end with slash, supports wildcards * and **, # starts comments - 2
Step2: Add targeted configuration based on project type
Step 2: Choose advanced config for your project
React/Vue projects additional exclusions:
• public/assets/ (large static resources)
• public/images/*.png (image files)
• public/fonts/ (font files)
Monorepo project config:
• apps/mobile/ (exclude mobile app)
• apps/admin/ (exclude admin dashboard)
• packages/backend-utils/ (exclude backend utilities)
• Keep only current working sub-projects
Full-stack project config:
• Frontend development: exclude server/, api/, database/, migrations/
• Backend development: exclude client/, public/, src/components/
Tip: Full-stack developers can prepare .cursorignore.frontend and .cursorignore.backend files, switch based on work content - 3
Step3: Verify configuration is working
Step 3: Check configuration effects
Method 1: Check indexing time
• Compare Syncing duration before/after config, should be noticeably shorter
Method 2: Check indexing status
• Open Settings > Features > Codebase Indexing
• View indexed file count, should drop significantly
Method 3: Test AI context
• Use @codebase to ask: "What React components are in the project"
• AI should not list components from node_modules/react
Method 4: Search function verification
• Cmd/Ctrl + P search for files in excluded directories
• If can't find them, config succeeded
Refresh indexing: Settings > Features > Codebase Indexing > Refresh - 4
Step4: Monorepo project special configuration (optional)
Step 4: Monorepo additional optimization strategies
Strategy 1: Split by work area
• Exclude unrelated sub-projects in .cursorignore
• Example: Frontend team excludes apps/mobile/, apps/api/, packages/backend-utils/
• Result: Indexing time drops from 15 minutes to 4 minutes
Strategy 2: Create .cursorrules file
• Create .cursorrules in project root
• Describe project structure, sub-app relationships, code reference rules
• Help AI understand monorepo architecture, reduce cross-boundary recommendations
Strategy 3: Split-window work
• Open separate Cursor windows for different sub-apps
• Window 1 opens apps/web, Window 2 opens apps/api
• Use @folder to explicitly reference dependency package code
FAQ
What's the difference between .cursorignore and .cursorindexingignore? Which should I use?
• .cursorignore: Completely blocks AI access—no indexing, reading, or referencing. For sensitive files (.env, credentials.json) and useless files (node_modules, dist)
• .cursorindexingignore: Only excludes from indexing, AI can still read when needed. For legacy code, test fixture data
Recommended strategy: 90% of cases only need .cursorignore. First configure basic exclusion rules, observe AI performance for a week, use .cursorindexingignore for fine-tuning if needed
Indexing is still slow after configuring .cursorignore—what should I do?
1. Check if config is working: Settings > Features > Codebase Indexing, view indexed file count—should drop significantly
2. Manually refresh indexing: Need to click Refresh button after modifying config
3. Check for missed large file directories: Run `du -sh */` to find large directories, add to .cursorignore
4. Monorepo special handling: Exclude unrelated sub-projects, or open separate windows for different sub-apps
5. Clear cache: Delete .cursor directory and re-index
Typical case: 100k-line project should drop from 8 minutes to 2-3 minutes after config. If difference is small, config is incomplete
After excluding node_modules, can AI still properly suggest third-party library APIs?
• AI's base training data already includes knowledge of common third-party libraries (React, Vue, Express, etc.)
• Import statements in your code tell the AI which libraries you're using
• AI infers API usage from context, doesn't need to index node_modules source code
Actual testing: After excluding node_modules, AI suggestions for React Hooks, Lodash methods, and Axios requests are completely normal. Actually reduced cases of mistaking dependency library code for project code
Note: Rare obscure libraries might have inaccurate suggestions. Can temporarily re-include specific dependency packages using ! syntax
Should .cursorignore be committed to Git in team collaboration?
Should commit:
• Common exclusion rules (node_modules, dist, .git, .env, etc.)
• Project framework-specific directories (.next, .nuxt, .cache, etc.)
• Large resource directories (public/videos, data/datasets, etc.)
Should not commit:
• Personal work preferences (excluding certain sub-projects)
• Development environment-specific paths
• Temporary debug exclusions
Recommended approach:
1. Commit common config to .cursorignore
2. Write personal config to .cursorignore.local
3. Add .cursorignore.local to .gitignore
4. Use comments in .cursorignore to explain each rule's purpose
In monorepo projects, how should frontend and backend developers configure different .cursorignore files?
Approach 1: Prepare multiple config files
• Create .cursorignore.frontend and .cursorignore.backend
• Copy to .cursorignore based on current work content
• Suitable for full-stack developers who frequently switch
Approach 2: Split-window work
• Window 1 opens apps/web (frontend app)
• Window 2 opens apps/api (backend app)
• Each window has independent .cursorignore config
• Suitable for large monorepos (20+ sub-apps)
Approach 3: Git branch config
• Main branch keeps common config
• Personal branches customize .cursorignore
• Revert config file changes before committing code
Recommendation: Small/medium teams use Approach 1, large teams use Approach 2
After configuration, AI still references code in excluded directories—what should I do?
1. Indexing not refreshed
• Solution: Settings > Codebase Indexing > Refresh
2. Config syntax error
• Check: Do directories end with slash (node_modules/)
• Check: Are wildcards correct (*.log not *.log/)
3. .gitignore conflict
• Cursor reads both .gitignore and .cursorignore
• Use ! syntax to override .gitignore rules
4. AI using historical context
• Clear Chat history and ask again
• Delete .cursor cache directory and re-index
5. File not actually excluded
• Test: Search file with Cmd/Ctrl + P—if found, not excluded
• Use git check-ignore -v [file-path] to debug config
11 min read · Published on: Jan 15, 2026 · Modified on: Feb 4, 2026
Related Posts
AI Keeps Writing Wrong Code? Master These 5 Prompt Techniques to Boost Efficiency by 50%

AI Keeps Writing Wrong Code? Master These 5 Prompt Techniques to Boost Efficiency by 50%
Cursor Advanced Tips: 10 Practical Methods to Double Development Efficiency (2026 Edition)

Cursor Advanced Tips: 10 Practical Methods to Double Development Efficiency (2026 Edition)
Complete Guide to Fixing Bugs with Cursor: An Efficient Workflow from Error Analysis to Solution Verification


Comments
Sign in with GitHub to leave a comment