Rules Hierarchy in Cursor

Hi everyone,

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?

hi @louis7 thank you for the post.

  • There is no precedence.
  • User rules are always attached.
  • Project rules depend on the settings (always on, based on description or based on file selector)
  • Custom mode instructions are always attached.

There is no fixed length limit but note that with too long or too many rules you will confuse AI and consume unnecessary amount of tokens.

1 Like

Thanks. Your answer is helpful, but I find it a bit too generic.

What happens in the following case?

  • One user rule
  • One always-attach rule
  • One custom mode instruction

Which of these should appear first in the prompt for Cursor?

For example:

${user_rule} - ${custom_mode_rule} - ${project_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.

1 Like

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 :slight_smile:

2 Likes

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

3 Likes

Thank you!

1 Like