fix(cli): honor Claude profile configuration - #1473
Merged
Merged
Conversation
The Claude hook resolved user-level settings as a hardcoded ~/.claude and never read CLAUDE_CONFIG_DIR, which Claude Code treats as a full replacement for that directory. Users running per-account profiles hit two problems: a basicMemory block in the active profile was never read, so hook status reported "settings: not found" and capture fell back to the default project; and `hook install` wrote hook entries into ~/.claude/settings.json regardless of the active profile, editing another account's configuration. Add _claude_user_dir(), honouring CLAUDE_CONFIG_DIR and falling back to ~/.claude so single-profile setups are unchanged, and use it for both the settings base and the install/remove target. The ancestor walk in _claude_project_dir can reach $HOME and find ~/.claude/settings.json. That was previously suppressed by comparing the resolved project root to $HOME; keep that guard alongside the new profile-dir comparison, otherwise the default profile's settings re-enter as a higher-precedence project source and override the active profile. Clear CLAUDE_CONFIG_DIR in the CLI test isolation fixture so a contributor running the suite under a profile wrapper does not read their real config. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Felipe Zipitria <fzipi@fing.edu.uy> (cherry picked from commit c189352)
CLAUDE_CONFIG_DIR can legitimately point at a repository's own .claude directory. Skipping the project sources whenever that directory matched the profile dir dropped settings.local.json entirely, so its higher-precedence primaryProject was ignored and hooks routed notes to the profile-wide project. Deduplicate by resolved file path rather than by directory: settings.json is read once as the user-level source, and settings.local.json still layers on top of it. Reported by the Codex review bot on #1420. Signed-off-by: Felipe Zipitria <fzipi@fing.edu.uy> (cherry picked from commit 54df21f)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33e46ff4ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLAUDE_CONFIG_DIRwhen resolving Claude Code hook settings~/.claudesettings.local.jsonprecedence when the profile directory overlaps the projectWhy
Claude Code supports profile-specific configuration through
CLAUDE_CONFIG_DIR. The hook command ignored that setting, which could read or modify a different account's configuration and route captures to the wrong Basic Memory project.Claude Code also treats the variable as a literal path whenever it is present. Normalizing, expanding, or treating an empty value as unset would make Basic Memory target a different settings file than Claude Code.
Implementation
~/.claudeonly when it is unsetCLAUDE_CONFIG_DIRTesting
uv run pytest tests/cli/test_hook_command.py -q(118 passed)just fast-checkjust package-check-claude-code/reviewbefore each maintainer push (no findings after fixes)Attribution
Supersedes #1420 while preserving @fzipi's original commits, authorship, sign-offs, and cherry-pick provenance.