claude-code - 💡(How to fix) Fix [FEATURE] Load .claude/settings*.json and hooks from directories added via --add-dir / additionalDirectories [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52934Fetched 2026-04-25 06:16:49
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2
RAW_BUFFERClick to expand / collapse

The gap

Claude Code currently loads .claude/settings.json and .claude/settings.local.json (and their configured hooks) only from the session's startup working directory. When an additional directory is brought into the session — via --add-dir, /add-dir, or permissions.additionalDirectories — its .claude/settings*.json is ignored.

Concretely: a repo-local PreToolUse hook configured in repo-X/.claude/settings.local.json will fire only when Claude Code is started from repo-X/. If the user starts Claude Code elsewhere and then asks it to do work in repo-X (whether via /add-dir or just operating on files inside that tree), the hook does not fire — so the repo's local policy (linters, title checks, commit-message checks, permission scopes, etc.) is silently bypassed.

Why it matters

Hooks are the mechanism for repo-local policy enforcement (e.g. blocking PRs with off-convention titles, running formatters, gating risky commands). For them to be useful, they need to follow the repo, not the session. Otherwise every multi-repo session silently falls back to user-global rules, and project owners can't rely on their repo-local hooks being honoured.

Related issues (already covering adjacent surface)

  • #44224 — --add-dir doesn't load skills from .claude/skills/
  • #30064 / #37553 — additionalDirectories doesn't load skills
  • #22583 — CLAUDE.md doesn't load from additionalDirectories (though it does load via --add-dir)
  • #26489 — feature request for .claude/ traversal into parent directories

Settings/hooks loading is not covered by any of these.

Proposal

When a directory is added to a session (via --add-dir, /add-dir, or permissions.additionalDirectories), and that directory contains .claude/settings.json or .claude/settings.local.json, merge them into the active session config under the usual precedence rules. Hooks defined there should fire for tool calls whose effect scope is within that directory (e.g. Bash commands whose cwd is inside the added tree, Edit/Write calls targeting files inside it).

Alternatives considered

  • User-global hook in ~/.claude/settings.json with a cwd / path check to no-op outside the target repo. Works, but requires the user to mentally track every repo-specific hook in one global file — doesn't compose.
  • Restarting Claude Code from the target repo. Works, but breaks the common "one session, many repos" flow.

Scope note

This is intentionally narrower than "load everything" — the ask is specifically for settings*.json and hooks. Skills and CLAUDE.md are already (partially) covered by the issues above.

extent analysis

TL;DR

Merge .claude/settings.json and .claude/settings.local.json from added directories into the active session config to enable repo-local policy enforcement.

Guidance

  • When a directory is added to a session, check if it contains .claude/settings.json or .claude/settings.local.json and merge them into the active session config.
  • Ensure that hooks defined in these files fire for tool calls within the added directory's scope.
  • Verify that the merged config follows the usual precedence rules to avoid conflicts.
  • Test the implementation with different scenarios, such as adding a directory with a PreToolUse hook and checking if it fires as expected.

Example

No code snippet is provided as the issue does not contain specific code references.

Notes

The proposed solution focuses on merging settings*.json and hooks, while skills and CLAUDE.md are covered by separate issues.

Recommendation

Apply the proposed workaround by merging .claude/settings.json and .claude/settings.local.json from added directories into the active session config, as it addresses the specific issue of repo-local policy enforcement without introducing broader changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [FEATURE] Load .claude/settings*.json and hooks from directories added via --add-dir / additionalDirectories [1 participants]