What's the correct globs syntax in a Cursor rule's frontmatter?

I have an Auto Attached rule under .cursor/rules/:

globs: *.java

alwaysApply: false

What’s the difference between globs: *.java and globs: **/*.java in Cursor? Does *.java only match files at the repo root, or does it recurse into all subdirectories?
For a project where Java files live deep under paths like web/src/main/java/..., which pattern should I use to make sure this rule gets auto-attached whenever any .java file is edited?

Hi Benjamin!

Both *.java and **/*.java work the same way in Cursor. Simple extension patterns like *.java are automatically treated as recursive, so they’ll match .java files in all subdirectories, including paths like web/src/main/java/....

Either form will work for your Auto Attached rule. The rule will auto-attach whenever a matching .java file is referenced in context (open in the active tab, @-mentioned in chat, or read/edited by the agent).

For more on how rules and glob patterns work: Rules

Thanks. Another question is when both globs and a description are specified, which one takes precedence or both works?