I thought that Chat or Composer will read that automatically.
But both Chat & Composer answer that they cannot read those files until I post to them.
So how does .cursorrules supposedly to work ? If I have to provide the files by myself, what’s the different with I create some README.md files and post to Chat/Composer ?
Setting → General can also setup ‘Rules for AI’, ‘Project Rule’.
‘Project Rule’ will create .cursor/rules/xxxxx.mdc.
Not sure Chat/Composer will read that automatically or not ?
And how about ‘Rules for AI’ ? Is it the same as .cursorrules ?
Project rules depend are not always shown, and will be added to the chat depending upon your glob and description.
Project rules will only be added if either:
The glob rule matches the file or a file which has been added to your context.
You’re in agent mode and the agent decides to add the project rule to the context based on the description.
Rules for AI are global rules that will be applied anytime you use cursor, independent of what project you’re on.
.cursorrules are for project-specific rules, e.g. specific to your workspace or repo that you’re in.
Project rules are used for even more fine-grained control, such as for specific file types or directories. e.g. you might set up a rule that only applies to HTML files using the glob **/*.html.
It answered:
It seems that you are asking if I can read a file named .cursorrules. However, I don’t have direct access to files or their contents. If you can provide the contents of the .cursorrules file or describe what you need help with regarding it, I would be happy to assist you!
It can’t “read” .cursorrules in the chat, because it might just be provided as context without knowing that what it’s reading is .cursorrules.
So it might see what’s in the .cursorrules file as part of its context, but not “know” that it’s a .cursorrules file.
As above, if you enable .cursorrules in settings ( Cursor Settings > General), then create a .cursorrules in your root directory, it will be passed to your chat responses.
Another trick that I’ve been using recently is (without much clue if the agent is actually learning from it - although, it seems to be following the patterns) is:
I’ll set the “Rules for AI” section to something like this:
When suggesting Powershell/CMD commands, be iterative. The “&&” syntax isn’t supported on my device - also avoid pipe (|) commands.
Use anything within the .cursor project folder to fuel project specific context to aid the Cursor Agent (do not reference the .cursor files in any files that would be committed to github) - ensure that the directory is included in the gitignore and keep the directory up to date with key learnings about the project structure. Additionally, if we do refactors, or have to fix complicated issues (more than a couple of attempts to fix a test, for example) then automatically update the .cursor folder with learnings so that we don’t fall down the same red herrings again.
Every so often I’ll explicitly tell the agent to update the .cursor directory, but it seems to be quite good at helping the agent follow the conventions of specific projects.