basic-memory icon indicating copy to clipboard operation
basic-memory copied to clipboard

feat(plugins): fall back to user-level ~/.claude settings for Claude Code hook config

Open samuellawerentz opened this issue 5 months ago • 5 comments

Problem

The Claude Code plugin's SessionStart and PreCompact hooks read the basicMemory block only from <cwd>/.claude/settings.json. Every project therefore needs its own config block (or a bm-setup run) before the brief resolves a pinned project — and the PreCompact checkpoint is a silent no-op everywhere until then. Users with a single primary knowledge graph end up repeating the same block in every repo.

Change

load_settings in both hooks now merges the user-level ~/.claude/settings.json and settings.local.json as the base, with the project's .claude files overriding per key — the same layering Claude Code itself uses for settings:

user settings.json → user settings.local.json → project settings.json → project settings.local.json

One user-level basicMemory block covers every project; a project that pins its own primaryProject still wins. When cwd is the home directory the user level is read once, not twice.

Also documents the user-level option in the plugin README.

Testing

  • bash -n on both hooks.
  • Manually invoked session-start.sh with a payload cwd of a repo with no .claude/settings.json: brief resolves the project from the user-level block (previously: "default project" + setup nudge).
  • Same with a project-level block present: project value wins.
  • pre-compact.sh resolves primaryProject from the user level the same way (previously exited silently).

🤖 Generated with Claude Code

Reviewed SHA: 868d2094c77aae23d1de92c72be3708ea8c3b293 Verdict: needs_human Status: failure - BM Bossbot review did not finish

Summary: BM Bossbot intentionally did not run Codex because this PR was not opened by an owner, member, or collaborator.

Blocking findings:

  • BM Bossbot does not run for outside contributors: This PR author association is NONE. BM Bossbot only runs for OWNER, MEMBER, and COLLABORATOR pull requests, so this PR requires a maintainer path outside the automatic merge gate.

Non-blocking findings:

  • None

samuellawerentz avatar Jun 09 '26 19:06 samuellawerentz

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Jun 09 '26 19:06 CLAassistant

thanks @samuellawerentz. I had not gotten around to adding the user level settings. Thats much needed.

Do you mind signing off on your commits? and signing the cla? We need that before we can merge this.

In your local branch, run: git rebase HEAD~1 --signoff

phernandez avatar Jun 09 '26 21:06 phernandez

Sure, I'll get these fixed and signed as well. This is a good plugin and a good tool that I use, which has solved my memory problems across the different harnesses. Thank you.

samuellawerentz avatar Jun 10 '26 03:06 samuellawerentz

Labeling needs-review: there are unresolved review threads on the hook fallback behavior that need a decision before this merges (merge precedence between project and user-level settings, and the skill doc updates). No action needed from the author yet — maintainers will follow up on the threads.

phernandez avatar Jun 10 '26 04:06 phernandez

@samuellawerentz Thanks for the contribution — the user-level settings fallback is a direction we're interested in, and your follow-up commits addressing the review were appreciated.

One mechanical blocker before we can take this further: the DCO check requires every commit to carry a Signed-off-by trailer, and the first commit on the branch (f94ae316) doesn't have one. The easiest fix signs everything and tidies the merge commits away in one go — from your local clone of the branch:

git fetch origin main
git rebase origin/main --signoff
git push --force-with-lease origin global-settings-fallback

(If your fork's remote is named differently, swap origin accordingly in the push. --signoff adds the trailer to each replayed commit using your configured git identity, which certifies the Developer Certificate of Origin.)

Once DCO is green we'll pick the review threads back up. Thanks again!

phernandez avatar Jun 10 '26 19:06 phernandez