AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How Engineering Teams Configure .cursorignore and Indexing Exclusions to Optimize Semantic Search in Large Monorepos

Geraldo Bracamontes Varga · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

In a repository with hundreds of thousands of lines of code across dozens of micro-frontends and backend services, unconfigured AI indexing is a silent productivity killer. When engineering teams open a massive monorepo in Cursor without granular ignore boundaries, the editor attempts to parse, chunk, and embed every generated artifact, test fixture, and build output. The symptoms are familiar to full-stack architects: local indexing loops indefinitely, CPU and memory usage spike to system-freezing levels, Cursor throws "indexing limit reached" alerts, and Composer context becomes poisoned with thousands of lines of auto-generated Protocol Buffer stubs rather than core business logic.

365Finds maintains a clear stance: Codebase indexing hygiene must be treated as critical repository infrastructure, not an afterthought left to individual developers. Deploying Cursor across an engineering organization without checked-in .cursorignore and workspace exclusion files wastes subscription value and degrades AI response quality.

This guide delivers an end-to-end framework for configuring Cursor's native exclusion hierarchy, taming OS-level file watcher bottlenecks, and verifying semantic search health in large monorepos.


1. The Indexing Pipeline: How Cursor Evaluates Your Files

To solve semantic search degradation, engineering teams must understand how Cursor consumes monorepo assets. Retrieval-augmented generation (RAG) in Cursor does not rely on a single flat scanner; it operates across a layered hierarchy.

┌────────────────────────────────────────────────────────┐
│ 1. OS-Level File Watcher (inotify / FSEvents)          │
│    Filtered by: files.watcherExclude in settings.json  │
└───────────────────────────┬────────────────────────────┘
                            │
┌───────────────────────────▼────────────────────────────┐
│ 2. Text Search & Instant Grep (Ripgrep Engine)         │
│    Filtered by: search.exclude & .gitignore            │
└───────────────────────────┬────────────────────────────┘
                            │
┌───────────────────────────▼────────────────────────────┐
│ 3. Background Codebase Indexing (Vector Embeddings)    │
│    Filtered by: Default Ignore List + .cursorignore    │
│                 + .cursorindexingignore                │
└───────────────────────────┬────────────────────────────┘
                            │
┌───────────────────────────▼────────────────────────────┐
│ 4. AI Context Retrieval (@Codebase, Composer, Agent)   │
│    Access restricted strictly by: .cursorignore        │
└────────────────────────────────────────────────────────┘

The Exclusion Hierarchy and Precedence

Cursor evaluates file accessibility through four primary mechanisms:

MechanismConfiguration ScopeSemantic Vector IndexingManual @ Context ReferenceOS Watcher CPU Overhead
Default Ignore ListHardcoded internal engineExcluded automaticallyBlockedNot affected
.gitignoreVersion control trackingExcluded automaticallyExcluded by defaultNot affected
.cursorignoreProject root & sub-packagesExcludedCompletely blockedNot affected
.cursorindexingignoreProject rootExcluded from vector indexAllowed via explicit @Not affected
files.watcherExclude.vscode/settings.jsonNot affected directlyNot affected directlyEliminated at OS layer

Why .gitignore Is Not Enough in Monorepos

Cursor automatically respects .gitignore. If a path is ignored by git, Cursor skips indexing it. However, enterprise monorepos routinely commit generated assets that version control requires but AI semantic models choke on:

When these git-tracked files are indexed, they flood the vector database with repetitive structural noise. When an engineer asks Composer, "How is user authentication session expiry handled?", the retrieval model retrieves generated serialization structs instead of domain middleware.


2. Configuring .cursorignore: Rules and Monorepo Architecture

Cursor's .cursorignore file uses standard .gitignore glob syntax and must be placed in the project root. Files matched by .cursorignore are excluded from background codebase indexing, Agent tool access, Tab autocomplete context, Inline Edit, and manual @ mentions.

Monorepo Production .cursorignore Template

Place this .cursorignore at the root of your monorepo to isolate noisy, high-entropy, or machine-generated assets:

# ==============================================================================
# 365Finds Recommended Monorepo .cursorignore Template
# ==============================================================================

# 1. Generated Code & Serialization Stubs
**/*.pb.go
**/*_pb.ts
**/*_pb.d.ts
**/*_grpc.pb.go
**/*.generated.ts
**/*.generated.go
**/generated/**
**/__generated__/**
**/gql-types.ts

# 2. Package Bundles & Build Output (Even if committed)
**/dist/
**/build/
**/out/
**/.next/
**/.nuxt/
**/.turbo/
**/target/
**/vendor/

# 3. Test Fixtures, Golden Files & Synthetic Data
**/fixtures/**/*.json
**/fixtures/**/*.xml
**/__snapshots__/**
**/*.snapshot
**/testdata/large/**
**/golden/**
**/*.wiremock.json

# 4. Database Dumps & Schema Snapshots
**/migrations/dumps/**
**/*.sql.gz
**/seed-data/**

# 5. Dependency Lockfiles (Cursor default-ignores these, but enforce explicitly)
**/package-lock.json
**/pnpm-lock.yaml
**/yarn.lock
**/bun.lockb
**/Cargo.lock
**/poetry.lock

# 6. Local Environment & Secret Safeguards
**/.env*
**/*.pem
**/*.key
**/credentials.json
**/secrets.json
**/id_rsa*

# 7. Documentation Builds & Coverage Reports
**/coverage/**
**/.nyc_output/**
**/storybook-static/**
**/*.lcov

The Parent-Directory Negation Trap

A frequent source of configuration failure in large teams involves negation patterns (!).

Under standard glob implementations, Cursor cannot re-include a file via ! if its parent directory has already been excluded with a wildcard directory pattern.

# ❌ BROKEN: public/assets/style.css remains ignored
public/*
!public/assets/style.css

# ✅ CORRECT: Exclude contents of the subdirectory, then negate
public/assets/*
!public/assets/style.css

Because Cursor avoids traversing excluded directory trees to save I/O cycles, patterns targeting nested files inside ignored folders are never evaluated. Engineering teams must structure directory-level patterns with explicit depth.

Enabling Hierarchical Ignore for Distributed Teams

In massive monorepos managed by dozens of squads, maintaining a monolithic root .cursorignore creates team friction.

Cursor supports Hierarchical Cursor Ignore:

  1. Open Cursor Settings (Cmd + , or Ctrl + ,).
  2. Navigate to Indexing > Ignore Files.
  3. Toggle on Hierarchical Cursor Ignore.

When enabled, Cursor traverses package roots (e.g., apps/web/.cursorignore, services/payments/.cursorignore), allowing individual domain teams to specify local exclusions without touching repository-wide root files.

Choosing Between .cursorignore and .cursorindexingignore

365Finds recommends establishing a strict team standard between these two configuration files:


3. Eliminating CPU Spikes with files.watcherExclude

Many teams confuse semantic vector indexing freezes with OS-level file watcher thrashing.

When a developer runs pnpm build, cargo build, or generates code in a monorepo, thousands of new files are written to disk simultaneously. By default, VS Code and Cursor track these file system modifications using native OS file system notifications (inotify on Linux, FSEvents on macOS). When hundreds of thousands of events fire, Cursor Helper and the Node.js extension host pin CPU cores at 100%, causing the UI and semantic indexing to stall.

.cursorignore does not stop the operating system file watcher. To fix this, engineering leads must enforce exclusion settings in .vscode/settings.json.

Recommended Monorepo .vscode/settings.json

Check this configuration into your shared .vscode directory:

{
  "files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/**": true,
    "**/dist/**": true,
    "**/build/**": true,
    "**/.next/**": true,
    "**/.nuxt/**": true,
    "**/.turbo/**": true,
    "**/target/**": true,
    "**/vendor/**": true,
    "**/coverage/**": true,
    "**/fixtures/**/*.json": true,
    "**/.cache/**": true,
    "**/tmp/**": true
  },
  "search.exclude": {
    "**/node_modules": true,
    "**/dist": true,
    "**/build": true,
    "**/.next": true,
    "**/.turbo": true,
    "**/target": true,
    "**/vendor": true,
    "**/coverage": true,
    "**/fixtures/**/*.json": true
  },
  "files.exclude": {
    "**/.git": true,
    "**/.DS_Store": true
  }
}

Isolating Watcher vs Indexer Load

If developers still report high CPU usage after applying exclusions:

  1. Open the Command Palette (Cmd + Shift + P or Ctrl + Shift + P).
  2. Run Developer: Open Process Explorer.
  3. Inspect the active process table:
    • If the Cursor Helper (Plugin) / indexing daemon dominates CPU, review .cursorignore patterns for unexcluded generated code trees.
    • If the File Watcher process dominates, update files.watcherExclude to cover newly created build output directories.

4. Resetting Cache and Verifying Vector Health

After deploying .cursorignore and workspace exclusion settings, Cursor's existing index cache may still hold stale vector embeddings from thousands of previously ingested files. Engineering teams must flush the cache and trigger a fresh index.

Step-by-Step Re-Indexing

  1. Trigger Manual Resync:
    • Open the Command Palette (Cmd + Shift + P / Ctrl + Shift + P).
    • Run Cursor: Resync Index.
  2. Settings UI Reset:
    • Navigate to Cursor Settings > Features > Codebase Indexing (or Indexing & Docs).
    • Review the total file count displayed. In an optimized monorepo, file count should decrease by 60% to 80% compared to an unconfigured workspace.
    • Click Delete Index (or the trash icon) and initiate a clean rebuild.
  3. Hard Cache Purge (When Indexing Is Stuck): If Cursor loops indefinitely on an old cache state, execute a workspace storage cleanup:
    • macOS: rm -rf ~/Library/Application\ Support/Cursor/User/workspaceStorage/*
    • Linux: rm -rf ~/.config/Cursor/User/workspaceStorage/*
    • Windows: Remove-Item -Recurse -Force "$env:APPDATA\Cursor\User\workspaceStorage\*"
    • Restart Cursor to initiate an untainted indexing cycle.

Verifying Semantic Search Accuracy

To confirm that vector retrieval is functioning with high signal-to-noise ratio:

  1. Audit via @Codebase Query: In Composer, submit an architectural query specific to domain rules:

    "Explain how tenant subscription limits are enforced in the API gateway."

  2. Inspect Context Chunks: Expand the retrieved context files in Composer's prompt panel.
    • Healthy Index: Context snippets contain application controllers, middleware, and domain models.
    • Polluted Index: Context contains auto-generated Protobuf serializers, fixture mocks, or migration strings. If these surface, locate their relative paths and add explicit wildcards to .cursorignore.

5. 365Finds Best Practices for Monorepo AI Governance

365Finds recommends embedding AI indexing configurations directly into team operational standards:

  1. Enforce Repository-Level Configurations in CI: Check .cursorignore and .vscode/settings.json into git. Treat accidental deletions or reckless wildcard negations as build review blockers.
  2. Pair with .cursorindexingignore for Interface Discoverability: Never completely blind Composer to API structures. Use .cursorindexingignore for large schema files so developers retain manual @ tagging without paying the vector chunking overhead.
  3. Audit File Counts After Major Dependency Upgrades: When adding microservices or introducing heavy tooling (like new protobuf compilers or code generators), check Cursor's indexing status bar to ensure new outputs have not leaked into the vector space.

By establishing strict ignore boundaries at both the OS watcher level and the semantic indexing layer, engineering organizations transform Cursor from a resource-draining editor into a sub-second, highly contextual development partner.


References