Day 46 of 52 · about 20 min · Context · Bonus
Set up Claude Code in a monorepo
In a big repository, Claude needs to know where to look. Otherwise it spends your context on other teams’ code and on instructions that have nothing to do with the package you are changing.
You’ll finish with
- A root
CLAUDE.mdplus one per package, each loading only where you work - Deny rules that keep build output and vendored code out of Claude’s reads
- A sibling package added with
--add-dirwhen a change spans two
You’ll need
- A monorepo or large repository where you can add files
- Day 9 (deny rules) and Day 21 (path-scoped rules)
Before you start
Tell us about your setup and the steps change to fit it. Your answers stay in this browser, and you can change them at any time.
Which system are you on?
Commands differ between systems. Pick the one you’ll run Claude Code on.
The steps
One step at a time. When a step’s check matches, tick it and the next one opens.
Step 1 of 4: Choose where to start Claude
Where you run claude decides what Claude can read and which instructions load.Start at the root
- Every file is in reach
- Root
CLAUDE.mdat launch; package files load on demand - For tasks that span packages
Start in a package
- That package only, until you add more
- Its
CLAUDE.mdplus every parent folder’s - For work inside one package
Pick per task. To focus on one package, start in it. Check it worked
You know which folder you will start from for your next task.
Step 2 of 4: Give each package its own CLAUDE.md
Keep repository-wide rules at the root and package rules beside their code.For example, commit conventions go in the root file and each package’s stack in its own. Prefer one central place? Use path-scoped rules in
.claude/rules/instead, as on Day 21.monorepo/
- CLAUDE.mdRules for every package
- folder packages
- folder api
- CLAUDE.mdNewAPI conventions only
- folder web
- CLAUDE.mdNewFrontend conventions only
- folder shared
- CLAUDE.mdNew
The layout the docs use. Swap in your own packages or subsystems. Check it worked
Start Claude in
packages/api/and run/context. Memory files lists the root and apiCLAUDE.md, and nothing fromweb.Step 3 of 4: Keep Claude out of generated code
Deny reads of build output and skip CLAUDE.md files you never need.Folders in
.gitignore, likenode_modules, already stay out of Claude’s searches. For checked-in build output or vendored code, addReaddeny rules. A Bashgrep -rover those folders still sees them..claude/settings.json- permissions.deny: ["Read(./**/dist/**/*)", "Read(./**/vendor/**/*)"]
- Blocks the files inside. Claude can still list the folders.
- claudeMdExcludes: ["**/packages/legacy-*/**"]
- Skips those packages’
CLAUDE.mdand rules when you start at the root.
Settings aren’t inherited from parent folders, so start-from folders need their own copy. Check it worked
Save this at the repository root and start Claude there:
/permissionslists both deny rules.Step 4 of 4: Reach a sibling package
Add another folder when a change spans packages.TerminalRun: claude --add-dir ../shared
What happens: Started in
packages/api/, Claude can now read and editpackages/shared/too.What happens: Mid-session,
/add-dir ../webdoes the same.Added folders give file access. Their CLAUDE.md loads only with an extra environment variable. Check it worked
Ask Claude to read a file in
../shared. It opens without a prompt about leaving the working folder.
Finish · 4 of 4 steps to go
Claude reads the part you work on
What you’ll have checked
/contextshows the root and packageCLAUDE.mdonly- Build output and vendored code are on the deny list
--add-dirgave access to a sibling package
Lesson updates by email
Get lesson updates by email
Leave your email and we’ll tell you when we add or update a lesson.
Claude Code for your team
Want Claude Code set up across your team?
HorizonLux sets up and repairs Claude Code for teams: CLAUDE.md rules, hooks that enforce them and reviewed MCP servers. Book a free call to talk it through.
Related
Questions
Questions about Day 46
Can a package settings file build on the root one?
No. Claude Code reads `.claude/settings.json` only from the folder you start in, so each one must be complete.
Sources
Checked against the official Claude Code docs on .
- Set up Claude Code in a monorepo or large codebase
- How Claude remembers your project
- Configure permissions
Independent resource, not affiliated with Anthropic. HorizonLux wrote this lesson; Claude Code is made by Anthropic.