I use rule files to provide context on various aspects of the project. All except 2 is include by glob pattern.
I maintain a special, manually applied rule file called “cursor-rules-guide.mdc” which describes how to write a cursor rule on a topic, which then I make AI to create and maintain the rule files by refering to this special rule file manually.
A rule file is attached when I tag a file that confirms to its glob pattern. But I do not think the agent auto-fetches the rules for files which he himself discovers. That would blow the context definitely, but still, some kind of development in this direction i think would be suberp by the cursor team. Even maybe a self-managed memory layer so we do not even need to maintian these rule files explicitly? We maybe maintain just a config for the managed memory?
Exciting stuff, just wanted to hear what you guys think.
The main goal is to make the agent more efficient, discover stuff in less depth and token, would love to hear how you guys handle this.
Quick clarification on how rules work right now: a rule with globs applies not only when you tag a file yourself, but also when the agent opens or reads a file that matches the glob. That’s part of the standard mechanism. So glob-based rules already support auto-fetch for discovered files. On top of that, rules with a description and alwaysApply: false are pulled in on-demand based on description relevance, which also partly covers the “fetch when needed” case. More details: Rules | Cursor Docs
On the self-managed memory layer side, this idea comes up a lot, and there are a few Feature Requests threads worth checking out and upvoting if it resonates:
If you have specific scenarios where the current glob or description-based fetching doesn’t work well, please share an example. These reports help us understand what to improve next.Hey, nice workflow. A couple quick clarifications on how rules work right now, so you can get more out of them without manual tagging:
Auto Attached globs: in the frontmatter gets pulled in when a file matching the globs is in context, including when the agent opens or reads the file on its own, not only when you manually @ tag it
Agent Requested only description: without globs means the agent decides to pull the rule based on the description when it sees it is relevant. This is the closest to what you described, the rule gets fetched only when needed
Manual only when you explicitly use @rule-name
So if you want to keep context small but still get the rule when needed, try rewriting some of your rule files as Agent Requested. Remove globs and keep a strong description. Then the model can decide when to pull it in and your context stays cleaner.
Also take a look at Skills Agent Skills | Cursor Docs. They give a similar effect of loadable knowledge modules, but with more explicit structure and for specific tasks.