Configure an async hook
Add "async": true to a command hook's configuration to run it in the background without blocking Claude. This field is only available on type: "command" hooks.
This hook runs a test script after every Write tool call. Claude continues working immediately while run-tests.sh executes. When the script finishes, its output is delivered on the next conversation turn:
json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "/path/to/run-tests.sh",
"async": true
}
]
}
]
}
}Once an async hook is running in the background, Claude Code doesn't enforce timeout on it. Claude Code still enforces timeout on a hook you run with asyncRewake.
Claude Code delivers an async hook's results only while the session runs:
- In non-interactive mode with the
-pflag, Claude Code kills any async hook still running at teardown and finalizes it with outcomecancelled - If your hook's work must outlive a
claude -psession, start a fully detached process from it