Skip to content

fix(setup): guard against project-local install colliding with the user-global Claude config#53

Merged
Grivn merged 1 commit into
mnemon-dev:masterfrom
MoonCaves:fix/home-collision-guard
Jun 8, 2026
Merged

fix(setup): guard against project-local install colliding with the user-global Claude config#53
Grivn merged 1 commit into
mnemon-dev:masterfrom
MoonCaves:fix/home-collision-guard

Conversation

@MoonCaves

Copy link
Copy Markdown
Contributor

What

Running the default project-local mnemon setup --target claude-code with cwd == $HOME makes ./.claude the 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.

ClaudeRegisterHooks now 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 --global for explicitness:

  Note: this project config dir is Claude Code's user-global config (~/.claude);
        writing absolute hook paths so hooks resolve from any directory.
        Use --global to make a user-wide install explicit.

Detection details, each pinned by a test:

  • both sides symlink-resolved before comparison (a $HOME reached via symlink still collides with the physical path)
  • honors CLAUDE_CONFIG_DIR: when set, ~/.claude is not the user-global dir and does not trigger the guard; the relocated dir does
  • genuine project-local installs are untouched — commands keep their current relative form, byte-for-byte

If 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

  • Tests pass (make test and go test ./...) — also make unit, make vet, gofmt
  • New/changed behavior covered by tests (collision detection incl. symlink + CLAUDE_CONFIG_DIR cases; collision writes absolute; project-local stays relative)
  • Documentation — n/a: no documented behavior changes; the project-local default and --global semantics are exactly as the README describes
  • Release-note impact: project-local setup run from $HOME (or targeting CLAUDE_CONFIG_DIR) now writes absolute hook commands instead of relative ones that fail outside $HOME

…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.

@Grivn Grivn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Grivn Grivn merged commit 1982cff into mnemon-dev:master Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants