Agent does not dynamically apply AutoAttached rules when editing files

:lady_beetle: Bug: .cursor/rules not applied when the agent edits a file

Description:
When the agent starts editing or creating a file that matches a rule marked as AutoAttached in .cursor/rules, the rule is not injected into the system prompt.

This behavior defeats the purpose of dynamic rule context. The rule should not be loaded at file open or startup โ€” it should be triggered only when the agent itself interacts with the file (edits, adds, inserts).


:repeat_button: Steps to Reproduce:

  1. Create a rule file like .cursor/rules/ts.json with AutoAttached and a matcher for src/test.ts.
  2. Ask the agent to write code into src/test.ts (let the agent open the file itself).
  3. The agent starts editing โ€” but the corresponding rule is not loaded.

:white_check_mark: Expected Behavior:

When the agent begins editing any file:

  • It should detect a matching AutoAttached rule;
  • Automatically update the system prompt with the rule;
  • Proceed with the task using the updated prompt.

:red_exclamation_mark: Impact:

This makes Cursor rules unreliable.
Without dynamic injection at edit time, the agent works in the wrong context and ignores key project-specific instructions. It severely limits the utility of .cursor/rules and prevents scalable workflows across large codebases.

Hey, thanks for the report. Weโ€™ll look into it.

I just tried to repro your case, and it works for me. Could you please share a video demo? This will help me understand in which scenario it might not work, as I might have missed something.

Hello, Thank you for your reply. I have been studying the cursor for a long time and want to make it as customizable as possible for developers.

The video shows that if I give the path to the file and it starts editing it, the AI โ€‹โ€‹agent does not see my rules, but if I specifically add this file to the context, only then does the AI โ€‹โ€‹agent see these rules. I think this is not working correctly. The AI โ€‹โ€‹agent should see my rules only when it starts editing the file. As soon as it calls the file editing tool, its context should be updated and a specialized rule should be added. In this case, we get a highly customizable agent system.

The current implementation also has a lot of problems. If I add 10 files of different types, it will load 10 rules into the context.

This works very crookedly.
The agent rule should only work at the time the file editing tool is called

Thank you for the clear example. In my case, I just sent a request in the chat window to find a specific file in a specific directory, and it automatically applied the necessary rules. It might sometimes fail, we will try to consider this in various scenarios.