Automate Repetitive Tasks with Hooks
Hooks are shell commands that execute automatically in response to Claude Code events. Configure them in your settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "vendor/bin/pint --dirty"
}
]
}
]
}
}
This example automatically runs Pint after every file edit — so your code is always formatted without you having to remember.
Available hook events:
- PreToolUse — runs before a tool executes
- PostToolUse — runs after a tool completes
- Stop — runs when Claude finishes its turn and returns control to you
The matcher field is a regex matched against the tool name (Write, Edit, Bash, etc.). Use ".*" to match all tools, or pipe-separate specific ones.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "vendor/bin/pint --dirty"
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo 'Running a shell command...'"
}
]
}
]
}
}
Hooks run synchronously — a PostToolUse hook fires before Claude moves to the next step, making it perfect for linting, formatting, or running a quick type-check after every change.
Use /update-config to set these up interactively, or just ask Claude to write the hook configuration for your specific needs.
Hooks turn repetitive quality steps into automatic ones — set them once and forget them.
Log in to leave a comment.
The autoUpdatesChannel setting pins Claude Code to a stable release track that skips versions with major regressions.
The language setting makes Claude respond in your preferred language by default, across every session and project.
The attribution setting lets you customize or completely remove Claude's Co-Authored-By trailer from git commits and pull requests.