Good examples of .cursorrules file?

Are there any references / best practices to get the most out of this new feature?

  • .cursorrules: You can write down repo-level rules for the AI by creating a .cursorrules file in the root of your repository. You might use this to give for context on what you’re building, style guidelines, or info on commonly-used methods.
6 Likes

.cursorrules is just a repo-specific “Rules for AI,” so this thread might serve as inspiration:

4 Likes

@truell20

Can you please let me know:

  1. Where is the .cursorrules file located?

  2. Is there just one .cursorrules file?

  3. In Cursor Settings > General, what is the relationship between:

  • The Rules for AI textarea field
  • The Include .cursorrules file toggle option
  1. Do rules added to the Rules for AI textarea automatically get added to a .cursorrules file?

I am having difficulty conceptualising what these two field settings do, how they relate to each other and what their scope is.

I added a ‘rule’ to the Rules for AI area:

Start your response with a pirate joke.

thinking that it might create a .cursorrules file in the folder where I was working, but it didn’t.

Thank You.

Edit:

Maybe this is related, but I’d love more clarification, thank you.

https://forum.cursor.com/t/split-rules-for-ai-into-global-and-workspace-project-scopes/1708/5?u=litecode

5 Likes

@litecode

  1. Create a .cursorrules in the root of your repo. It’s like a .gitignore.

  2. Yes.

  3. Rules for AI is global, if .cursorrules present in repo, will be appended (i guess? maybe prepended) to rules for AI.

  4. No. Rules for AI is like how you want your ai model to respond in any scenario/context, not just current repo.

3 Likes

If you have a repo with multiple programming languages in it, can I just add a .cursorrules file in each root folder for each language?

3 Likes

Is it possible for a .cursorrules file to read a local directory and scan files there?

2 Likes

I’d love to know about this as well.

My use case is that I want to tell AI that when it writes code related to UI / widgets, it should use custom widgets present at a shared_ui folder, and styles presents in a styles.dart file

I’ll leave it here: https://cursor.directory/

7 Likes

I also find this website https

1 Like

Here’s a free tool to generate them for you:

Just tell it your tech stack. It’s trained on high-quality examples from the community so it should be better than just asking cursor itself

3 Likes

You can try Raycast extension for https://cursor.directroy if you are on macOS.

this is aaaawwwwwwwwsoooooooommmmmeeeee

I don’t think I’ll ever be able to say that I thought this was a bit of a useless feature, but now in version 44.8, I had a significant gain in logic in the flow of my software because I adopted the idea of ​​cursor rules, I took many prompts from cursor.directory and adapted them for each of my projects. And I also added the option to include the .cursorrules file to add the key and import a prompt within the codebase logic, this made the language models better understand the codebase indexing and apply more correct logic to my workflow.



the result was really surprisingly better, not to mention the option of interacting with the lints… this is fantastic in composer and yolo mode.
I believe that in the future the only thing that should be considered is migrating the electron cursor core to a low-level language like rust or c++, in order to improve the application’s performance, because the software line seems to have started to get very good.

2 Likes

The last example is very good. The secret to .cursorrules format is to write JSON, not markdown. I think because JSON is more like mindmap, it’s hierarchical and contextual. All these cursor directories are low quality, those prompts might work in ChatGPT, but not as a cursorfile. You can play around with examples I built, so far I very happy with the result. AI-First Organization

With minimal prompting, I had Claude 3.5 write its own .cursorrules in Agent mode and it worked really well.

My prompt:

Do a quick look over the codebase to understand:
- the stack we're using (e.g. tanstack router, tanstack query, convex, react, shadcn, etc.)
- review the conventions and styles used
- then write some instructions for a .cursorrules file based on your observations. cursor rules files are dot files at the root of repository (i've made an empty one) that "customize AI behavior, streamline the development and tailor code generation, suggestions and queries to your framework and language."
- therefore, what you write will be your OWN rules, based on things we've learned building this project.

Resulting .cursorrules:

cursorrules example