fix(setup): guard against project-local install colliding with the user-global Claude config#53
Merged
Conversation
…er-global Claude config Running the default project-local setup with cwd == $HOME makes "./.claude" the same directory as ~/.claude — Claude Code's user-global config. Relative hook commands written there load for every session on the machine but only resolve when the session's working directory is $HOME; everywhere else the hooks fail (loudly in interactive sessions, silently in -p mode) and the memory integration stops working. ClaudeRegisterHooks now detects exactly that collision (symlink-resolved comparison, CLAUDE_CONFIG_DIR-aware) and writes absolute hook commands for it, honoring the user-global file's existing contract. Genuine project-local installs are untouched and keep their relative form.
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.
What
Running the default project-local
mnemon setup --target claude-codewith cwd ==$HOMEmakes./.claudethe same directory as~/.claude— Claude Code's user-global config. The relative hook commands written there load for every session on the machine but only resolve when the session's working directory is$HOME; elsewhere the hooks fail (loudly in interactive sessions, silently in-p) and the memory integration stops working.ClaudeRegisterHooksnow detects exactly that collision and writes absolute hook commands for it — honoring the contract the user-global file already has under--global— and prints a note suggesting--globalfor explicitness:Detection details, each pinned by a test:
$HOMEreached via symlink still collides with the physical path)CLAUDE_CONFIG_DIR: when set,~/.claudeis not the user-global dir and does not trigger the guard; the relocated dir doesIf you'd rather fail hard on the collision ("use
--global") instead of rerouting, happy to flip it — one small change, the tests cover the detection either way.Why
Fixes #52. Reproduced on mnemon 0.1.13 / Claude Code 2.1.163, macOS + Linux; full evidence (write/loader matrices with controls, a production before/after, fleet frequency) in the linked issue.
Checklist
make testandgo test ./...) — alsomake unit,make vet,gofmtCLAUDE_CONFIG_DIRcases; collision writes absolute; project-local stays relative)--globalsemantics are exactly as the README describes$HOME(or targetingCLAUDE_CONFIG_DIR) now writes absolute hook commands instead of relative ones that fail outside$HOME