Agents.md isolated within a subdirectory is applied to root?

Hi, how can I solve this:

I have a large repo opened as a single workspace in Cursor. Some subprojects have their own AGENTS.md (e.g. subproject_A/blabla/AGENTS.md) with instructions that only make sense for that subtree.

What I want: Those instructions should apply when I’m working on files under that subproject, and not affect conversations or edits that are only about other parts of the repo.

What I’m unsure about: How does Cursor decide which AGENTS.md files are included in Agent context—is it strictly based on the files I’m editing / have in context, or can nested AGENTS.md files still influence unrelated work elsewhere in the same workspace? Is there a supported way to restrict agent instructions only to a subdirectory (e.g. only root AGENTS.md, or an explicit setting)? I know with rules I can add it in the .md file but I guess the same does not apply for AGENTS.md?

What I’ve considered: Using .cursor/rules with globs instead of AGENTS.md, or opening subfolders as separate workspaces. I’d like to know the intended behavior for nested AGENTS.md and any recommended pattern for monorepos.

Hey, short answer: nested AGENTS.md files are designed to automatically scope to the folder they live in. A file at subproject_A/blabla/AGENTS.md is treated like a rule that always applies with an implicit glob pattern subproject_A/blabla/**, so it only gets added to the agent context when the agent works with files inside that subtree, including files it reads or edits during the chat. It should not affect chats that only touch other parts of the repo.

The exception is the root AGENTS.md. It applies to the whole workspace, so it is best to keep it to repo wide guidance.

A few useful notes:

  • Unlike .cursor/rules/*.mdc, AGENTS.md does not support frontmatter or globs. Scope is determined only by where the file sits in the tree. There is no setting to load only the root AGENTS.md.
  • For monorepos with subproject specific instructions, your current setup with a nested AGENTS.md per subproject is the intended and recommended pattern.
  • If you need more explicit control like descriptions, custom globs, or conditional behavior, use .cursor/rules/*.mdc with an explicit globs:.
  • Opening a subfolder as its own workspace gives the strongest isolation if the subprojects are truly independent.

Are you seeing a real leak where instructions from a nested AGENTS.md show up in chats that do not touch that subtree? If yes, it is worth investigating. Share your Cursor version and a minimal repro and I will take a look. There is also a known issue in the opposite direction where nested files do not load when they should, so it is important to confirm which way your issue shows up.

Docs link: Rules | Cursor Docs

Thanks! It seems like the issue was that the user asked the LLM to specifically search for coding guidlines in the repo and review changes accordingly. So, then it found agents.md in the subdirectory and applied it.