How to force automated testing with a Cursor project rule?

I have a Ruby on Rails project where I want Cursor to run bin/rails test and bundle exec rubocop -a -f GitHub after each command/prompt the agent runs for me. And to fix occurring errors.

This seems to be such a simple thing but I can’t get it working. I want it to as a project rule so every developer in the project has the same setup.

But even I can’t even get it run with a fixed rule.

When I ask cursor to solve this for me it comes up with this:

cursor.json

{
  "projectRules": {
    "beforeCodeChange": {
      "commands": [
        {
          "command": "bin/rails test",
          "onError": "fix"
        },
        {
          "command": "bundle exec rubocop -a -f github",
          "onError": "fix"
        }
      ]
    }
  }
}

This results in this:

So the agent says that it is running the tests but it actually isn’t (never mind the typo - old screenshot).

How can I achieve this?

1 Like

It seems that naming a rule readme.mdc does the trick. AFAIK the agent always reads that.

Thanks for sharing @wintermeyer ! I’m curious how well this setup has worked for you in practice. I know it’s only been a few hours at this point :wink:

And it already failed! :face_with_peeking_eye::scream:

This is very frustrating work.

lol thanks for the follow-up :cry: