You gave Cursor a clear instruction: do not modify files in src/auth/.
Cursor opened src/auth/session.ts and rewrote the token refresh logic.
No error. No warning. It simply decided that instruction did not apply to this particular edit.
This is the most common source of broken Cursor Agent runs — and it is not a bug. It is by design.
Why .cursorrules Has No Scope
.cursorrules is a single global file. Every instruction in it applies to the entire project.
When you write a rule like "do not touch the auth module", Cursor reads that as a preference, not a boundary. The model interprets it contextually. If the current task seems related to auth, the model may proceed anyway because it is trying to be helpful.
There is no file-level or folder-level enforcement. The rule does not know what src/auth/ is.
What Actually Works: Scoped .mdc Rules
The proper system for scoped rules is .cursor/rules/*.mdc. Each file can be scoped with globs frontmatter.
Example — protecting your auth module:
---
globs: src/auth/**
---
# Auth Module — DO NOT MODIFY
Never modify files in this directory without explicit instruction.
Always ask before editing: session.ts, token.ts, middleware/auth.ts
With glob scoping, Cursor only applies this rule when working on files matching that pattern. The boundary is enforced, not advisory.
The Fix: Restructure Your Rules
Move from .cursorrules prose to scoped .cursor/rules/*.mdc files:
.cursor/
rules/
general.mdc # globs: **
auth-protected.mdc # globs: src/auth/**
api-readonly.mdc # globs: src/api/**
tests.mdc # globs: **/*.test.ts
Why This Matters for Agent Mode
In Agent mode, Cursor chains multiple edits across files. A misapplied rule can cascade into several unintended changes before you review the diff. Scoped rules stop that cascade at the boundary.
Ready-to-Use Scoped Rules
If you want a complete .cursor/rules/ structure already built — auth protection, API guard, test isolation, agent mode controls — the Cursor Rules Pack v2 has 25+ rules ready to drop in.
. No setup required. Works with Agent mode and normal Cursor.
Prefer to start free? Free Starter Kit — sample rules to test the structure before committing.
Top comments (0)