Cursor loads all rules from all folders in monorepo and blows past context limits $$

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

We have a big monorepo, many folders have their own AGENTS.md file. There are several hundred AGENTS.md files across the repo. If I load the root of the repo in Cursor, then run an agent (typically specifying a specific file+line in my prompt), it will often load all rules files across the entire repo, loading e.g. 600k tokens worth of rules, immediately blasting past my e.g. 300k context window. This also causes massive $$$$$$ use which makes Cursor economically insanely expensive, yield extremely slow results as it seems to think and do “Chat context summarized” dozens of times, and in the end yield bad quality results.

This problem started occurring in Cursor 3.6 and mostly always happened since then, until 3.10 when it seemed to sometimes work, but sometimes I still have this issue and I don’t know how to get out of it. I’ve never once had the problem in Cursor 3.5 or earlier, so I frequently find myself reinstalling 3.5 and then avoiding “restart to update” (or else reinstalling 3.5 every time I accidentally update).

Steps to Reproduce

Have a large project (e.g. monorepo) with a lot of AGENTS.md files in folders/subfolders across the project. Create a new agent and do any prompt. Even something as simple as “hi” would cost $5, but being very specific and quoting a specific file (e.g. Ctrl+L) has the same problem.

Expected Behavior

Only the relevant AGENTS.md rules are loaded for a given prompt. In older versions of Cursor before 3.6, I had never seen this issue.

Screenshots / Screen Recordings

Operating System

Windows

Version Information

Version: 3.10.17 (user setup)
VS Code Extension API: 1.125.0
Commit: c89f45b831621cdc5e951694db44fecd8fab1150
Date: 2026-07-05T06:39:45.228Z
Layout: IDE
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.256
OS: Windows_NT x64 10.0.26200

For AI issues: which model did you use?

Opus 4.8

Does this stop you from using Cursor

Yes - Cursor is unusable

Hi @vulture-1234 Thank you for the forum post! AGENTS.md files are “Always” rules, so their full contents load on every request. Since 3.6, Cursor discovers nested AGENTS.md files across the entire repo (not just the folders above where you’re working), so a monorepo with hundreds of them loads them all at once. That’s what blows past the context window and drives the cost and constant re-summarizing.

The good part is it’s fully in your control. Here are the three best ways I can see that can solve this:

  1. Open a subfolder, not the repo root - fastest fix, zero migration.
  2. Convert nested AGENTS.md to scoped .mdc rules - most thorough, scriptable.
  3. Consolidate - one small root file, drop the rest.

Taking a deeper look at each possible mitigation route:


1. Open the specific package/folder as your workspace
Rule discovery walks outward from whatever folder you open, so opening the subtree you’re actually working in only loads the AGENTS.md files inside it. Fits your “I’m targeting one file/area” workflow. A multi-root workspace with just the folders you need works too.

2. Convert nested AGENTS.md files into scoped rules

Every AGENTS.md file is treated as “Always” applied: its full contents load on every request, no matter what you’re working on, and there’s no setting inside the file to change that.

Cursor’s other rule format, .cursor/rules/*.mdc, lets you scope a rule to a folder. Add a globs: field and the rule becomes “Auto Attached”, so it only loads when the agent actually touches a file in that folder.

So move each AGENTS.md’s content into a scoped .mdc rule. For example, replace backend/services/AGENTS.md with backend/services/.cursor/rules/services.mdc:

---
description: Backend services conventions
globs: ["backend/services/**"]
alwaysApply: false
---
(your existing AGENTS.md content here)

Now that rule only loads when the agent works under backend/services/, instead of on every prompt. You can script this across the repo (one .mdc per folder, globs pointing at that folder) so you don’t convert hundreds of files by hand.

3. Consolidate
Keep one small root AGENTS.md for genuinely repo-wide conventions, and merge or drop the deeply nested ones that rarely apply.

You can watch the payload drop live in the same context explorer you screenshotted, or in Settings > Rules, where anything marked “Always applied” is loading on every request. More on rule types and folder scoping: Rules | Cursor Docs

  1. Impossible, we have a single workspace monorepo and we need to load the root.
  2. I’m not sure this solution works for us due to needing compatibility across other harnesses:

Because we have people also using Claude Code (and other harnesses) in our monorepo, whatever solution will also need to be compatible with those harnesses as well. Claude Code’s behavior is specifically:

  1. Ancestor files (loaded eagerly at launch) – Claude Code walks up the directory tree from wherever you started the session, loading every CLAUDE.md it finds along that path (note: we symlink claude.md to agents.md to make this cross compatibility across whatever harness devs prefer) from the filesystem root down to your working directory, concatenated in order.
  2. Files in subdirectories below your working directory (loaded lazily) – these are not loaded at launch. They’re pulled in on demand only when Claude actually reads a file in that subdirectory.

So with hundreds of AGENTS.md/CLAUDE.md files scattered across a monorepo, you will not get all of them dumped into context at once, only: (1) the chain of files above/at your working directory (eager), plus (2) whichever subdirectory files get touched as Claude works (lazy, on-demand).

“Converting” AGENTS.md files to .mdc is a non-starter because again it prevents cross-compatibility with other harnesses.

  1. We have 300K tokens worth of rules across the monorepo, there isn’t a way to “keep one small root” one because there are tons of them.

In the end here, it seems like the “Always” rule is the problem if it’s going to include all files in all folders/subfolders – especially when other harnesses work exactly the opposite of this. Is there a way to switch from “Always” to something more on-demand, while retaining our cross-harness compatibility?