Rules/Skills context served from stale agentEnvironment cache after rule files are deleted

Where does the bug appear (feature/product)?

Cursor IDE - Rules, Skills, and the Context Usage panel

Describe the Bug

The Context Usage panel reports ~5.9K tokens of Rules and ~2.1K of Skills in brand-new chats after every rule and skill file has been removed from disk. Cursor appears to serve the rule/skill index from a cached snapshot in the global state database and does not invalidate it when the underlying files change, so every conversation is charged for rules that no longer exist. Because the whole prefix is re-sent each turn, the cost repeats for the life of every chat. Users who deliberately trim their rule set to control context see no benefit from doing so.

Steps to Reproduce

  1. Start with a populated rule set: 36 .mdc files in ~/.cursor/rules/, 5 in the workspace .cursor/rules/, 7 skills in ~/.cursor/skills/. Context Usage shows Rules 6.7K, Skills 2.1K.
  2. Move every rule and skill file to a directory outside .cursor. Leave both .cursor/rules folders empty and delete the alwaysApply: true rule.
  3. Confirm nothing remains: no .mdc under ~/.cursor, no AGENTS.md, no .cursorrules, no nested .cursor/rules or .cursor/skills, and no ~/.agents, ~/.claude or ~/.codex.
  4. Open a new agent chat and view Context Usage.

Expected Behavior

Rules reports 0, since no rule file exists in any documented location.

Actual Behavior

Rules reports 5.9K and Skills 2.1K in every new chat, essentially unchanged from the populated state and stable across repeated new chats.

Evidence of the stale cache

In ~/AppData/Roaming/Cursor/User/globalStorage/state.vscdb, table ItemTable:

agentData.cacheStorage.agentEnvironment.slashMenuItems.v2.local.glass.empty-window    15,679 chars
agentData.cacheStorage.agentEnvironment.slashMenuItems.v2.local.glass.5478...4f1ecf   15,679 chars

Both blobs still contain skill entries whose files had been moved out of .cursor roughly 40 minutes earlier, e.g. {"id":"skill-anm/SKILL.md","name":"anm","description":"ANM (Notification Manager)...","type":"skill"}.

Deleting rows matching agentData.cacheStorage.agentEnvironment% with Cursor closed is the only workaround I found.

Operating System

Windows 10.0.26200

Current Cursor Version

Version: 3.11.25
Commit: fc2563ec93d793fc275eef734405a4fdf8b47b20
VS Code base: 1.125.0

Additional Information

Request ID: <paste via chat “…” menu → Copy Request ID>

Related feature request, which is why this bug is costly rather than cosmetic: conditional per-prompt rule loading is currently impossible. beforeSubmitPrompt accepts only continue and user_message, so a hook cannot inject context based on prompt content; only sessionStart supports additional_context and it fires unconditionally, costing the same as an alwaysApply rule. Adding additional_context to beforeSubmitPrompt would let users load a workflow only when its trigger word appears.

Hi there!

We detected that this may be a bug report, so we’ve moved your post to the Bug Reports category.

To help us investigate and fix this faster, could you edit your original post to include the details from the template below?

Bug Report Template - Click to expand

Where does the bug appear (feature/product)?

  • Editor, Tab & Chat (autocomplete, Composer, in-editor agent)
  • Terminal & commands
  • Models, pricing & API keys (availability, Auto/Max, BYOK/Bedrock)
  • MCP & tools
  • Cloud Agents & Automations (cursor.com/agents, scheduled/event)
  • BugBot & Code Review
  • Cursor CLI
  • Cursor Mobile
  • Remote (SSH / Dev Containers / WSL)
  • Account, billing & login
  • Something else…

Describe the Bug
A clear and concise description of what the bug is.


Steps to Reproduce
How can you reproduce this bug? We have a much better chance at fixing issues if we can reproduce them!


Expected Behavior
What is meant to happen here that isn’t working correctly?


Screenshots / Screen Recordings
If applicable, attach images or videos (.jpg, .png, .gif, .mp4, .mov)


Operating System

  • Windows 10/11
  • MacOS
  • Linux

Version Information

  • For Cursor IDE: Menu → About Cursor → Copy
  • For Cursor CLI: Run agent about in your terminal
IDE:
Version: 2.xx.x
VSCode Version: 1.105.1
Commit: ......

CLI:
CLI Version 2026.01.17-d239e66

For AI issues: which model did you use?
Model name (e.g., Sonnet 4, Tab…)


For AI issues: add Request ID with privacy disabled
Request ID: f9a7046a-279b-47e5-ab48-6e8dc12daba1
For Background Agent issues, also post the ID: bc-…


Additional Information
Add any other context about the problem here.


Does this stop you from using Cursor?

  • Yes - Cursor is unusable
  • Sometimes - I can sometimes use Cursor
  • No - Cursor works, but with this issue

The more details you provide, the easier it is for us to reproduce and fix the issue. Thanks!

Hey @Avinash_Dubey

Two things are likely combining here.

First, the Rules and Skills numbers in Context Usage count more than just the .mdc and SKILL.md files on disk. Rules you added in Cursor Settings, rules your organization publishes to your account, and plugin or managed skills all count too, and none of those live under the .cursor folders you cleared. That’s probably why the numbers don’t drop to zero after the files are removed.

Second, changes to the personal folders (the rules and skills under your home directory’s .cursor folder) are currently picked up when Cursor starts rather than continuously, so removing them mid-session can keep showing up in new chats until Cursor is fully restarted.

3.11 is a fairly old build at this point. Recent versions clean up exactly the cached entries you found in state.vscdb, so upgrading should stop that file from carrying stale entries. Recent versions also let a beforeSubmitPrompt hook return additional context, which is the conditional per-prompt loading you asked about at the end of your report.