Composer doesn’t read your whole repo. It works from the dozens of chunks embedding retrieval gave it. In small repos, top-K covers everything; in a 10k+ file monorepo where every concept has a dozen variants, retrieval only sees one or two and the model fills the gaps with guesses. The visible damage: it edits module A and forgets module B that imports from A; it suggests import paths that don’t exist; old patterns from packages/old-app slip into packages/new-app.
Fixing this isn’t a setting flip — it’s a change in how you collaborate with Composer.
Common causes
1. Retrieval only covers top-N, not enough surface
Composer slices the repo into 200-500 line chunks and embeds them. “Fix auth” pulls the top 10-20 most relevant chunks. In a 100k-LOC auth subsystem that’s like looking at the room through a keyhole.
How to judge: after a Composer reply, ask “List exactly which files you read.” If it lists 3-5 files and misses ones you know are relevant, retrieval coverage is the issue.
2. Monorepo has multiple same-named patterns
packages/web/utils/fetch.ts and packages/admin/utils/fetch.ts share the name with different implementations. Similarity ranking can drop the admin version into a web prompt and the model copies it.
How to judge: scan generated import paths for boundary crossings (e.g. packages/web/... importing from packages/admin/internal/...).
3. Working directory is the repo root
By default the workspace root is the working directory, so every file is in the search surface. Narrowing to apps/web shrinks retrieval surface by an order of magnitude and quality jumps.
How to judge: look at the bottom-left workspace path; if it’s the repo root in a monorepo, it’s too wide.
4. No .cursorrules describing package boundaries
Without rules, the model has no map of which path belongs to which package, what’s public API, what’s internal. It guesses from the file path alone.
How to judge: ls -la <repo-root> | grep cursor — no .cursorrules or .cursor/rules/ means no boundary map.
5. One prompt spanning many packages
“Standardize the logger across all microservices” can’t guarantee retrieval covers every package. Composer edits the ones it sees and silently skips the rest.
How to judge: after the edit, grep -r "old_logger" . — leftover hits mean packages were missed.
6. Index is stale or .cursorignore is too aggressive
If the last full index ran two weeks ago, newer directories simply don’t exist to retrieval. An over-broad .cursorignore (e.g. **/*.test.ts) hides test files Composer would otherwise reference.
How to judge: Settings → Features → Codebase Indexing → look at “Last indexed.” Open .cursorignore and audit coverage.
Before you start
- Identify whether the issue is in Composer or Cmd+K — Cmd+K skips repo-wide retrieval entirely and behaves differently.
- Commit or branch before reproducing so applies don’t trash unsaved work.
- Note Cursor version and current model. Long-context handling varies widely (opus / gpt-5-long beats sonnet on 200k context).
Info to collect
- Repo size in files and LOC; whether it’s a monorepo or single package.
- Whether
.cursorrules/.cursorignoreexist; last index timestamp. - Active model, whether Max mode is on, screenshot of @Files attached in Composer.
- The model’s own answer to “Which files did you actually read?”
Shortest fix path
Ordered by ROI. The first two usually flip the result immediately.
Step 1: Hand-attach 5-10 highly relevant files via @Files
Biggest lever. Before the task, in Composer input:
@target-file.ts
@reference-pattern-1.ts
@reference-pattern-2.ts
@target-file.test.ts
@types/relevant.ts
And: “follow the pattern shown in reference-pattern-1.ts exactly.”
Step 2: Shrink the working directory
Cursor → File → Open Folder → pick apps/web, not the monorepo root. Retrieval surface shrinks to a single package and cross-pollination basically stops.
Step 3: Per-package .cursorrules
packages/web/.cursorrules:
This is the customer-facing web app.
- Imports MUST stay inside packages/web/* or packages/shared/*.
- Never import from packages/admin/* or packages/internal-tools/*.
- Use the Logger from packages/shared/logger, not console.log.
- API calls go through src/api/client.ts; do not call fetch() directly.
Cursor prefers nearest-rules so each package stops bleeding into others.
Step 4: Make Composer report context before writing
Two-step prompt:
Step 1: List exactly which files you've loaded into context and explain how each relates to the task. Do NOT write code yet.
Step 2: After I confirm, implement the change.
If the file list is wrong, stop and add @Files. If it’s right, let it continue.
Step 5: Decompose cross-package tasks
Don’t say “standardize all microservices.” Say:
Task scope: only packages/auth-service for now.
Goal: replace all usage of old_logger with shared logger.
Move to the next package in a fresh Composer turn.
Step 6: Reindex
Settings → Features → Codebase Indexing → “Reset index” → wait 5-30 minutes. Audit .cursorignore while waiting.
How to verify the fix
- Run the same prompt before and after narrowing the working dir; cross-package pollution should disappear.
- Have a teammate open the same workspace with the same prompt — they should see the same improved behavior.
- Run grep / lint to physically confirm import paths no longer cross package boundaries.
If it still fails
- Reduce the prompt to its minimum: one function, one @File, explicit path.
- Roll back the most recent Cursor upgrade or
.cursorruleschange. - Search forum.cursor.com for “monorepo composer context”; include version + repo size numbers.
- Grab View → Output → Cursor logs and post to Bug Reports.
Prevention
- Every package gets its own
.cursorrulesspelling out boundaries, conventions, banned imports. - Each package README has a “If you edit X also edit Y” section to anchor the model.
- Pin 5-10 core reference files in workspace tabs — Composer’s retrieval up-ranks them.
- For huge refactors, use a CLI agent (Claude Code) for scanning and reserve Cursor for in-editor spot edits. Don’t make Cursor do the impossible alone.
- Standardize on “list context first, then code” as your team prompt template.
Related reading
- Cursor missed project context
- Cursor stuck indexing
- Cursor context panel missing files
- Cursor generates duplicate logic
- Cursor rules not loaded
Tags: #Troubleshooting #Cursor #Debug #Composer large project