Describe the Bug
In a monorepo, Cursor injects the same AGENTS.md file several times as <always_applied_workspace_rule>. It does this once for each symlinked path that resolves to the file. In my workspace this put 471.5K tokens into the Rules category. The context window is 300K, so the context was 181% full before any real conversation. The agent has to summarize again and again from the first turn.
Data from the context-usage panel:
| Category | Tokens |
|---|---|
| Rules | 471.5K |
| MCP & dynamic tools | 32.4K |
| Summarized conversation | 13.1K |
| Skills | 9.5K |
| Tool definitions | 7.5K |
| Conversation | 3.8K |
| System prompt | 2.1K |
| Subagent definitions | 2.0K |
| Total | ~542K / 300K (181%) |
The Rules category held 20 files:
- 9 copies of
vercel-react-best-practices/AGENTS.md. Each copy is byte-identical, and each is about 99.8K chars. The source file is 106 KB, so each copy has the[truncated: AGENTS.md is 106 KB; only the first 100 KB is …]marker. - 9 copies of
vercel-composition-patterns/AGENTS.md. Each copy is byte-identical and about 15.9K chars. - The root
AGENTS.mdand the rootCLAUDE.md. These two are about 72K chars each and almost identical.
Git contains only one real copy of each skill file. The other 8 paths are symlinks. The repo layout is:
packages/skill-pack/.agents/skills/
vercel-react-best-practices/AGENTS.md <- the only real file
vercel-composition-patterns/AGENTS.md
packages/skill-pack/.claude/skills/vercel-* -> ../../.agents/skills/vercel-* (symlink)
apps/<app-N>/.agents/skills/pack -> ../../../../packages/skill-pack/.agents/skills (symlink, 8 apps/packages)
apps/<app-N>/.claude/skills/pack -> ../../.agents/skills/pack (symlink)
The 9 injected paths look like this. 8 of them go through .claude/skills/... and 1 goes through .agents/skills/...:
apps/app-1/.claude/skills/pack/vercel-react-best-practices/AGENTS.md
apps/app-2/.agents/skills/pack/vercel-react-best-practices/AGENTS.md
packages/skill-pack/.claude/skills/vercel-react-best-practices/AGENTS.md
...
Other observations
- Cursor does not inject every nested
AGENTS.md. Other nested ones, such as a 37K-charapps/<backend>/AGENTS.md, were not injected. Only the files that live inside skill directories were injected. - In the context-usage panel, the per-file
estimatedTokensvalues add up to 296.6K. That sum equals chars ÷ 4. The Rules category total is 471.5K, which is about 2.5 chars/token. The two numbers do not agree. - Claude Code and Codex CLI on the same repo do not show this problem. Codex injects only the root
AGENTS.md, and its first turn is about 46K tokens in total.
Related: #164295 (symlink double-counting, 2 copies) and #165337 (nested AGENTS.md in monorepos). This report is the same dedupe problem at 9× scale, inside skill directories.
Steps to Reproduce
- Put a large
AGENTS.mdinside a skill directory, for examplepackages/skill-pack/.agents/skills/big-skill/AGENTS.md. - Symlink that skills directory into several workspace packages, for example
apps/a/.agents/skills/packandapps/b/.agents/skills/pack. - Open the repo root in Cursor and start an Agent chat.
- Open the context-usage view. The Rules category lists the same
AGENTS.mdonce for each symlinked path.
I observed this in the repo structure above. I have not yet confirmed it in a minimal standalone repo.
Expected Behavior
- Cursor resolves symlinks with realpath and injects each unique file only once.
- Ideally, Cursor does not treat an
AGENTS.mdinside a skill directory as an always-applied workspace rule. That file is the skill’s reference material, and it should load only when the skill is used. - Cursor tells the user, or refuses to start, when always-applied rules alone exceed the context window.
.cursorignoreor a setting can exclude a path from rule discovery. Please confirm whether this is already possible.
Operating System: macOS 26.5.1 (arm64)
Current Cursor Version: 3.27.14
Does this stop you from using Cursor: Yes. Every new chat in this repo starts over the context limit.