How to verify a rule was applied?

Hi everyone. I am currently developing server application on Spring Webflux in Kotlin and I have some tests in Groovy. I have created a few rule files but those rules are never applied correctly. For example Cursor often forgots to import classes to kotlin or groovy files so I decided to define it to a rule. No change in bahavior, still forgetting. But there are many other things it is forgetting.

How do I verify a rule was applied?
Any ideas how to fix this behavior?

Hi,

Most users add to begin of the rule something like “Output at begin: …” that tells them that the rule was understood and used. Note that it depends on the rules being usable and not confusing AI, as that would lead to the AI model not doing what you ask. (It can happen, not a shame)

On other side you can see in Chat when AI pulls a rule as it shows the rule preview in chat.

In the Agent chat you can simply ask: “Are project rules used in this query?”

Then you’ll get a list of applied rules.

2 Likes

@PSAGChristian @T1000 Yes I always verify by asking in chat window. But very often the response is “no it was not applied”. So these issues are not happening to you?
For clarity, this is example of rule that is often ignored “- When adding a class or enum or extension method or static method usage to a *.kt, *.java or *.groovy file then always check the class or method is imported. If not then add the import.” Should it be formulated easier way?

@Lukas
Not sure how your rules are set up.
Here’s a very good thread to understand the concept: A Deep Dive into Cursor Rules (> 0.45) - #7 by michaelito80us

At least with alwayApply: true you should get it going, if your rule file is not applied in general (since you got the answer “no it was not applied”)

1 Like

To summarize quick

alwaysApply: true for forcing the rule file to always be included. be careful of the rule polluting context if it may conflict with other requirements or have conflicting details.

Then the description: which is used for text based detection by AI. Disable Always and set detailed description in which case to be applied. The better you describe without being excessively long the clearer it will be for AI when to use it.

Or otherwise the glob: rule where you use path, file or extension based inclusion.

Usually each of them serves different purposes. The link is sure a good guide.

2 Likes