Cursor for Large Codebases: A Smarter Way to Scale

Dan Greer · · 11 min read

Part of the Claude Code guide. Start with Claude Code Doesn't Understand Your Codebase? How to Fix It

Cursor for large codebases cover illustrating a smarter way to scale

Before asking Cursor to change a shared authentication helper, ask it to find a caller outside that helper's package. Pick one you already know exists. If the answer misses it, check which folders are open, inspect the exclusions, and get that lookup working before asking for edits.

I'd use that as the first test of a large-repo setup. A plausible explanation of the helper isn't enough to plan a change to its consumers.

What Cursor indexes now

Cursor's current search documentation describes Instant Grep, an automatically used search engine with a local index, alongside Explore, a subagent with its own context window, so broader investigations can happen separately. Cursor says it doesn't store codebase embeddings for search.

That changes the indexing advice worth following. Old instructions about waiting for a semantic index, uploading chunks, or forcing a full reindex don't match the current search page, which says Cursor doesn't upload file paths or code to build a search index, so I'd start by testing whether a known reference is discoverable.

Local indexing also says little about the rest of the request. When Agent opens a match, its contents can enter the model request, as the same documentation explains.

Check the ignore files

Put .cursorignore at the project root. It uses .gitignore pattern syntax, and Cursor also applies .gitignore and its default exclusions. Review those together before adding more patterns, especially around shared source, tests, and configuration that a change needs.

For a project where these directories contain disposable build output, a starting example is:

**/dist/
**/build/
**/coverage/

Don't paste that blindly. If your repo keeps a contract in generated output, inspect how it is produced, decide which source the agent needs, and make that source available instead of hiding both sides of the contract.

The current docs say Cursor blocks Agent, Tab, and @-mention references from files listed in .cursorignore, while the terminal and MCP server tools Agent uses can still reach them. The same page warns that complete protection isn't guaranteed, so treat the file as a guard for those listed features, not as a way to keep secrets from an agent that can run commands.

What about .cursorindexingignore?

Cursor introduced .cursorindexingignore in February 2025 for indexing-only exclusions.

The current ignore reference doesn't document it.

If your repo still has one, test whether a file it lists stays out of Agent's search before relying on it.

Open the packages the change actually crosses

Cursor supports multi-root workspaces, with each folder's context available to Agent. The same FAQ says features that rely on a single git root, like worktrees, are disabled in multi-root workspaces, and Cloud Agents don't support multi-root workspaces. If an API and its shared library live in separate directories, include both, check their ignore files, and test a reference across that boundary before editing.

Use File > Add Folder to Workspace, add the related folders, then choose File > Save Workspace As, following VS Code's multi-root workspace guide, and save beside the example's apps, packages, and tests directories.

refactor.code-workspace stores the folder paths in this example. They resolve relative to that workspace file:

{
  "folders": [
    { "path": "apps/api" },
    { "path": "packages/auth" },
    { "path": "packages/contracts" },
    { "path": "tests" }
  ]
}

Opening the monorepo root is also reasonable. I'd keep the helper's consumers in the workspace even if only one package needs edits, and narrow the questions rather than the folders.

For package relationships beyond this setup, see mapping dependencies in a monorepo.

Attach files deliberately

Type @ in chat and select a matching file or folder. Cursor's prompting documentation gives @auth.ts and @src/components/ as examples, with deeper navigation available after selecting a folder, so attach a known implementation, then ask the agent to find its consumers, including packages outside your target app.

Here's an illustrative prompt. Replace these paths and the symbol with your own:

Read @packages/auth/ and @apps/api/ before proposing changes.
Find SharedUserClaims and trace a request from its route to validation.
List consumers outside the API package, with file paths.
Flag any path you could not inspect. Do not edit files yet.

An attached folder doesn't establish that every relevant consumer was read. I'd still inspect the cited files, follow any re-export, and compare the result with the caller I used in the setup test.

Give project rules a narrow job

Use project rules for conventions the agent should follow.

api-refactor.mdc is an example project rule, stored under .cursor/rules, with a glob for API TypeScript files, and alwaysApply: false so it attaches when a matching file enters context.

For example, save this as .cursor/rules/api-refactor.mdc, adjusting the glob to your layout:

---
globs: apps/api/**/*.ts
alwaysApply: false
---
Before editing a handler, read a neighboring handler and its tests.
Preserve the existing authentication and error-response conventions.
For a shared contract change, identify consumers outside this package.
Report any consumer you could not inspect before proposing the patch.

api-refactor.mdc records a workflow expectation. It doesn't establish which callers exist, whether they still use the same contract, or what changed on your branch, so keep that evidence in the investigation rather than maintain a caller list inside the rule.

Use a search ladder

When I know a symbol, I start with a literal lookup, inspect its package, then follow consumers outward. When I only know the behavior, I ask the agent to locate a candidate implementation first.

1. Start with an exact reference

rg searches this example's apps and packages directories for a literal string (-F, explained in ripgrep's user guide) and prints line numbers (-n, defined in the flag reference), so you can open each match, including the caller you expected to find, to inspect its use.

rg -n -F 'SharedUserClaims' apps packages

rg prints matching lines, not a verified list of runtime callers. Open each match to work out whether it's a definition or a use, then follow the imports, with re-exports kept in view, before calling it a consumer.

2. Search by behavior when you lack a symbol

Ask Cursor to find where a request becomes an authenticated session. Even if the explanation sounds familiar, take its candidate implementation into an exact lookup, with the source open beside the results, so you can inspect the names the agent proposes.

3. Narrow the follow-up to a package

rg accepts a directory as its search scope. Once you've found the likely implementation, search its package, then expand to consumers, rather than repeat the same broad question:

rg -n -F 'SharedUserClaims' packages/auth
rg -n -F 'SharedUserClaims' apps

4. Verify what the search covered

rg skips ignored and hidden files by default, as its filtering documentation explains, so if an expected match is absent, check the active filters, then search the relevant file directly.

Ask the agent to name its searched roots and unresolved consumers. Where supported, the language server's reference search provides another check, alongside inspection of entry points and configuration, because a missing text match, on its own, doesn't establish non-use.

A five-phase refactor workflow

I want the plan to survive inspection before I ask for a patch. The following sequence keeps discovery separate from permission to edit, while giving each phase something concrete to hand to the next.

Phase 1: map before editing

Start read-only. Ask which packages own the target behavior, where database access lives, which code calls external services, and where state is shared. Require paths you can open.

The result should identify the area to investigate. Keep unresolved ownership questions visible.

Phase 2: trace the path you're changing

Follow the request into the target implementation and out to its consumers. I'd inspect the error path too, including configuration and shared models, because a consumer can sit outside the app where the request began, and that needs to appear in the plan.

Trace session refresh from its entry point to the shared auth helper.
Show the files that read its return value, including other packages.
Explain how an error reaches the caller.
Separate observed references from assumptions. Do not edit yet.

Phase 3: write the change plan

Ask for the smallest compatible change. Name the contracts that must hold, then order preparatory work ahead of the behavior change, with a checkpoint after each slice, where you can stop or revert.

A plan can include an unresolved question. I'd rather resolve it before accepting edits to another package.

For example, if SharedUserClaims needs a new field, the handoff should identify the type definition, its validation, the API handler that creates it, consumers that read it, and the tests covering those paths. Before editing, check each item off as either inspected or unresolved:

  • [ ] Definition and re-exports located
  • [ ] Producers and consumers listed with file paths
  • [ ] Validation and error behavior inspected
  • [ ] Configuration-dependent paths noted
  • [ ] Relevant tests identified
  • [ ] Unresolved consumers recorded

Phase 4: execute in bounded slices

Change one boundary at a time. I'd stop at any unexpected file in the diff, even if the edit looks harmless, because it may point to a consumer the plan missed, which deserves investigation before the patch expands.

Keep unrelated cleanup for another change. It makes the compatibility review harder.

Phase 5: verify from fresh context

Start a separate review conversation with the current diff and the intended behavior. Run the repository's relevant tests and lint checks, then review untouched consumers against that evidence, with any unexercised path recorded explicitly, including configuration-dependent behavior.

Cursor summarizes older conversation near its context limit. Give the review its own evidence rather than assume every earlier discovery remains available.

For the parallel workflow in another client, see Claude Code on a large codebase.

Add mapped relationships when you need them

I build Pharaoh, a hosted MCP server that maps repository structure for TypeScript, JavaScript, Python, C and C++, including module dependencies and callers, for agents to query while planning changes. A repository with more than 20 MB of C and C++ maps its other languages only.

get_codebase_map shows modules and their dependencies. get_module_context supplies a module's exports and callers from other modules.

I'd use those to orient the investigation, then ask what changing the target could affect.

get_blast_radius returns production callers and affected endpoints, along with cron jobs and database operations. Test-file callers are excluded, so find the relevant tests separately, inspect the reported consumers, and use those findings to set review scope.

The graph covers the default branch, excluding uncommitted work and other branches. A live repo is remapped after each push to its default branch.

Every repository is live during the trial and on Pro, and each one refreshes and answers.

That matters if the folders you opened in Cursor come from separate repos.

pharaoh_account can request a refresh, but a refresh maps the default branch too, so the graph won't show edits you haven't pushed there.

For how code graph MCP servers differ in indexing and refresh, see this comparison of code graph MCP servers.

Install the GitHub App on the account or organization that owns the repo. Add this remote MCP server in Cursor, then sign in with GitHub:

https://mcp.pharaoh.so/mcp

Set up Pharaoh for Cursor.

For your next shared-helper change, keep the caller you already knew about in the review checklist. Confirm it was inspected and tested before accepting the patch.

Article Record

ReferencesPrimary sources used for this article
  1. Search
  2. Prompting agents
  3. Ignore file
  4. Rules
  5. Securely indexing large codebases ยท Cursor
  6. Multi-root Workspaces
Update HistoryMeaningful revisions to this article
Added a Practical Refactoring Example
  • Replaced the example in the five-phase refactor workflow with a practical scenario to make the process easier to understand and apply.
Initial publication.

More in Claude Code

← Back to blog