You can now run a hook whenever a directory is added mid-session, including via /add-dir.
What's wrong with this entry?
Hooks gained a DirectoryAdded event that fires after a working directory is registered mid-session, so you can react to /add-dir and to SDK-driven directory registration.
- Described in the hook config as "After a working directory is added mid-session"; fires after the directory is registered and after the sandbox config is refreshed.
- Hook input JSON carries the absolute
directoryand asource; the matcher can match on"slash_command"for /add-dir and"register_repo_root"for the SDK control request. - Registered in the hook config schema, the hook registry, the SDK hook-event enum and the /hooks UI.
- Failure handling differs by path: for /add-dir a failure count is summarised to Claude and hook
systemMessageoutput reaches Claude; forregister_repo_rootfailures are debug-logged only, via "DirectoryAdded hook failed: ".
"slash_command" for /add-dir, "register_repo_root" for the SDK control_request., After a working directory is added mid-session
Strings lifted out of the shipped bundle, so the claim above can be checked against them.