[FEATURE] claudeMdExcludes cannot express "do not load ancestors" — request a launch-scoped memory boundary
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
CLAUDE.md traversal from the working directory to / runs on every launch. It can be narrowed only by naming paths — claudeMdExcludes skips files whose absolute path matches a glob — or by dropping a whole settings tier with --setting-sources. No setting, flag or environment variable expresses "stop at the working directory".
Prior art, stated up front: #20880 asked for this and was closed as completed on 2026-08-17 with claudeMdExcludes. #26944 and #15332 were closed as duplicates; #19458 was closed as not planned, and #34209 and #3232 were closed by the stale bot. This request is narrower and is not satisfied by claudeMdExcludes, for three structural reasons:
- Patterns cannot be written relative to the launch directory. Entries are globs matched against absolute file paths, so a pattern either names one tree or, if made broad enough to catch arbitrary ancestors, catches the working directory's own file as well:
**/CLAUDE.mdin~/.claude/settings.jsonexcludes the file I want along with the ones I don't. "Every CLAUDE.md above the working directory, wherever that directory is" has no expressible form. - The list is exclusion-only. There is no documented negation or include form, so the ancestors can only be enumerated, tree by tree, as each new project root appears.
- Arrays merge across settings layers. A lower scope can add exclusions but never narrow an inherited list — the docs state this for
claudeMdExcludesand spell out the same semantics forworktree.sparsePaths("a local file can add paths to the committed list but not remove them") — so a per-project override of a broad user-level pattern is impossible.
The result is that a user who wants working-directory isolation as a machine-wide default has no supported way to express it. Note the sequence in #20880: the setting was pointed out in-thread on 2026-05-25, a further +1 was posted on 2026-07-16, and the issue was closed on 2026-08-17 — after which I replied pointing out that claudeMdExcludes "is not a global on/off switch I can configure at the user level" and must be repeated per project. The same thread also proposed a configurable resolution policy rather than more exclusions, for the same reason.
Proposed Solution
A setting honored at user scope, so it applies to every project on the machine without per-repo configuration. Any one of these closes the gap:
{ "memoryScope": "cwd" }
with "cwd" (working directory only), "repo" (stop at the nearest enclosing .git), and "filesystem" (today's behaviour, the default). A boolean "ancestorTraversal": false would do equally well.
Alternatively, or in addition:
- Stop at the git boundary. If the working directory is inside a repository, do not traverse above its root. An independent checkout nested inside another project is the common case.
- A
root: truemarker in a CLAUDE.md's frontmatter, meaning "traversal stops here", which lets the boundary be committed with the repository that owns it.
The setting should cover CLAUDE.md, CLAUDE.local.md, .claude/CLAUDE.md and .claude/rules/ uniformly — every memory file an ancestor directory contributes. claudeMdExcludes is already documented to reach two of those: a directory pattern "skips every CLAUDE.md and rules file under that package". Coverage is not the gap; the gap is that the coverage is reachable only by naming absolute paths.
Alternative Solutions
Considered, and why each falls short:
claudeMdExcludeswith the ancestors enumerated — works per tree, must be written again for every new project root, and a pattern broad enough to be reusable (**/CLAUDE.md) also excludes the working directory's own file. This is the per-project maintenance the request is trying to avoid.--setting-sources— not a lever for this.projectnames a whole settings tier, and there is no documented way to separate the working directory from its ancestors within it. What each value actually gates is itself undocumented (#92254), and #87590 reports that--setting-sources projectstill loads~/.claude/CLAUDE.mdand~/.claude/rules/*.md.permissions.denyonRead(CLAUDE.md)— does not apply. Deny rules are documented as covering the built-in file tools and the file commands Claude Code recognises in Bash; memory files are injected at session start rather than read through a tool, so there is nothing for the rule to intercept.- Renaming the parent CLAUDE.md and pulling it in with
@import— suggested in #20880; fragile, and breaks for anyone else working in the parent project. - Wrapping the binary so the exclusion list is synthesised at launch, walking the ancestors of
$PWDand passing them asclaudeMdExcludesthrough--settings. I have not verified that this suppresses the files, so I make no claim that it works; I mention it because it is the only remaining shape a solution can take today, and a shell wrapper computing an exclusion list on every launch is not a reasonable way to express "load only this directory's instructions".
Priority
Critical - Blocking my work
Feature Category
Configuration and settings
Use Case Example
A component developed inside a larger tree, where the two levels have different conventions:
project/
CLAUDE.md # conventions for the outer project
subproject/
CLAUDE.md # conventions for this component
cd project/subproject && claude/context→ Memory files lists three:~/.claude/CLAUDE.md,project/CLAUDE.md,project/subproject/CLAUDE.md.- Only the first and the third are wanted. The outer file describes sibling components that are not in scope, and its instructions compete with the component's own wherever the two differ.
- To suppress it today I must add the outer file's absolute path to
.claude/settings.local.jsoninside the component — then repeat that for every sibling component, and again for every unrelated project on the machine.
What I want instead: set memoryScope once in ~/.claude/settings.json, and have every session anywhere on the machine load the working directory's instructions and nothing above it.
Additional Context
- Docs: Exclude specific CLAUDE.md files, Monorepos and large repos
- The monorepo guide states the exclusion list is "static, not a per-task switch" and suggests starting Claude "from that package's directory instead of editing exclusions". That answers the sibling-package case; it does not answer this one, because whichever directory the session starts in, every CLAUDE.md above it still loads.
- Related and still open: #16600 (the same request restricted to git worktree boundaries),
anthropics/claude-agent-sdk-typescript#149(proposesmemoryScope: 'cwd-only'/disableParentMemoryTraversalfor the SDK, open and unanswered since 2026-01-23). A shared resolver setting would cover both surfaces. - Closed for reference: #20880, #26944, #15332, #19458, #34209, #3232.