Learn how to customize and extend Claude Code’s behavior by registering shell commands
prettier
on .ts files, gofmt
on .go files,
etc. after every file edit.jq
for JSON processing in the command line.
/hooks
slash command and select
the PreToolUse
hook event.
PreToolUse
hooks run before tool calls and can block them while providing
Claude feedback on what to do differently.
+ Add new matcher…
to run your hook only on Bash tool calls.
Type Bash
for the matcher.
*
to match all tools.+ Add new hook…
and enter this command:
User settings
since you’re logging to your home
directory. This hook will then apply to all projects, not just your current
project.
Then press Esc until you return to the REPL. Your hook is now registered!
/hooks
again or check ~/.claude/settings.json
to see your configuration:
ls
and check your log file: