How to best use .mdc rules?

Hi, two things.

I don’t really understand .mdc rules. I sort of have it working but I had to explicitly prompt the LLM to read it, despite having 'Always" on the rule.

I want cursor to write a sentence to my @README (on a per project level) after significant code changes (yes I know git is there for much of this) - is this a good use of an .mdc?

And why can’t it pull the current YYYY-MM-DD to prefix its sentence?
Ta

Hi, there are several ways to solve this.

Cursor project rules / MDC

  • If you prefer a rule to be always included set to Always, but remove description and glob as those trigger by text and filename.
  • Add at begin of the rule file this text: Add to begin of output RULE: NAME (use your name of the rule)
  • Date: AI usually doesnt know the local users date. while its technically possible for AI to receive the date injected, it would have to be part of every single prompt and that would need to happen on each users machine (as local date is not same for everyone around the world). Users have madesuch
  • Usual solution is to add to the rule details what AI should do.
  • You could also ask AI in the rule to use terminal to get current date

In your case:

  • After significant code changes (or completed task step), commit code to git with command git commit -m "$(date +'%Y-%m-%d') - <commit message>". Use a full sentence to describe changes performed.

For Windows

  • Powershell git commit -m "$(Get-Date -Format 'yyyy-MM-dd') - <commit message>"
  • Terminal: git commit -m "%date:~10,4%-%date:~4,2%-%date:~7,2% - <commit message>"

Let me know if you have other MDC questions :slight_smile:

  • Its good to try simple small prompts to see if AI reacts to the rule.
  • Note that rules are injected at start of a chat, not later on, though AI may choose some rules based on description/glob later on.
  • Try a fresh chat in case it doesnt work, perhaps also restarting Cursor to see if there was maybe another issue.
1 Like