Verified against Cursor · 2026-07-24
Tell Cursor which package actually owns a change in a multi-root monorepo workspace
A context brief for Cursor's multi-root workspace support that names the owning package, treats sibling packages as read-only context, and states shared-file boundaries, so semantic search across the flattened index doesn't cross package lines while looking for a similarly named symbol.
The prompt
Ready to copy — highlighted parts are example details you can swap.
This workspace has multiple roots open at once, and the codebase index treats them as one searchable space by default. Before editing anything, confirm which root and package this change actually belongs in. OWNING PACKAGE FOR THIS CHANGE packages/checkout-service SIBLING PACKAGES IN THIS WORKSPACE — context only, do not edit these packages/shared-ui, packages/payments-sdk, packages/admin-dashboard SHARED FILES / ROOT-LEVEL BOUNDARY RULES pnpm-workspace.yaml and the root tsconfig.base.json are off-limits without asking first. packages/shared-ui/src/index.ts (the public export list) requires confirmation before adding new exports. PACKAGE-SCOPED COMMANDS TO USE pnpm --filter checkout-service test, pnpm --filter checkout-service lint, pnpm --filter checkout-service build RULES - Make all edits inside the owning package unless a shared file must change to satisfy the task — if so, name the shared file explicitly and ask before editing it, even if the change looks trivial. - If a symbol, type, or utility you need already exists in a sibling package, import it from there. Do not redefine or fork a local copy inside the owning package, even if that seems faster or avoids adding a cross-package dependency — say if importing it would require adding one, and ask first. - Don't run a workspace-wide build, lint, or test command when a package-scoped equivalent exists. Use the commands named above and state exactly which one you ran and against which package. - If the semantic search for "where does X live" surfaces a same-named symbol in more than one package, stop and confirm which one is actually relevant before assuming it's the one in the owning package. Before finishing, state explicitly whether any shared or root-level file was touched, and if so, why it was unavoidable given the task.
Customize
Optional — swap in your own details for the highlighted parts above.
Why this works
Multi-root workspace support means Cursor's indexer sees several package roots at once and its semantic code search treats that as one searchable space by default — that's the point of the feature for cross-package navigation, but it also means a similarly named file or function in another root is a plausible edit target unless the agent is explicitly told which root actually owns this specific change. Without OWNING_PACKAGE stated up front, a "closest semantic match" search across roots can surface a same-named helper in a sibling package as the thing to modify, or the model can duplicate a type that already exists in a package it was never told to treat as read-only, producing two divergent copies of the same concept that will silently drift apart the moment one gets updated and the other doesn't. Naming shared-file boundaries closes a second, more damaging gap: monorepo root config — workspace manifests, base tsconfig, a shared package's public export list — affects every package silently and simultaneously, so an edit there is exactly the kind of change that should never happen without an explicit ask, even though nothing in a narrowly scoped task description would obviously exclude it from an agent reasoning purely from "what files need to change to make this work." Requiring package-scoped commands over workspace-wide ones prevents a slower but real failure mode where a workspace-level test run silently exercises and reports on packages the change never touched, producing a results summary that looks like broader verification happened when it actually just added noise and runtime without adding signal. The explicit stop-and-confirm rule for ambiguous same-named symbols matters because that ambiguity is invisible from inside a single search result — the agent sees one plausible match per package and has no built-in reason to suspect there's a second one worth checking unless told the possibility exists.
Verified against
Cursor 2.2 · 2026-07-24
Changelog
- 2026-07-24 — Initial publish, verified against Cursor 2.2 multi-root workspace support in a pnpm monorepo.
Need this built into your business?
If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.
EXPLORE CUSTOM SOFTWARE
