fix(claude): stop project SessionStart hook from firing at user scope - #65
Merged
Conversation
The dotfiles .claude/settings.json served two roles: the dotfiles repo's project settings AND, via link-agents.sh, the user-scope settings symlinked to ~/.claude/settings.json. Because the user-scope copy carried a SessionStart hook pointing at the project-relative $CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh, that hook fired in every project and errored in any repo lacking that script. Split the roles: settings.global.json holds the universal user-scope prefs (no project-relative paths) and is what link-agents.sh now links into ~/.claude; settings.json keeps only the SessionStart bootstrap hook and is read solely as the dotfiles repo's project settings. Web bootstrap is unchanged -- opening the repo still fires the hook, which runs link-agents. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dijonkitchen
force-pushed
the
fix/claude-user-scope-hook-leak
branch
from
June 8, 2026 14:57
8fb2572 to
e5fd39b
Compare
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.
Problem
dotfiles/.claude/settings.jsondid double duty: it was both the dotfiles repo's project settings and, vialink-agents.sh, the user/global settings symlinked to~/.claude/settings.json.Because the user-scope copy carried a
SessionStarthook pointing at the project-relative$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh, that hook fired in every project and errored in any repo that doesn't ship the script:Fix
Split the two roles:
.claude/settings.global.json(new) — universal user-scope prefs (permissions, statusLine, editorMode, worktree, verbose), no project-relative paths.link-agents.shnow links this into~/.claude/settings.json..claude/settings.json— trimmed to just theSessionStartbootstrap hook; read only as the dotfiles repo's project settings.Web bootstrap is unchanged: opening the repo still fires the project hook, which runs
link-agents.sh.Result across contexts
CLAUDE_CODE_REMOTE != true). No more error in other repos.~/.claude/settings.jsonis purely universal prefs, zero project paths.~/.claude.Tests
bats tests/link-agents.bats→ 6/6 pass, including a new test asserting the global link resolves tosettings.global.jsonand that global has noCLAUDE_PROJECT_DIRwhile project keeps the hook.shellcheckclean.bootstrap.batsfailures (mise ... not trustedin the sandbox) are unrelated — confirmed identical on a clean tree.🤖 Generated with Claude Code