When you put an autonomous AI coding agent—whether it's Claude Code, Cursor, or a custom harness—to work on your codebase, development speed explodes. But so does silent code slop. LLMs are probabilistic completion engines. As context windows fill up or tasks grow complex, developers frequently observe recurring shortcuts: leaving behind # TODO stubs, inserting temporary breakpoint() calls, stripping hand-written architectural comments, and leaking hardcoded API keys while testing integrations. If you try to catch all of that by reading every line of diff during manual code reviews, you end up acting like an unpaid laborer cleaning up after the crew. In construction, a good job-site foreman doesn't inspect every single screw by hand at the end of the day—they set up strict inspection gates and physical stop-blocks before the work starts. In software, you do that with version-controlled Git hooks and automated linters like Ruff. ## What is a Hook? (The Stop-Block Principle) If you're cutting twenty trim boards to exactly 12 inches, you don't measure each board by hand and hope your eye is sharp—you clamp a physical stop-block to your miter saw fence. The lumber hits the block, and the cut is right every single time. ## A Git hook is a digital stop-block. It is a script that runs synchronously in the foreground when a developer or AI agent triggers a Git action. Right before a commit is finalized (git commit), Git halts execution and runs your hook. It inspects the staged files, runs your quality checks, and decides whether to let the work pass or block it on the spot. ## Workflow Diagram ``` [ AI Agent Types 'git commit' ] │ ▼ ┌─────────────────┐ │ Synchronous Git │──(Blocks execution & runs fast checks) │ Pre-Commit Hook │ └─────────────────┘ │ │ (Pass) (Fail) │ │ ▼ ▼ [ Committed ] [ BLOCKED ] ──► Feed stack trace back to Agent ``` Because the hook blocks execution, any failure aborts the commit and dumps the exact error message right back into the AI agent’s context window. The agent reads why it got blocked, fixes its own code, re-stages the file, and retries the commit—all before you ever look at the pull request.