5 Claude Code Hooks I Use Daily
Claude Code hooks run shell commands on session start, file writes, and tool calls. Here are the 5 I use daily and how to configure them.

Most people discover Claude Code for the AI. They miss the hooks.
Hooks are shell commands that execute automatically when something happens in your Claude Code session: a session starts, a tool runs, Claude stops. You define them in .claude/settings.json. They run silently in the background.
Here are the 5 I use every day.
What hooks look like
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [{ "type": "command", "command": "date +%F" }]
}
]
}
}The available events: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop.
Hook 1 - Auto-inject date on every prompt
Event: UserPromptSubmit
echo "Context: today is $(date '+%A %B %d, %Y')."Claude doesn't have real-time awareness. Every prompt gets the current date injected automatically. Useful for anything time-sensitive: changelogs, deadlines, scheduling logic.
Hook 2 - Push notification when Claude stops
Event: Stop
osascript -e 'display notification "Claude is done" with title "Claude Code"'Long tasks (refactors, test runs, analysis) can take 2–5 minutes. Without a notification I'd either stare at the screen or miss the result. This fires whenever Claude finishes a task, whether it succeeded or hit a limit.
On macOS you get a native notification. On Linux, swap for notify-send.
Hook 3 - Safety check before Bash runs
Event: PreToolUse (Bash)
command=$(jq -r '.tool_input.command // ""')
if echo "$command" | grep -qE '(rm -rf|drop table|DELETE FROM|reset --hard)'; then
echo "BLOCKED: destructive command detected. Confirm manually." >&2
exit 2
fiThis intercepts every Bash tool call and blocks patterns I've flagged as dangerous. For PreToolUse, exit code 2 blocks the call. This pattern list is not a security boundary: it cannot catch every dangerous command. Configure tool permissions separately.
Hook 4 - Auto-lint after every file write
Event: PostToolUse (Write/Edit)
file=$(jq -r '.tool_input.file_path // ""')
ext="${file##*.}"
if [[ "$ext" == "ts" || "$ext" == "tsx" ]]; then
npx eslint "$file"
fiThe script runs ESLint on matching TypeScript files without changing them. Inspect its output and run the project's checks as well: a post-write hook cannot undo a change already made.
Hook 5 - Load project briefing on session start
Event: SessionStart
cat .claude/briefing.md 2>/dev/null && echo "---"
git log --oneline -5 2>/dev/nullMy .claude/briefing.md has: current sprint goal, in-progress work, known blockers. Combined with the last 5 commits, Claude starts each session with the project's actual state - not just what's in CLAUDE.md.
I update the briefing file whenever priorities shift. Takes 30 seconds.
Test the filter before enabling it
Save the hook 3 example as check-bash.sh, then test a normal input and a command to block:
printf '%s' '{"tool_input":{"command":"pwd"}}' | bash check-bash.sh
echo "$?" # 0
printf '%s' '{"tool_input":{"command":"rm -rf /tmp/example"}}' | bash check-bash.sh
echo "$?" # 2These commands do not run rm: they send a JSON string to the script. To enable it, reference the script path in a PreToolUse hook with the Bash matcher in .claude/settings.json. Test it in an isolated project first.
Where to put them
Global hooks go in ~/.claude/settings.json (apply to all projects). Project hooks go in .claude/settings.json at the repo root (checked in, shared with the team).
For hooks that reference project-specific paths or tools, use the project-level file.
The compounding effect
None of these hooks is dramatic on its own. Together they remove the small frictions that break flow: manually noting the date, checking if Claude is done, catching destructive commands late, fixing lint in a second pass, re-explaining context.
That's where the time actually goes. Hooks are how you get it back.
The free Coding Agent Setup Kit provides shared AGENTS.md project instructions and reusable task prompts for Codex and Claude Code. It does not install hooks or change tool permissions.
Get the next post in your inbox
Practical tips for building with AI. One email per post.
Your email is used to send these updates. You can unsubscribe at any time. See our privacy policy.
Related posts
- 7 Claude Code Skills Worth BuildingSeven practical Claude Code Skills examples for code review, debugging, documentation, QA, releases, and safe repository work.
- Claude Code Skills vs Slash CommandsClaude Code Skills and slash commands are related but not identical. Learn how files, invocation, scope, and reusable workflows fit together.
- How to use Claude Code Skills in a projectA step-by-step guide to installing, invoking, debugging, and safely improving Claude Code Skills in a real repository.