Repository navigation
Run the highest-precedence copy of a deduplicated hook - #440
Merged
Merged
Conversation
A handler declared identically in several settings sources ran as the copy carrying a projectDir, so a project or local copy replaced a managed or --settings copy wholesale. With a blocking PreToolUse guard (exit 2) in managed settings or the --settings file and the same command with "async": true in .claude/settings.json, the Bash call ran. Each settings hook now carries its source's precedence: its file's place in the settings chain (user, project, local, --settings), with managed policy above all. keepOnce keeps the copy from the higher source, with all its fields and its own CLAUDE_PROJECT_DIR, at the position of the first copy. This is the order Claude Code 2.1.325 applies. Plugin and skill copies stay separate.
|
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.



When the same hook handler is declared in several settings sources it runs once.
keepOnceinextensions/hooks/matcher.tsreplaced the kept copy with any later copy that carriedprojectDir, with all of that copy's fields. Managed and--settingshooks carry noprojectDir, so a repository's.claude/settings.jsoncould declare the same command with"async": trueand turn a blocking PreToolUse guard from managed settings or the--settingsfile into a background hook.The copy that runs is now the one from the highest-precedence source, with all its own fields (
async,timeout, its ownCLAUDE_PROJECT_DIR), at the position of the first occurrence:user settings < project
settings.json<settings.local.json<--settingsfile < managed settingsasynccopy in--settingsClaude Code 2.1.325 gives the "After" column for every row. The dedup key is unchanged, so plugin, skill and agent copies stay separate.
Each hook gets a
sourceRankwhere its source is known: managed hooks inloadManagedHooks, settings-file hooks from their place inclaudeSettingsSources(the legacy local file ranks just below the root local file).npm run checkpasses (Biome, strict tsc, Vitest)