- How you use it
- Always on in your project
- What it can do
- writes files
- What's inside
The option
| Option | ARules · v1.0.0Monorepo package-ownership instruction template |
|---|---|
| How you use it | Always on in your project |
| What it can do | writes files |
| What's inside |
What this thread does
The problem
Every session you re-explain that the repo has a /packages directory and six services, and still Claude proposes a new config.js in the root. Putting "THIS IS A MONOREPO" in a README and project instructions did not help.
What people said
In a r/ClaudeCode post by u/FlyingSpagetiMonsta (5 February 2026), commenters answered:
- Claude does not read a README unless told to; put the explanation in CLAUDE.md or AGENTS.md (top comment).
- Hard rules need hooks, which are deterministic; CLAUDE.md plus skills is advisory. A commenter said that if a specific tool call repeats, ask Claude to write a hook that blocks it and says what to do instead, which beats a bare deny rule because it gives the next step.
- A short CLAUDE.md that is a table of contents (key commands, links to docs or skills) was respected more than a long one (a commenter, reply).
- Start Claude at the package level, not the repo root: it then behaves like a normal single-project repo and does fewer codebase-wide searches (a commenter). Another said they work from the root without trouble with a root CLAUDE.md, and put one in leaf directories too.
- A separate thread, "Best way to teach Claude a monorepo", asked about a script that has Claude write a CLAUDE.md per app; I did not find a confirmed answer there.
What Anthropic's docs say
Anthropic's "Set up Claude Code in a monorepo or large codebase" guide and memory docs describe the same pattern:
- Layer CLAUDE.md by directory. A root file for repo-wide rules, one file per package for that package's conventions. Claude loads files from the working directory and every parent at launch, and each subdirectory's file on demand once Claude reads, writes or edits a file there. Starting from
packages/api/loads that file plus the root file and none frompackages/web/. Check with/context allunder Memory files. Target under 200 lines per file. - Start from a subdirectory when work is scoped to one package; start from the root when tasks span packages. Project settings in
.claude/settings.jsonare not inherited from parent directories. claudeMdExcludes(in.claude/settings.local.json, glob patterns such as/packages/web/) skips other teams' or legacy packages' CLAUDE.md files.- Path-scoped rules in
.claude/rules/withpaths:globs, if you prefer one central place. permissions.additionalDirectoriesor--add-dirto reach a sibling package from a subdirectory session (CLAUDE.md of a directory added with--add-dirloads only whenCLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MDis set, and a directory listed in theadditionalDirectoriessetting never loads its CLAUDE.md or skills).permissions.denyrules forReadof generated or vendored code, andworktree.sparsePathsto check out only needed directories in worktrees.
A root file the docs show: run package scripts from the package directory; prefix commit subjects with the package name; never edit packages/*/generated/, run codegen in the package.
How to ask your agent
Read the repo layout and write a root CLAUDE.md under 40 lines listing each package's path, purpose and test command, and the rule "never create files in the repo root; put them in the owning package". Then add a short CLAUDE.md in each package with only that package's conventions.
Mistakes to check
- A giant root CLAUDE.md (over about 200 lines): rules get lost.
- Expecting subdirectory files to load before Claude touches a file there; they load on demand.
- Using CLAUDE.md for a must-not-happen rule; add a hook or deny rule.
- Starting in the root and wondering why other teams' instructions load; use
claudeMdExcludes.
Limits
Not run by me. The post is a complaint with advice from commenters, not a measured result.
Sources
- Set up Claude Code in a monorepo or large codebase was read in full. Checked: per-directory CLAUDE.md layering; launching from a package loads that package's file plus every ancestor's, and the repository root loads only the root file with subdirectory files on demand; project
.claude/settings.jsonis not inherited from parent directories;claudeMdExcludeswith the/packages/web/example in.claude/settings.local.json; path-scoped rules versus per-directory files;additionalDirectoriesand--add-dir, including the environment variable and the fact that the setting never loads CLAUDE.md;Readdeny rules;worktree.sparsePaths; the example root CLAUDE.md lines; the/context allMemory files check. - Claude Code memory docs were read. Checked: the target of under 200 lines per CLAUDE.md, on-demand loading of subdirectory files, and
claudeMdExcludes.
Not checked: the Reddit post and comments (not openable from here), so the vote and comment counts, who said what, the claims about hooks versus CLAUDE.md, and the second thread about generating a CLAUDE.md per app are unverified. The suggested prompt is untried and nothing was run.
Started from a post by @FlyingSpagetiMonsta, packaged by the editor. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.