feat(claudecode): follow the DirectoryAdded event, documented hook handler fields, and skill background - #2471
Merged
Conversation
…ndler fields, and skill background Adds the DirectoryAdded hook event, carries the documented per-handler fields (args, async, asyncRewake, shell, statusMessage, once, continueOnBlock) through generate and import for both claudecode and claudecode-plugin, drops matchers on UserPromptSubmit and Stop as the docs' matcher table requires, and makes the skill frontmatter background field authorable.
…mand-only fields off other hook types
Review follow-ups: an empty args array selects the exec form too, which is the form the docs' own example uses. Rather than dropping the project-directory prefix there, emit the braced ${CLAUDE_PROJECT_DIR} placeholder that Claude Code substitutes itself, and strip it again on import. args/async/asyncRewake/shell are documented on command hooks only, so passthrough descriptors gained a commandOnly flag.
This was referenced Jul 29, 2026
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.
Background
Related issue: #2397 (partial — this PR covers gaps 1, 2, 3 and 5; gaps 4 and 6 follow separately)
Claude Code added a
DirectoryAddedhook event, documents a set of per-handler hook fields that rulesync silently dropped on generate, lists two more events as taking no matcher, and added abackgroundskill frontmatter field. Each was verified against the hooks docs, the skills docs and the upstream CHANGELOG before implementing.Changes
DirectoryAdded(gap 1). Added as canonicaldirectoryAddedplus the Claude mapping. The event is announced in the 2.1.219 changelog ("fires after/add-diror the SDKregister_repo_rootcontrol request registers a new working directory mid-session") but has no row in the docs' event table yet, so its matcher support is unknown and it is treated as no-matcher — a matcher authored on it is dropped with the existing warning rather than written intosettings.jsonto be ignored. Noted in a code comment.Dropped handler fields (gap 2).
args,async,asyncRewake,shell,statusMessage,onceandcontinueOnBlocknow generate and import forclaudecodeandclaudecode-plugin(which shares the converter config).asyncRewakeandcontinueOnBlockare new on the canonicalHookDefinitionSchema; the rest already existed. The boolean and string passthrough unions widened accordingly.applyCommandPrefixno longer rewritescommandwhen the exec form is in use: withargspresent the tool spawnscommanddirectly, with no shell to expand$CLAUDE_PROJECT_DIRor strip the quotes the prefix adds, so the prefixed string would be looked up as a literal file name. The check is gated on the converter actually emittingargs, so shell-form hooks and other tools are unaffected — verified both branches.Missing no-matcher events (gap 3).
beforeSubmitPrompt(→UserPromptSubmit) andstopadded toCLAUDE_NO_MATCHER_EVENTS, matching the docs' matcher table.Skill
background(gap 5). Added to the Claude Code skill frontmatter schema and theclaudecodesection of the rulesync skill schema, carried as a defined field rather than a truthy one —background: falseis the whole point, and a truthy check would drop it. Applies toclaudecode-plugintoo, sinceClaudecodePluginSkillextendsClaudecodeSkill.Deferred to follow-up PRs
Write(path)/NotebookEdit(path)/Glob(path)forms Claude Code warns about) — confirmed against the docs and worth fixing, but it changes generated permission output and deserves its own diff.sandbox.*authorable through theclaudecodepermissions override) — a new public override surface that Claude Code permissions: supportpermissions.defaultModeandpermissions.additionalDirectories(and notesandbox.*) #2129 deliberately deferred.This PR therefore does not close #2397.
Verification
pnpm cicheck(full: code + content)npx vitest run --config vitest.e2e.config.ts src/e2e/e2e-hooks.spec.ts src/e2e/e2e-skills.spec.ts