Set up Cursor on an existing codebase like a new hire

Learn how to set up Cursor on an existing codebase with .cursorignore, rules and Plan Mode so it helps without touching sensitive parts.

Set up Cursor on an existing codebase like a new hire

If you point Cursor at a large, lived-in repository and let the agent run freely, you can get noisy answers, risky edits and even expose sensitive code to models you did not intend to use. The better approach is to treat Cursor like a new team member: decide what it is allowed to see, give it clear rules, and start with small, reviewable tasks.

Quick verdict

The safest way to set up Cursor on an existing codebase is to start with a tight .cursorignore, enable hierarchical ignores, and add minimal project rules that describe how the repo is structured and how changes should be made. Then use Agent in Plan Mode on a low‑risk task (docs, tests) and review its proposed edits before touching core business logic. This takes 30–90 minutes upfront but avoids index noise, surprises and expensive rework later.

What this guide will help you do

This guide is a concrete onboarding playbook for bringing Cursor into an existing repository. It focuses on:

  • Controlling what Cursor uses for AI context with .cursorignore and hierarchical ignores.
  • Defining project vs user rules so the agent respects your conventions.
  • Choosing a safe, low‑risk first Agent task in Plan Mode.
  • Verifying that sensitive folders and files really are excluded from AI context.
  • Growing from conservative usage to broader changes once you trust the behaviour.

For teams still deciding between Cursor and other coding agents like Claude Code or GitHub Copilot, it can be useful to compare capabilities first. If you are still at the evaluation stage, the comparison in Cursor vs Claude Code 2026 and the broader best AI coding tools shortlist can help you choose your stack. This article assumes Cursor has been selected and focuses on wiring it into a real project safely.

Step 1: Decide how far Cursor is allowed to see

Cursor analyzes files in a project when work is done in a folder and uses tools like Instant Grep and direct file reads to power codebase search and understanding, rather than relying solely on a precomputed semantic index as described in Cursor’s secure-codebase and indexing write‑up and its search documentation. Before opening a main repository in Cursor, decide what level of visibility is acceptable.

Pick a visibility profile for your repo

Use the table below to choose a starting profile. Scope can always be expanded later.

Profile Scope Cursor sees Setup effort Risk of incorrect / risky edits When to choose
Loose Whole repo with only default ignores Very low (0–10 minutes) High Small personal projects with no sensitive data
Controlled Main app & tests; excludes data dumps, infra, secrets Moderate (30–90 minutes) Moderate–low Typical SaaS / product repo with legacy code
Conservative Single service or sanitised clone High (clones, branches, policies) Low Regulated domains, critical legacy systems

The rest of this guide assumes either controlled or conservative is chosen:

  • Controlled: Cursor is allowed to use most of the repo as long as obvious sensitive folders, binary artefacts and data dumps are excluded.
  • Conservative: parts of the repo contain data or regulated code that should never be sent to any online model. In that case, work on a reduced mirror or a standalone service.

When you must not open the main repo at all

If a repository contains highly sensitive data snapshots, credentials or regulated source code (for example banking or health systems), and policy says this code must not be exposed to external models, the safest option is often not to open those folders in Cursor at all. In that case:

  • Create a sanitised mirror of the repo without the sensitive directories, or
  • Check out only the specific service / package where Cursor assistance is desired, into a separate folder.

Cursor’s .cursorignore controls what is included in AI context inside the folder that is open in Cursor, but opening a folder that contains banned material may already violate internal policies, even if those paths are later ignored. For strict environments, keep the sensitive tree out of Cursor’s view entirely and use local-only tools there.

Step 2: Open the project and check default behaviour

Once a scope has been chosen, follow Cursor’s “Your first project” guide to open the relevant folder as a project. When it is opened, Cursor will begin analyzing the codebase to support search and AI assistance.

Cursor’s ignore system ships with a default list and also respects the project’s .gitignore, automatically excluding many common directories and file types from AI context. The ignore-file reference documents the pattern syntax and notes that defaults cover common build artefacts and dependencies; additional patterns should still be added for any binaries, datasets or other files that should not be available to Cursor’s AI features as described in the ignore file reference.

However, these defaults do not know about project-specific secrets folders, internal data dumps or unusual build outputs. A tuned .cursorignore is needed.

Step 3: Create a tight .cursorignore for the repo

Cursor lets teams control what is available to AI using a .cursorignore file at the repository root as documented in its ignore file reference. This file uses glob-style patterns and works similarly to .gitignore.

Understand how .cursorignore behaves

  • Any file or directory matched by .cursorignore is excluded from AI context and codebase search inside Cursor, according to the ignore-file documentation. These files are not used to provide context to the models for editor chat, the agent, or semantic search.
  • There is a built-in default ignore list; a project’s own .cursorignore adds to that list and overrides it where patterns overlap.
  • Terminal commands and external tools invoked from Cursor can still access files on disk even if they are ignored in Cursor, so .cursorignore should be treated as an AI-context control, not an OS-level permission system.

Enable hierarchical Cursor ignore

For monorepos and multi-service projects, hierarchical ignore rules make it easier to scope different parts of the tree. The Cursor documentation explains that this can be toggled via Settings.

In Cursor:

  • Open Settings → Indexing → Ignore Files.
  • Turn on Hierarchical Cursor Ignore (labelled as such in the UI per the ignore file docs).

Screenshot idea: A view of Settings → Indexing → Ignore Files with the “Hierarchical Cursor Ignore” toggle highlighted, so readers can confirm they are in the right place.

Design a base .cursorignore for a typical web/service repo

A base .cursorignore typically excludes:

  • Secrets and credentials: config/secrets.yml, .env*, certs/, keys/.
  • Data dumps and logs: dump.sql, backups/, storage/uploads/, logs/, tmp/.
  • Generated artefacts: dist/, build/, out/, coverage/, .next/ and similar.
  • Large binary assets that are not already covered by defaults, such as proprietary datasets.
  • Vendor/third-party code that should not be changed.

An example starting .cursorignore at the repo root might look like:

# Secrets and environment
.env
.env.*
config/secrets.yml
certs/
keys/

# Data dumps and large storage
*.sql
backups/
storage/uploads/
logs/
/tmp/

# Build artefacts (in addition to Cursor defaults)
dist/
build/
.next/
.coverage/

# Third-party / generated
vendor/
**/generated/

# Optional: infra you do not want indexed
terraform/
helm/
infra/

These patterns should be adjusted to the specific stack, but with a consistent rule: if a path contains data or code that models should never see, it should be placed under an ignored folder or handled in a reduced repo without it.

Use hierarchical .cursorignore for monorepos

In a monorepo, additional .cursorignore files can be added to specific services or packages once the hierarchical setting is on. For example:

repo-root/
  .cursorignore            # broad rules
  services/
    payments/
      .cursorignore       # stricter rules for regulated code
    marketing/
      .cursorignore       # more relaxed
  tools/
    migration-scripts/
      .cursorignore       # possibly fully ignored

The payments service might have:

# services/payments/.cursorignore
# Do not include compliance rules or customer data exports for AI
compliance/
exports/

# Extra secrecy for key-handling code
key_rotation/

With hierarchical mode enabled, Cursor respects both the root and service-level ignore patterns as described in the ignore file docs.

Quick include/exclude table

The table below can be used as a checklist for what typically should be included or excluded from AI context.

Category Example paths Default Cursor behaviour Recommended adjustment
Source code src/, app/, services/* Included Keep included; this is where Cursor adds value.
Tests tests/, __tests__/ Included Keep included; useful for low‑risk tasks.
Docs docs/, README.md Included (unless matched) Include high-level docs; be careful with sensitive docs.
Dependencies node_modules/, .venv/ Often ignored by default Usually no change needed, but verify for each stack.
Secrets .env, config/secrets.yml May be included Add explicit ignores for all secrets paths.
Data dumps *.sql, backups/ May be included Ignore; they add risk and noise.
Build outputs dist/, build/, .next/ Some ignored by default Ensure project-specific folders are ignored.

Step 4: Add project rules vs user rules

Ignoring the right things reduces risk. Teaching Cursor how a repo is structured improves usefulness. Cursor supports rules for this: instructions the agent follows when working in a project.

The rules documentation explains several kinds of rules in the Cursor rules guide:

  • Project rules – stored in the repository (for example under .cursor/rules) so everyone shares them.
  • User rules associated with a Cursor account – managed through the Cursor UI; these sync when signed in on another machine.
  • Legacy local user rule files – stored under ~/.cursor/rules (or %USERPROFILE%\.cursor\rules on Windows) and not synced between devices.

Project rules are used for shared conventions and constraints that should be true for every contributor. Common examples (adapted from community best‑practice templates such as the “make codebase cursor compatible” guide) include:

  • Directory layout and responsibilities (for example “apps/web is the Next.js frontend, apps/api is the REST backend”).
  • Tech stack versions and major dependencies (for example “React 18, Next.js App Router, Prisma ORM”).
  • How to add or change features (for example “for new endpoints, follow the pattern in apps/api/routes/users.ts and add tests under apps/api/tests”).
  • Safety rules (for example “do not modify code under legacy/ without explicit instruction” or “never add direct SQL queries; always use the repository layer”).
  • Git and CI policies (for example “don’t push directly to main; create a branch and open a PR”).

Project rules can be defined through the Cursor UI or by adding a rules file at the project root as recommended in community tutorials on Cursor basics. The exact filename and format may evolve over time, but the underlying idea is the same: shared rules live in the repo and are version-controlled.

A concise project rules file might say, in plain language:

# Project overview
- This is a monorepo with apps/web (Next.js frontend) and apps/api (Node API).
- Shared types live in packages/types.

# Implementation rules
- For new API routes, follow the pattern in apps/api/routes/users.ts.
- Add tests for new routes in apps/api/tests.

# Safety
- Do not edit code in legacy/ unless explicitly asked.
- Never add plain SQL queries; always use the repository functions in apps/api/db/.
- Never commit or print environment variables.

# Git & CI
- Create a feature branch for any non-trivial change.
- Do not push directly to main; changes are merged via PR and CI.

Cursor’s agent documentation describes how the agent uses such rules when planning and applying changes in its overview. If you want a deeper template for what belongs in rules for a production repo, see the dedicated patterns in Cursor rules for a real project.

What belongs in user rules

User rules that are tied to a Cursor account and managed in the UI are well suited to:

  • Individual style preferences (within the organisation’s standards).
  • Personal shortcuts (for example “when asked to draft tests, prefer Jest and Testing Library”).
  • Personal safety defaults (for example “prefer Plan Mode unless explicitly instructed otherwise”).

Legacy local rule files under ~/.cursor/rules or %USERPROFILE%\.cursor\rules behave similarly but remain on the local machine and do not sync.

Personal preferences should not be mixed into project rules; that creates friction in code review and unpredictable behaviour for other developers. Shared behaviour belongs in the repo; personal behaviour belongs in account-level user rules or, where explicitly desired, local rule files.

Governance: who owns .cursorignore and rules?

Cursor’s primary mechanism for scoping which files AI can see in a project is repo-level .cursorignore files, plus optional global ignore patterns in user settings. Team and Enterprise plans add central rule management, but they do not currently expose a comprehensive, centralised .cursorignore policy interface comparable to a full data loss prevention system. Governance therefore still largely relies on version control:

  • Treat .cursorignore and project rule files like code.
  • Make changes via pull requests, reviewed by a senior developer or tech lead.
  • Optionally add CI checks to ensure these files exist and meet basic standards. The safe AI-in-CI patterns in this GitHub Actions workflow guide can be adapted for such checks.

Step 5: Verify that ignores and rules are really working

Before letting Cursor make any edits, it is important to confirm that ignores and rules behave as expected.

Check that sensitive files are excluded

Once .cursorignore is in place and the project has been re-opened if required:

  • Use Cursor’s search (Instant Grep or semantic search, described in its “Understanding Your Codebase” material) to look for a string that appears only in an ignored file (for example a fake key like FAKE_SECRET_123 added to a test file under an ignored folder).
  • Confirm that search returns no results. The ignore docs state that files matched by .cursorignore are excluded from indexing for AI features and codebase search.

Screenshot idea: a code search panel where a term present only in backups/dump.sql yields no results, demonstrating that backups/ is correctly ignored.

Confirm that rules influence the agent

Next, test that project rules are picked up:

  • Ask the agent something small that should trigger the rules. Example: “Add a new API route to list invoices.”
  • Verify that Cursor proposes changes in the directories and patterns specified (for example apps/api/routes with tests under apps/api/tests), and obeys “do not touch legacy/” style constraints.

Screenshot idea: the project tree in Cursor showing a rules file (for example .cursor/rules) and .cursorignore at the root, so developers can see where these should live.

Step 6: Choose a low‑risk first task and use Plan Mode

Cursor’s Agent can search a codebase (using tools like Instant Grep and semantic search), edit files, and run configured tools such as tests, git commands and terminal tasks as part of an automated workflow per the current Agent overview docs. That capability is useful but potentially risky on a production repo. Cursor offers Plan Mode as a safer on‑ramp.

The Plan Mode documentation explains that Cursor will research the codebase, create a step‑by‑step implementation plan, and ask clarifying questions before making edits in the Plan Mode guide. The plan can then be reviewed, with steps accepted or rejected.

Why Plan Mode first

Using Plan Mode for initial tasks provides three safety nets:

  • It shows exactly which files Cursor intends to touch.
  • It can be stopped if it attempts to modify ignored or sensitive areas (which would indicate misconfiguration).
  • It reveals how well Cursor has understood the architecture and rules before it is trusted with more complex refactors.

Good candidates for a first task

Suitable initial tasks share these traits:

  • The blast radius is small (for example just tests or documentation).
  • There is a clear source of truth (existing behaviour and expectations).
  • The diffs are easy to review.

Some concrete options:

  • Synchronise documentation with existing code. For example, “Update docs/api.md so that all endpoints listed reflect the handlers currently implemented under apps/api/routes.”
  • Improve or fix flaky tests. For example, “Identify flaky tests under apps/api/tests and rewrite them to be deterministic.” Once this pattern is comfortable, background agents for test fixes become viable.
  • Add type annotations or comments. For example, “Add TypeScript types to functions in src/utils/date.ts and explain each in a short comment.”

Running the first task in Plan Mode

In Cursor (exact UI text may change slightly over time, but the documented flow is):

  1. Open a relevant file (for example a test file) so Cursor has context.
  2. Open the Agent panel and select Plan Mode.
  3. Paste a prompt such as:

    "In Plan Mode only: improve the tests in apps/api/tests/invoices.test.ts to make them easier to read without changing behaviour. Follow project rules and do not touch any files under legacy/ or infra/."
  4. Let Cursor generate the plan. It will show a list of steps and the files it intends to edit.
  5. Carefully review each step:
    • Are all files within the non-sensitive, non-ignored areas expected?
    • Is it following the project rules (for example adding tests in the right folder)?
  6. Approve only if the plan is acceptable. Otherwise, adjust the rules or .cursorignore and re-run.

Screenshot idea: a Plan Mode screenshot showing the step list (for example “Edit apps/api/tests/invoices.test.ts to refactor test names”) and file list, illustrating what a safe reviewable plan looks like.

Review AI-generated diffs carefully

Once a plan step is accepted and Cursor applies changes, the resulting diffs should be treated like those from any new teammate:

  • Review the diff line by line.
  • Run local tests or checks.
  • Commit to a branch and open a pull request; do not push directly to main.

The patterns in this structured AI-assisted code review workflow can be adapted to help review Cursor’s diffs as well.

Step 7: Gradually expand what Cursor is allowed to do

Once indexing and rules have been validated and Plan Mode behaves well on low‑risk tasks, Cursor can gradually be used for more substantial work while still keeping strong guardrails.

Expand the task types, not just the scope

A typical progression looks like:

  1. Docs & tests in Plan Mode – as described above.
  2. Small, isolated functions – for example refactoring utility functions or adding new helpers, still in Plan Mode.
  3. Feature scaffolding – letting Cursor draft new files or skeletons following existing patterns, while humans own the final logic.
  4. Larger refactors – only once it is clear that ignores, rules and the CI process are being respected.

Even when confidence is high, a policy of “no direct production pushes from Cursor” remains advisable. Cursor should be combined with branch/PR-based workflows and CI. For more robust patterns, the safe CI agent workflows in this GitHub Actions article show how to keep AI changes safely behind branches and automated checks.

Be conscious of model usage and cost

Cursor’s current public pricing page shows tiers from Free up to Ultra and notes that third‑party models are not included in any monthly subscription price; the Models & Pricing docs state that on Premium and above, third‑party models like Claude, GPT and Gemini are available in Cursor at the model’s API list price from the first request, billed against prepaid credit rather than covered by a bundled allowance on the public pricing page and models and pricing docs. Heavy use of Plan Mode and the agent on large repos can therefore translate into meaningful usage of those paid models.

For a deeper breakdown of how Cursor fits alongside other tools and how model billing stacks up, see analyses that compare Cursor, Codex, Claude Code and similar tools. The practical implication here is:

  • Prefer targeted, well-scoped Plan Mode tasks over long, open-ended agent runs.
  • Use semantic search and Instant Grep for quick understanding where possible, as described in Cursor’s codebase understanding guide.

Step 8: Establish a team-wide onboarding playbook

Once a working setup exists, it can be codified so new team members can onboard Cursor safely. A simple one-page internal document can include:

  • Which repo folders are safe to open with Cursor (and which are not).
  • Where .cursorignore and project rules live and who maintains them.
  • How to enable hierarchical .cursorignore in Settings.
  • A standard first Plan Mode task (for example “improve tests for feature X in this file”) for new users.
  • Policy: always use branches and PRs; never push AI-generated changes directly to protected branches.

Cursor can reuse a teammate’s existing analysis of a large repo to speed up onboarding on large codebases according to its secure indexing article, so getting this setup right once pays off each time a new developer joins or switches machines.

For teams that lean heavily on CI-based agents instead of IDE agents, or want to keep all high-risk changes in CI, the patterns in this CI workflow guide may be a better primary foundation, with Cursor used mainly for exploration and small local edits.

What changes the decision

The playbook above assumes a typical SaaS or product codebase. In a few situations, usage of Cursor or the way it is introduced may need to be adjusted, or avoided entirely for parts of the repo.

Highly sensitive or regulated code

If the repo contains code or data that must not be exposed to external models (for example production banking or healthcare code, or real customer data exports), Cursor should be limited to:

  • Local-only tooling on sanitised mirrors or demo projects, or
  • Non-sensitive subfolders that can be opened independently.

Even with careful .cursorignore usage, policies in such environments often require that sensitive trees are never opened in cloud-connected tools.

Extremely large monorepos

For very large monorepos where latency or answer quality becomes an issue, a good starting point is to:

  • Scope Cursor to one or two critical services instead of the whole tree.
  • Use hierarchical .cursorignore to aggressively ignore unrelated packages and infra.

This narrower view reduces noise and often makes answers more relevant.

Teams needing centralised policies

Organisations that expect a central admin UI to manage which files AI tools can see should be aware that while Cursor provides repo-level .cursorignore, user-level global ignore patterns and team rule management, it does not currently offer a comprehensive, centralised .cursorignore enforcement system across all repos and users comparable to dedicated DLP products. Standardisation therefore typically looks like:

  • Using repository-level .cursorignore and project rules as the primary controls.
  • Managing them via normal code review and governance.

Different personal workflows on the same repo

When most developers want different personal workflows but share the same conventions, repositories’ rules should stay focused on architecture and constraints, and each developer can customise Cursor behaviour through account-level user rules (and, where needed, local rules in ~/.cursor/rules). Personal preferences should be kept out of the project rules file.

Teams with tight AI usage constraints

For teams on tiers with limited AI usage, or where internal policy demands tight control of model calls, it is helpful to prioritise:

  • Using Cursor’s semantic search and Instant Grep to understand code quickly.
  • Running small, targeted Plan Mode tasks instead of broad, free-form agent sessions.

This preserves most of the value while keeping model calls fewer and more predictable.

Key takeaways

  • Avoid opening a whole monorepo and starting edits without preparation. Decide what Cursor should see and create a tight .cursorignore before any serious work.
  • Enable hierarchical ignores and use them. Put stricter .cursorignore files in especially sensitive services or legacy areas.
  • Split rules correctly: shared conventions and safety constraints live in project rules; personal preferences stay in user rules associated with the Cursor account (or in local rule files where explicitly desired).
  • Verify configuration. Use search to confirm ignored files are not indexed and run a small agent query to check rules are respected.
  • Start with Plan Mode on low‑risk tasks. Docs and tests are ideal for validating Cursor’s understanding before it touches core logic.
  • Treat Cursor like a new team member. Keep changes behind branches and CI, and manage its configuration via pull requests and review.

FAQ

Can Cursor see or use files that are listed in .cursorignore?

According to Cursor’s ignore file documentation, any file or directory matched by .cursorignore is excluded from AI context and codebase search in Cursor, so it is not used to provide context to models for editor chat, the agent, or semantic search. Terminal commands and external tools can still access files on disk, so .cursorignore should not be treated as an OS-level permission system.

Where should .cursorignore be placed in an existing repository?

A primary .cursorignore should be placed in the repository root to define global rules. If hierarchical ignore is enabled in Settings, additional .cursorignore files can also be added in subdirectories, such as individual services in a monorepo, for more granular control.

How do project rules differ from user rules in Cursor?

Project rules live in the repository (for example under .cursor/rules) so that all contributors share the same conventions and safety constraints and they are version-controlled. User rules tied to a Cursor account are managed through the UI and sync across machines when signed in, making them suitable for individual preferences and personal workflows. Legacy local user rule files under ~/.cursor/rules or %USERPROFILE%\.cursor\rules are similar in intent but remain on the machine and do not sync.

Is Plan Mode safer than letting the agent edit files directly?

Plan Mode is designed for safer changes in existing repositories because it first generates a step-by-step implementation plan and shows which files will be edited. This plan can be reviewed and approved or modified before any code changes are applied.

What if a company bans sending certain code to external AI models?

If policy forbids exposing specific parts of the codebase to external models, those folders should not be opened in Cursor at all. Work should instead be done with sanitised clones, non-sensitive subdirectories, or local-only tools on the restricted code, even if .cursorignore is used elsewhere.