DirectoryAdded API

August 15, 2026 ยท View on GitHub

Available when inheriting from ClaudeHooks::DirectoryAdded:

Runs after a working directory is added mid-session via /add-dir or the SDK register_repo_root control request. Non-blocking โ€” the directory is already added when the hook runs.

Input Helpers

๐Ÿ“š Shared input helpers

MethodDescription
directoryAbsolute path of the directory that was added
sourceHow the directory was added: 'slash_command' for /add-dir or 'register_repo_root' for the SDK control request

Hook State Helpers

๐Ÿ“š Shared hook state methods

MethodDescription
system_message!Set a message delivered to Claude as context on the next turn (slash_command) or written to the debug log (register_repo_root)

Output Helpers

๐Ÿ“š Shared output helpers

MethodDescription
output.system_messageThe configured system message

Hook Exit Codes

Non-blocking. Exit code is ignored; only systemMessage is consumed.