Install command
Not provided
How to give Claude Code access to more than one directory: the --add-dir flag, the /add-dir command, and the permissions.additionalDirectories setting, plus how each one handles CLAUDE.md, rules, and skills in monorepos.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Not provided
Config snippet
Not provided
Copy snippet
Provided
Prerequisites
2 to clear
Platforms
1 listed
Difficulty
45/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Prerequisite readiness
2 prerequisites to line up before setup.
Safety & privacy surface
1 safety and 1 privacy notes across 1 risk area. Review closely: credentials & tokens.
## Overview
A Claude Code session can read and edit files in its working directory by default. Working across more than one directory comes up in two common situations:
- **A monorepo**, where a change to a shared package needs matching edits in the packages that import it.
- **Separate repositories** checked out side by side, where one task spans both.
Claude Code gives you three ways to grant access beyond the working directory: the `--add-dir` launch flag, the `/add-dir` in-session command, and the `permissions.additionalDirectories` setting. They differ mainly in scope (one session versus committed config) and in what they load from the added directory: file access only, or also that directory's `CLAUDE.md`, rules, and skills.
This guide covers those three mechanisms and the decision that comes before them: where to start Claude.
## Choose where to start Claude
Before adding directories, pick your launch point. Where you run `claude` determines which files Claude can touch without a grant and which `CLAUDE.md` files load at startup.
| Start from | File access | CLAUDE.md loaded at launch | Use when |
| :-------------- | :------------------------------------- | :----------------------------------------------------- | :----------------------------------------- |
| Repository root | Every file in the tree | Root only; subdirectory files load on demand | Tasks span multiple packages or subsystems |
| A subdirectory | That subtree only, until you grant more | That directory's plus every ancestor's | Work is scoped to one package or subsystem |
If you start from the repository root of a single large tree, Claude already reaches every file and you do not need to add directories. The mechanisms below matter when you start from a subdirectory, or when a task spans separate checkouts.
Note that project settings in `.claude/settings.json` load only from the directory you start in; they are not inherited from parent directories the way `CLAUDE.md` files are.
## Grant access for one session: `--add-dir` and `/add-dir`
To add a directory at launch, pass `--add-dir`:
```bash
# Start in packages/api and also reach the sibling shared package
claude --add-dir ../shared
# Multiple directories, including a separate repository
claude --add-dir ../shared --add-dir ~/code/other-repo
```
To add a directory after a session has already started, use the `/add-dir` command:
```text
/add-dir ../web
```
Either way, Claude can read and edit files in the added directory for the rest of that session. Neither change is persisted; the next session starts from your working directory again.
By default, a directory added this way does **not** load its `CLAUDE.md`, `.claude/rules/`, or `CLAUDE.local.md`. To also load those memory files, set the `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD` environment variable:
```bash
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../shared-config
```
With the variable set, Claude loads `CLAUDE.md`, `.claude/CLAUDE.md`, `.claude/rules/*.md`, and `CLAUDE.local.md` from the added directory. (`CLAUDE.local.md` is skipped if you exclude `local` from `--setting-sources`.) Skills in an added directory load on demand regardless of this variable.
## Grant access permanently: `additionalDirectories`
To make sibling access part of the project so everyone working in this area gets it, use the `permissions.additionalDirectories` setting in `.claude/settings.json`:
```json
{
"permissions": {
"additionalDirectories": [
"../shared",
"../web"
]
}
}
```
Relative paths resolve against the directory you start Claude from. With the configuration above, a session launched in `packages/api/` can read and edit files in `packages/shared/` and `packages/web/` without any flag.
Commit the setting to `.claude/settings.json` for everyone, or put it in `.claude/settings.local.json` for a personal, gitignored selection.
Unlike `--add-dir`, the `additionalDirectories` setting grants **file access only**. It never loads the added directory's `CLAUDE.md`, rules, or skills, and the `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD` variable has no effect on it. If you need a sibling's instructions or skills loaded, add it with `--add-dir` instead.
## Reference: which mechanism loads what
| Added with | Scope | Read/edit access | Loads CLAUDE.md and rules | Loads skills |
| :------------------------------------- | :------------------ | :--------------- | :----------------------------------------- | :----------- |
| `additionalDirectories` setting | Committed / local config | Yes | Never | Never |
| `--add-dir` flag | One session | Yes | Only with `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` | Yes |
| `/add-dir` command | Rest of the session | Yes | Only with `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` | Yes |
Pick based on intent: `additionalDirectories` for stable, team-wide sibling access where you only need files; `--add-dir` / `/add-dir` for one-off access, or when you want the sibling's conventions and skills in context too.
## Monorepo layout that scales
Adding directories is one of several settings that keep Claude focused in a large codebase. A typical monorepo combines them:
- **Layer `CLAUDE.md` files by directory.** A root file sets repository-wide rules; each package adds its own. Claude loads the root plus the package you start in, and pulls in a subdirectory's file on demand when it reads there. Keep each file focused on its own area so context is not spent on unrelated subsystems.
- **Exclude irrelevant `CLAUDE.md` files** with `claudeMdExcludes` (glob patterns matched against absolute paths) for packages you never touch, such as other teams' code or vendored subtrees.
- **Block reads of generated and vendored code** with `Read` deny rules in `permissions.deny`, for example `"Read(./**/dist/**)"` and `"Read(./vendor/**)"`. Searches already respect `.gitignore`, so this is for checked-in artifacts.
- **Grant sibling access** with `additionalDirectories` when a change spans packages.
A committed `packages/api/.claude/settings.json` that combines these:
```json
{
"permissions": {
"additionalDirectories": [
"../shared"
],
"deny": [
"Read(./**/dist/**)",
"Read(./**/build/**)"
]
}
}
```
Because project settings load only from your starting directory, each subdirectory's `.claude/settings.json` must be self-contained rather than layered on a root file.
## Worktrees and sparse paths
If you start sessions in a new git worktree with `--worktree`, the entire repository is checked out by default. In a large repository, the `worktree.sparsePaths` setting uses git sparse-checkout to write only the listed directories (plus root-level files) to disk:
```json
{
"worktree": {
"sparsePaths": [
".claude",
"packages/api",
"packages/shared"
],
"symlinkDirectories": [
"node_modules"
]
}
}
```
Paths are relative to the repository root regardless of where you launch Claude. List directories, not individual files; root-level files like lock files and `tsconfig.base.json` are always included. Add `.claude` if you want the repository root's `.claude/` available inside the worktree. Pair with `symlinkDirectories` to avoid duplicating large directories such as `node_modules` across worktrees.
Note that `sparsePaths` and `symlinkDirectories` are read from your starting directory before the worktree is created; after creation the session's working directory is the worktree root, so put permission rules and hooks you need inside worktrees in the repository root's `.claude/settings.json`.
## Scoping a change that spans packages
Configuration controls what Claude can see; how you scope the task affects the result:
- **Hand over the whole change in one session.** Giving Claude the shared edit and its call sites together keeps decisions consistent across packages instead of being re-derived per package.
- **Save the plan to a file before editing.** A long cross-package session compacts its context along the way; a plan written to a markdown file in the repository survives where conversation history may not.
## Troubleshooting
- **Claude says it cannot edit a sibling package.** You started in a subdirectory without granting the sibling. Add it with `--add-dir`, `/add-dir`, or `additionalDirectories`, or start Claude from the repository root.
- **A sibling's `CLAUDE.md` is being ignored.** The `additionalDirectories` setting never loads memory files. Use `--add-dir` with `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1`, or layer a `CLAUDE.md` in your own tree instead.
- **A relative path resolves to the wrong place.** Relative paths resolve against the directory you start Claude in, not the repository root (sparse paths are the exception). Confirm your launch directory, or use an absolute path.
- **Settings in `.claude/settings.json` are not taking effect.** Project settings load only from the directory you start in. A root settings file does not apply when you launch from a subdirectory.
## Related resources
- [Set up Claude Code in a monorepo or large codebase](https://code.claude.com/docs/en/large-codebases)
- [Settings reference](https://code.claude.com/docs/en/settings)
- [Memory and project instructions](https://code.claude.com/docs/en/memory)A Claude Code session can read and edit files in its working directory by default. Working across more than one directory comes up in two common situations:
Claude Code gives you three ways to grant access beyond the working directory: the --add-dir launch flag, the /add-dir in-session command, and the permissions.additionalDirectories setting. They differ mainly in scope (one session versus committed config) and in what they load from the added directory: file access only, or also that directory's CLAUDE.md, rules, and skills.
This guide covers those three mechanisms and the decision that comes before them: where to start Claude.
Before adding directories, pick your launch point. Where you run claude determines which files Claude can touch without a grant and which CLAUDE.md files load at startup.
| Start from | File access | CLAUDE.md loaded at launch | Use when |
|---|---|---|---|
| Repository root | Every file in the tree | Root only; subdirectory files load on demand | Tasks span multiple packages or subsystems |
| A subdirectory | That subtree only, until you grant more | That directory's plus every ancestor's | Work is scoped to one package or subsystem |
If you start from the repository root of a single large tree, Claude already reaches every file and you do not need to add directories. The mechanisms below matter when you start from a subdirectory, or when a task spans separate checkouts.
Note that project settings in .claude/settings.json load only from the directory you start in; they are not inherited from parent directories the way CLAUDE.md files are.
--add-dir and /add-dirTo add a directory at launch, pass --add-dir:
# Start in packages/api and also reach the sibling shared package
claude --add-dir ../shared
# Multiple directories, including a separate repository
claude --add-dir ../shared --add-dir ~/code/other-repo
To add a directory after a session has already started, use the /add-dir command:
/add-dir ../web
Either way, Claude can read and edit files in the added directory for the rest of that session. Neither change is persisted; the next session starts from your working directory again.
By default, a directory added this way does not load its CLAUDE.md, .claude/rules/, or CLAUDE.local.md. To also load those memory files, set the CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD environment variable:
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../shared-config
With the variable set, Claude loads CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md, and CLAUDE.local.md from the added directory. (CLAUDE.local.md is skipped if you exclude local from --setting-sources.) Skills in an added directory load on demand regardless of this variable.
additionalDirectoriesTo make sibling access part of the project so everyone working in this area gets it, use the permissions.additionalDirectories setting in .claude/settings.json:
{
"permissions": {
"additionalDirectories": [
"../shared",
"../web"
]
}
}
Relative paths resolve against the directory you start Claude from. With the configuration above, a session launched in packages/api/ can read and edit files in packages/shared/ and packages/web/ without any flag.
Commit the setting to .claude/settings.json for everyone, or put it in .claude/settings.local.json for a personal, gitignored selection.
Unlike --add-dir, the additionalDirectories setting grants file access only. It never loads the added directory's CLAUDE.md, rules, or skills, and the CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD variable has no effect on it. If you need a sibling's instructions or skills loaded, add it with --add-dir instead.
| Added with | Scope | Read/edit access | Loads CLAUDE.md and rules | Loads skills |
|---|---|---|---|---|
additionalDirectories setting |
Committed / local config | Yes | Never | Never |
--add-dir flag |
One session | Yes | Only with CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 |
Yes |
/add-dir command |
Rest of the session | Yes | Only with CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 |
Yes |
Pick based on intent: additionalDirectories for stable, team-wide sibling access where you only need files; --add-dir / /add-dir for one-off access, or when you want the sibling's conventions and skills in context too.
Adding directories is one of several settings that keep Claude focused in a large codebase. A typical monorepo combines them:
CLAUDE.md files by directory. A root file sets repository-wide rules; each package adds its own. Claude loads the root plus the package you start in, and pulls in a subdirectory's file on demand when it reads there. Keep each file focused on its own area so context is not spent on unrelated subsystems.CLAUDE.md files with claudeMdExcludes (glob patterns matched against absolute paths) for packages you never touch, such as other teams' code or vendored subtrees.Read deny rules in permissions.deny, for example "Read(./**/dist/**)" and "Read(./vendor/**)". Searches already respect .gitignore, so this is for checked-in artifacts.additionalDirectories when a change spans packages.A committed packages/api/.claude/settings.json that combines these:
{
"permissions": {
"additionalDirectories": [
"../shared"
],
"deny": [
"Read(./**/dist/**)",
"Read(./**/build/**)"
]
}
}
Because project settings load only from your starting directory, each subdirectory's .claude/settings.json must be self-contained rather than layered on a root file.
If you start sessions in a new git worktree with --worktree, the entire repository is checked out by default. In a large repository, the worktree.sparsePaths setting uses git sparse-checkout to write only the listed directories (plus root-level files) to disk:
{
"worktree": {
"sparsePaths": [
".claude",
"packages/api",
"packages/shared"
],
"symlinkDirectories": [
"node_modules"
]
}
}
Paths are relative to the repository root regardless of where you launch Claude. List directories, not individual files; root-level files like lock files and tsconfig.base.json are always included. Add .claude if you want the repository root's .claude/ available inside the worktree. Pair with symlinkDirectories to avoid duplicating large directories such as node_modules across worktrees.
Note that sparsePaths and symlinkDirectories are read from your starting directory before the worktree is created; after creation the session's working directory is the worktree root, so put permission rules and hooks you need inside worktrees in the repository root's .claude/settings.json.
Configuration controls what Claude can see; how you scope the task affects the result:
--add-dir, /add-dir, or additionalDirectories, or start Claude from the repository root.CLAUDE.md is being ignored. The additionalDirectories setting never loads memory files. Use --add-dir with CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1, or layer a CLAUDE.md in your own tree instead..claude/settings.json are not taking effect. Project settings load only from the directory you start in. A root settings file does not apply when you launch from a subdirectory.Show that Multi-Directory and Monorepo Setup in Claude Code is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/guides/multi-directory-setup)Multi-Directory and Monorepo Setup in Claude Code side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
2 trust signals differ across this comparison (Source provenance, Submitter).
| Field | How to give Claude Code access to more than one directory: the --add-dir flag, the /add-dir command, and the permissions.additionalDirectories setting, plus how each one handles CLAUDE.md, rules, and skills in monorepos. Open dossier | A practical walkthrough of structuring CLAUDE.md across a monorepo: how files load up the directory tree and on demand in subdirectories, path-scoped rules, imports, excluding other teams' files, and keeping per-package context lean. Open dossier | Set up sparse context for large codebases in Claude Code: scoped directories, CLAUDE.md hierarchy, subagents, and avoiding whole-repo loading. Open dossier | Configure Claude Code in JetBrains IDEs for large repositories: terminal rendering fixes, synchronized output, sparse context, and plugin workflows for IntelliJ-based teams. Open dossier |
|---|---|---|---|---|
| Next steps | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenanceDiffers | Source-backed | Source-backed | Submission linkedSource submission | Submission linkedSource submission |
| SubmitterDiffers | — | JPette1783 | kiannidev | kiannidev |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | guides | guides | guides | guides |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JPette1783 | kiannidev | kiannidev |
| Added | 2025-10-27 | 2026-06-05 | 2026-06-14 | 2026-06-14 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Any directory you grant with --add-dir, /add-dir, or additionalDirectories is readable and editable by Claude in that session; only add directories you intend Claude to modify. | ✓CLAUDE.md is context, not enforcement; for rules that must always hold (block a path, run a check before commit), use a PreToolUse hook or managed settings, not prose. Conflicting instructions across nested CLAUDE.md files cause Claude to pick one arbitrarily; review the hierarchy periodically to remove contradictions. Managed-policy CLAUDE.md cannot be excluded by individual settings; keep organization-wide rules there when they must always apply. | ✓Sparse context reduces accidental edits outside the intended package but does not replace code review—verify diff scope before merge. Do not disable permission prompts to speed up large-repo exploration. When using subagents for exploration, constrain file access to approved directories. | ✓Large-repo sessions amplify token usage—use sparse context and compaction hygiene to avoid runaway costs. JetBrains terminals on 2026.1+ use synchronized output; avoid custom ANSI themes that fight IDE rendering. Do not mount entire monorepo secrets into agent sessions; scope working directories per module. |
| Privacy notes | ✓Granting a directory exposes its file contents to the session and the model provider; do not add directories containing secrets or unrelated private code. | ✓CLAUDE.md and loaded rules are sent to the model provider every session; keep secrets and sensitive data out of them, and use CLAUDE.local.md (gitignored) for personal notes. @path imports load the referenced files into context at launch; do not import files containing credentials. In large monorepos, other teams' CLAUDE.md may load unexpectedly; use claudeMdExcludes to avoid pulling in unrelated or sensitive context. | ✓Large-repo CLAUDE.md files may reference internal service names across business units; scope instructions to teams that should see them. Sparse setups often use multiple CLAUDE.md files; ensure nested files do not leak restricted submodule details to broader teams. Exploration subagents may still read sensitive paths if permissions are too broad—align with least-privilege directory scope. | ✓IDE-integrated sessions expose package names, module paths, and dependency graphs in prompts. Usage and session data follow the same data-usage policies as terminal Claude Code. Shared JetBrains licenses on VDI pools can leak session resumes—use per-developer config directories. |
| Prerequisites |
|
|
|
|
| Install | — | — | — | — |
| Config | — | — | — | — |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.