Agent removing front matter when it creates mdc file

Bug: The Agent is removing the front matter when creating cursor rules.

Reproduction: Tell the Agent to make an mdc file with the content.

---
description:
globs:
alwaysApply: true
---

# Your rule content

- You can @ files here
- You can use markdown but dont have to

The first line of the mdc file it makes should be # Your rule content leaving an invalid rule. Now tell it to make a an mdc with the content

// ... existing code ...
---
description:
globs:
alwaysApply: true
---
// ... existing code ...

# Your rule content

- You can @ files here
- You can use markdown but dont have to

Both of the // ... existing code ... should get removed and you should be left with a valid rule file.

One thing I tried while debugging this was to tell the agent to put the front matter block a few lines under below the first line of the file. It didn’t seem to have any issues with that. When I then had it move the block up to the top of the file the Agent was once again removing it.

Reproduction video in an empty folder:
I used Claude-3.7-sonnet with thinking in this video, but I was able to reproduce the behavior with other modals.

I have this issue as well. I found that instructing the agent to NEVER write .mdc files directly and to instead create them as .md files and then rename them to .mdc files gets around this problem.

Super frustrating