Cursor agent cannot write to .cursor/rules files

version 0.46.10

I use the below cursor rule file saved in .cursor/rules/000-core.mdc and when the agent determines it appropriate it does in fact attempt to create/edit new rules.

The issue is that it creates the file (usually in the right directory but sometimes in a different directory), but the file is empty. The contents for the file is present in the chat history, so I can copy/paste, but this is problematic when it’s trying to edit a rule file as it sometimes the content can’t be copied (gets rendered as markdown, not as code).

This appears to be some sort of limitation with the cursor rules directory and agent mode. It can write these files if I tell it to write to a different directory, then run a copy command to move the file into the correct location.

---
description: Use ALWAYS when asked to CREATE A RULE or UPDATE A RULE or taught a lesson from the user that should be retained as a new rule for Cursor
globs: .cursor/rules/*.mdc
---

When applying this rule prefix your response with [Rule Manager]

# Cursor Rules Format

## Core Structure
---
description: ACTION when TRIGGER to OUTCOME
globs: *.mdc
---
# Rule Title

## Context
- When to apply this rule
- Prerequisites or conditions

## Requirements
- Concise, actionable items
- Each requirement must be testable

## Examples
<example>
Good concise example with explanation
</example>
<example type="invalid">
Invalid concise example with explanation
</example>
## File Organization

### Location
- Path: `.cursor/rules/`
- Extension: `.mdc`

### Naming Convention
PREFIX-name.mdc where PREFIX is:
- 0■■: Core standards
- 1■■: Tool configs
- 3■■: Testing standards
- 4■■: Documentation standards
- 1■■■: Language rules
- 2■■■: Framework rules
- 7■■: Presentations
- 8■■: Workflows
- 9■■: Templates
- _name_.mdc: Private rules

### Glob Pattern Examples
Common glob patterns for different rule types:
- Core standards: .cursor/rules/*.mdc
- Language rules: src/**/*.{js,ts}
- Testing standards: **/*.test.{js,ts}
- React components: src/components/**/*.tsx
- Documentation: docs/**/*.md
- Configuration files: *.config.{js,json}
- Build artifacts: dist/**/*
- Multiple extensions: src/**/*.{js,jsx,ts,tsx}
- Multiple files: dist/**/*, docs/**/*.md

## Required Fields

### Frontmatter
- description: ACTION TRIGGER OUTCOME format
- globs: `glob pattern for files and folders`

### Body
- <version>X.Y.Z</version>
- context: Usage conditions
- requirements: Actionable items
- examples: Both valid and invalid

## Formatting Guidelines
- Use Concise Markdown primarily
- XML tags limited to:
- <example>
- <danger>
- <required>
- <rules>
- <rule>
- <critical>
- <version>
- Always indent content within XML or nested XML tags by 2 spaces
- Keep rules as short as possbile
- Use Mermaid syntax if it will be shorter or clearer than describing a complex rule
- Use Emojis where appropriate to convey meaning that will improve rule understanding by the AI Agent
- Keep examples as short as possible to clearly convey the positive or negative example

## AI Optimization Tips
1. Use precise, deterministic ACTION TRIGGER OUTCOME format in descriptions
2. Provide concise positive and negative example of rule application in practice
3. Optimize for AI context window efficiency
4. Remove any non-essential or redundant information
5. Use standard glob patterns without quotes (e.g., *.js, src/**/*.ts)

## AI Context Efficiency
1. Keep frontmatter description under 120 characters (or less) while maintaining clear intent for rule selection by AI AGent
2. Limit examples to essential patterns only
3. Use hierarchical structure for quick parsing
4. Remove redundant information across sections
5. Maintain high information density with minimal tokens
6. Focus on machine-actionable instructions over human explanations

<critical>
- NEVER include verbose explanations or redundant context that increases AI token overhead
- Keep file as short and to the point as possible BUT NEVER at the expense of sacrificing rule impact and usefulness for the AI Agent.
- the front matter can ONLY have the fields description and globs.
</critical>

try edit mode, not ask/agent. I think agent mode can interact with files but not directly with other files. I don’t know how/why, but if you ask it in edit mode it can apply the texts into your rules files.

Edit mode wasn’t any better. It creates an empty file in the root of the project folder.

I’m having the same problem. If I tell chat that the file is empty it will insist that it isn’t. It will even go as far as providing diffs for the file if I ask for changes. It looks like cursor has a buffer for the rules (presumably to speed up retrieval) which gets updated by chat but the filesystem isn’t updated.

Hi all - an update thanks to another forum post - disable the mdc editor - apparently having that in the mix breaks cursor rules ability to self edit.

In Cursor’s VS Code settings, search for “Workbench: editor associations” and add:
key: *.mdc value: default

3 Likes

Can confirm this was the issue for me too and disabling the mdc editor resolved it.

I initially went down the rabbit hole of creating rules about how to avoid the edit_file tool and use terminal commands to echo strings etc as a workaround. I’m just going to clean all that up and keep the mdc editor disabled for now, hope they see this and fix it as anyone trying to automate rule creation is going to hit this issue.