· Mark Lester Mahilum · Case Studies · 2 min read
Automating Code Review with Claude Code Hooks
How I wired Claude Code's PostToolUse hooks to automatically review every file I edit, catching bugs before I even run the code.
Every time I edited a file, I’d forget to review it properly. So I stopped doing it manually.
The problem
Code review is the right habit. Running it consistently is the hard part. I’d edit 10 files in a session and review 3.
The solution
Claude Code’s hook system lets you run arbitrary commands after tool use events. I wired a review step into PostToolUse:Edit.
Setup
In .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "echo 'File edited, review queued'"
}
]
}
]
}
}Then in CLAUDE.md, I added instructions that trigger after each edit:
After editing any file, briefly check for: obvious bugs, missing error handling,
security issues. One sentence per concern. Skip if none.Result
Every file edit now gets a lightweight automatic review pass. Claude flags issues inline as it works, not after the fact.
The point is timing: issues get flagged while the file is still open, instead of in a review pass I might skip.
Next step
Hooks can also backfire: a hook that rewrites commands fails every command when its binary is missing. For a sturdier pattern, see session goals with Stop hooks. Want review gates wired into your team’s Claude Code setup? That is part of the Claude Code workflows I build. Book a call.