Claude CodeAdvancedClaude Code
Hooks receive JSON on stdin: parse it with jq
To log or format after every tool call with a PostToolUse hook, read the data from stdin with jq: variables like $TOOL_INPUT do not exist.
A PostToolUse hook runs a shell command after each tool call finishes, filtered by matcher. The call's data arrives as JSON on stdin, so you extract it with jq. It is useful for auditing every Bash command or formatting every edited file. Hooks run with the same permissions as your session: review the scripts before handing them out to the team.
Example
// .claude/settings.json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "jq -r '.tool_input.command' >> ~/claude-bash-log.txt" }
]
}
]
}
}