I’d like to understand the order of precedence for rules in the Cursor context during compilation. Specifically, how are the following prioritized when sending a message?
User rules
Project rules
Custom mode instructions
Additionally:
Are there any weights assigned to these rules?
Are there any length limitations for each type of rule?
I believe there’s a fixed order they should follow in technical perspective.
Also, you mentioned there’s no length limit, but based on my experiments, changing the order or having a rule that’s too long sometimes causes Cursor to ignore the rule entirely. So I think length and order do matter in practice.
Right, the length definitely influences the probability that AI ignores something as it will get confused with too much information or conflicting details. Order may have effect but if rules are grouped together closeby, the order does not matter from my experience since there is a lot of information after the rules (resquest, code, tool calls, …).
AI gives more weight to information that appears later in the prompt, thats why the follow up prompt is always at the end and not at begin. Information at the beginning of a prompt establishes the initial framing so rules should be early on, which is likely the case. But in most applications there is a system prompt which always goes first.
I used words ‘likely’ and so on since I do not have insight how Cursor internally does this. From personal experience, I reduced the user rules, project rules heavily with latest models as they simply don’t need as many instructions where 6months ago the models needed much more specific details.
For example to maintain quality of code I introduced static analysics, linter, unit/feature/architecture tests that AI can run and avoids long rules how what should be written. So a single line of which tools to use and how to call them is now already enough.
In case of complex projects I instruct AI to have a look at the project and plan, rather than having it described in a rule file.
The question is actually interesting so I will see if I can find someone who knows the answer, but cant promise it will be satisfactory
There’s some research done by users to have rule priority:
Also, when an LLM fetches the rules because of description, inside, it reads the content that may contain a hint on which rules have higher priority(I use critical/high/medium/low): Priority: High