Why Claude Code and Cursor ignore your monorepo conventions (and how to fix it)
The fix in one paragraph
Keep the root file short and repo-wide. Put each package's rules in that package (AGENTS.md, plus a CLAUDE.md that imports it, or .claude/rules files scoped with paths:). In Cursor, use nested AGENTS.md or .mdc rules with globs. Move anything a linter can enforce into the linter. Then check what actually loaded: /context all in Claude Code shows the memory files in use.
In a monorepo, each package has its own rules: different frameworks, test commands, import boundaries. Agents often follow the root instructions and miss the package ones, or never see them. The cause is usually how the instruction files are laid out and when each tool loads them.
Last reviewed: December 2026
Need living codebase context for Claude Code or Cursor?
Moxie Docs indexes your codebase and serves verified conventions and docs over MCP. Free on 1 repo.
Package files load late, or not at all: Claude Code loads CLAUDE.md from the working directory and every directory above it at startup. A CLAUDE.md in a subdirectory loads only once Claude reads, writes or edits a file in that subdirectory. If the agent plans the change before opening a file there, it plans without those rules.
The wrong file name: Claude Code reads AGENTS.md natively only where there is no CLAUDE.md. A package with only AGENTS.md is fine; a package with a CLAUDE.md that doesn't import AGENTS.md hides it from Claude.
Cursor rule files that never apply: Cursor project rules in .cursor/rules must use the .mdc extension; a plain .md file there is ignored. A rule with alwaysApply: false and no globs or description only applies when you @-mention it.
A root file that tries to cover everything: A long root file mixes rules for every package. The model gives each rule less weight, and rules for one package get applied to another.
Sessions started in the wrong place: Codex reads AGENTS.md files from the repo root down to the directory you start it in. Starting at the root means package files below aren't in the initial instructions.
Claude Code: nested files and path-scoped rules
Put a CLAUDE.md in each package that imports the package's AGENTS.md, or put the rules in .claude/rules/ with a paths: list so they load whenever Claude touches a matching file (memory docs):
MARKDOWN
123456789
---
paths:
- "packages/api/**/*.ts"
---
# API package
- Validate input with the zod schemas in packages/api/src/schemas.
- Run tests with: pnpm --filter api test
In a large monorepo, claudeMdExcludes in .claude/settings.local.json skips other teams' CLAUDE.md files by glob. To check what loaded, run /context all and look under memory files.
Cursor: nested AGENTS.md or rules with globs
Cursor applies an AGENTS.md in any subdirectory when you work with files in that directory or below, combined with the parent files, with the more specific file taking precedence. For finer control, add .mdc rules in .cursor/rules with globs. (Cursor's documentation now lives at docs.grok.com under the Grok Build name.)
MARKDOWN
1234567
---
description: Conventions for the web app package
globs: apps/web/**/*.tsx
alwaysApply: false
---
- Use components from packages/ui, not raw HTML elements.
The legacy root .cursorrules file is being deprecated; move its content into a rule set to Always Apply.
For every agent: enforce, don't just ask
Instructions are suggestions; failing checks aren't. Boundaries between packages can be enforced with ESLint import rules, dependency-cruiser or your build tool's project graph. Formatting and naming belong in the formatter and linter. Put the check command in the package's AGENTS.md so the agent runs it before it finishes. Then the agent learns the convention from an error, whatever it loaded.
When conventions aren't written down anywhere
Often the real problem is that the package rules live only in people's heads. Writing them down is the fix, and keeping them current is the ongoing cost (see how to keep AGENTS.md and CLAUDE.md up to date). Another option is a tool that reads conventions from the code. Moxie Docs indexes a repository, detects its conventions, re-checks them on every merge, and serves them to Claude Code, Cursor and Codex over MCP, so the agent can look them up before editing. It complements the files above rather than replacing them.
The short version
Short root file, package rules next to each package, Cursor rules as .mdc with globs, enforcement in linters and CI, and a quick check of what each agent actually loaded.