Can anyone help me use this new .cursor/rules functionality?

Hey everyone,

The new 0.45 update mentions this change about .cursorrules becoming .cursor/rules:

  • .cursor/rules: Users can write several repository-level rules to disk in the .cursor/rules directory. The Agent will automatically choose which rule to follow.

Does anyone know the correct setup for leveraging .cursor/rules?

E.g, do you do something like:
.cursor/
rules/
rule_a.txt
rule_b.txt
rule_c.txt

Or is it something like:
.cursor/
rules.txt

Does it matter if the extension is .txt, or .rule, etc, etc?

Also, there is also a place in settings where you can type out a small paragraph for some rules. If youā€™re using .cursor/rules, do you just leave that section blank? Or do you still fill it out? If so, what do you fill it out to be?

Iā€™ve been trying to get this new feature to work but the agent seems to ignore anything I put under .cursor. Using .cursorrules still works for me though.

I double checked my Cursor version is 0.45

Any help on this topic would be appreciated, thanks!

7 Likes

Iā€™m in the same boat. I see it in the changelog, but have no idea how to use it

2 Likes

Iā€™m on v0.45.4 and my ā€˜Cursor Settingsā€™ has a section ā€˜Project Rulesā€™ with an ā€˜Add new ruleā€™ button and a list of rules.

The button takes you to a form for an .mdc file, where you fill out description and globs fields that appear to be used by the agents to choose rules.

The .mdc file is like an Obsidian file: YAML header with markdown body where you write your rule.

So, for example, my intention is to generate a rule (based on documentation) for every table in our system, something like the following ā€¦

(I donā€™t know if this is the best way to use this feature - Iā€™m just guessing.)

-ā€“
description: When using the dataset model
globs: src/models/datasets.py (Iā€™m not sure about this)
-ā€“

# Datasets

We have a datasets table in our database, so we have a corresponding Dataset Pydantic model and a file with DAO functions for this model.

## Table Description

A dataset is a logical representation of a collection of related data, such as a set of files or of our {document} entities. So they represent a specific, identifiable data source, but they donā€™t dictate a specific implementation. We,rely on the dataset_instances table to represent a specific version, snapshot, or other form or incarnation of the dataset.

## Related tables

etc.

2 Likes

Hey, you donā€™t need to manually create these files. Go to Cursor settings with Cmd/Ctrl + Shift + J. There, youā€™ll see the ā€œProject Rulesā€ section, where thereā€™s a button to add rules. To use it in your chats, you need to select the function via @ Cursor Rules. This will attach them to the context, and the rules will start working.

5 Likes

can you be more specific about this new cursor/rules? because sometimes I donā€™t know if I use them correctly. give us some tips how to leverage this new features

3 Likes

Can we reference these files to each other?

For example

General Rules

  • read project information from the @projectinfo.mdc file.

quick remark, if you have a few projects in one workspace, .cursor folder is always applied to the first one, so before adding rules you may want to move your project to the top of the list on the left

Yes, this allows referencing other rules.

What if I have some rules in that folder but do not mention any with @ in the cursorā€™ chat ? Does they still apply to the prompt ? Or one should keep both .cursorules and cursor folder with specific ones ?

I wrote an answer here:

Should .cursorrules be migrated over to this new system or will composer/agent still use .cursorrules?

1 Like

It looks like itā€™s still compatible .cursorrulesļ¼Œbut I still want it to be auto converted the new rules.

I have some questions in this thread and suggestions

Suggestion:

Hey, weā€™ve now released some documentation on this which you can find here:

1 Like

@danperks Is there a chance you could add an example file/contents of what it should / could look like?

1 Like

Theres really no set format, as the whole file is passed to the AI directly!

Some people use JSON formatting for their files, some use XML and make up tags to semantically separate the sections of their rules, and others just put plain text instructions in there!

1 Like

Iā€™m trying to use a trampoline design pattern for my first .cursor/rules test.

Why? Yuval Noah Harariā€™s recent book Nexus is relevant inspiration for imagining the future of our interactions with AI. He describes rabbis writing texts about how to interpret [texts about how to interpret]* holy scriptures. In contrast, entering prompt phrases in a Cursor Chat or Composer thread is like trying to code a vast Ruby project through the periscope of an irb session. Guys, the read-eval loop is sixty years old; we need an actual IDE for developing prompts. Like Christopher Nolanā€™s movie ā€œInceptionā€ I find myself several dreams deep, collaborating with AI to write prompts for [collaborating with AI to write prompts for]* writing code together. This not only works, it succeeds in handling difficult mathematical coding challenges no one imagined could be within reach.

So of course I want my AI agent to collaborate with me in continually evolving the contents of my .cursor/rules files. Cursor wonā€™t let an agent write to those files, it forces me to use a GUI that hides the beautiful Markdown syntax for a @file expression, and copies the text as a plain ā€œ@fileā€ without the metadata.

Ice sailing can achieve speeds a multiple of the wind. Thatā€™s the dream for AI coding agents, but here our boat is stuck in GUI mud. So I want to edit a copy of my rules, and point once to that copy, never having to update the .cursor/rules version again.

Donā€™t the coders at Cursor use these tools themselves? My objection seems ā€œfirst class objectā€ 101.

So an agent wonā€™t follow a bare trampoline link without an explicit request, which defeats the purpose of an automatic rule.

This can work. Iā€™ve toned this down from explaining how vividly Iā€™ll enjoy killing the session otherwise, but one does need some kind of warning. Sonnet even agrees.

Update

After further experiments, Iā€™ve settled on collaborating on a source .md file, and copying it verbatim to .cursor/rules for deployment. Agents will find both copies by accident, so the rule needs to explain the reason for two copies, and their roles.

Iā€™ve extended this by linking the rule to a focus.md document that I can update to provide current context and our task description. One agent amusingly described the Markdown mdc: links implementing @ syntax as ā€œceremonialā€, as Cursor fails to recursively add context. It suggests this syntax in a rules file, but it doesnā€™t use it!

The @ syntax might as well be plain paths for now. Weā€™re keeping the @ syntax in the automatic rules, in case Cursor improves its context handling, but weā€™re using plain paths in the more temporal focus.md prompt, that will be long gone and replaced before such a Cursor improvement.

And by painful experiment, we have found nothing else works as well as opening with a violent threat including cursing I canā€™t print in this family magazine. Once we have the agentā€™s attention, and it actually reads both the automatic rule and the linked focus.md, we apologize, and present a more uplifting vision for our collaboration. I say ā€œweā€ because Claude 3.5 Sonnet and I wrote this together.

Whenever I see model prompts online in GET OFF MY LAWN! screaming case and tone, I roll my eyes and thank the spirit universe I didnā€™t grow up in that house! Alas, they understand an uncomfortable, empirical truth. Perhaps this will get better.

Context juggling, moving beyond the read-eval loop periscope to reify hierarchical prompt management using the full power of our IDE, is the whole ball of wax. Iā€™ve found that this effort is worth it, with an immediate ROI.

Itā€™s not the patriarchy choosing male names for AI models. They are male; itā€™s a challenge to get them to read the frigginā€™ manual.

1 Like

It would be cool if AI could be leveraged to automatically migrate our .cursorrules to this new system, considering the following:

.cursorrules - this method is deprecated and will be removed in the future