Phase 2: Static Analysis & Automated Gates · 50 min · Python · Claude Code Hooks · pre-commit
Hook-Based Real-Time Verification
Don't review the bad code. Stop it from being written.
Hiring signal: Engineers who can implement hook-based real-time verification (PostToolUse interception, pre-emptive blocking) demonstrate the ability to shift quality gates left -- from post-hoc review to pre-emptive blocking, which is the frontier of AI code quality engineering.
What you will learn
- Implement PostToolUse hooks that intercept AI tool calls before code is written
- Configure pre-commit hooks that block AI-generated code with linting violations
- Distinguish pre-emptive blocking from post-hoc review and explain the tradeoffs
- Build a real-time verification layer that runs inside the AI coding loop
The Problem
Traditional code review happens after the code is written: the AI generates code, the developer commits it, the PR is opened, the reviewer (human or AI) reviews it, and feedback comes back hours later. By then, the AI has already moved on to the next task. The feedback loop is too long.
Hook-based real-time verification shortens the loop to seconds. Instead of reviewing code after it's written, hooks intercept the AI's tool calls before the code reaches the file system. If the AI tries to write code with a security vulnerability, the hook blocks it in real-time. The AI sees the error and fixes it immediately -- no PR, no review delay, no context switch.
Post-Hoc Review vs Pre-Emptive Blocking
| Aspect | Post-Hoc Review | Pre-Emptive Blocking |
|---|
| When | After code is written and committed | Before code reaches the file system |
| Feedback delay | Hours (PR review cycle) | Seconds (hook execution) |
| AI context | Lost -- AI has moved to next task | Preserved -- AI is still working on this code |
| Fix mechanism | Human reviews, requests changes, AI regenerates | Hook blocks, AI sees error, AI regenerates immediately |
| Code that reaches review | All AI code (good and bad) | Only code that passes hooks |
| Developer burden | High -- review every PR | Low -- hooks filter automatically |
The shift from review to blocking
Post-hoc review asks: "Is this code good enough to merge?" Pre-emptive blocking asks: "Should this code be written at all?" The shift is from gatekeeping at the PR to gatekeeping at the tool call. This is more effective for AI code because the AI can self-correct in real-time -- it has the context of what it was trying to do, and the hook tells it exactly what's wrong. In post-hoc review, the AI has lost that context and the developer has to manually relay the review feedback.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers Claude Code Hooks: PostToolUse Interception, Pre-Commit Hooks: The Developer-Facing Layer, Build It — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy