The hooks that stopped my agent from shipping garbage
retained text
Most of my agent problems weren't the model, they were the agent saying "done" on stuff that wasn't. Hooks fixed more of that than any prompt did. This is what runs on my repo now, about 6 months in. Before every edit: block writes to migrations and .env. It can propose them, it can't touch them. This one alone saved me twice. After every edit: typecheck and lint on the changed files only. If it fails the agent sees the error right away instead of finding out 40 files later. Before it says done: run the tests for the files it touched. No green, no "done". It still writes weak tests but at least it can't skip them. Pre-commit: a check that fails if a commit touches more than 15 files. Big changes have to be split. Annoying at first, best rule I have. Pre-push: coderabbit's CLI reviews the diff before it leaves my machine, and the agent fixes what it flags first. Adds about 90 seconds to every push, which I hated for a week, but it catches the cross file stuff the agent misses. On stop: write a 3 line summary of what changed and why to a notes file, so tomorrow's session doesn't start from zero. What I dropped: a hook that asked a second model to approve every edit (slow and it agreed with everything), and auto formatting on every save (it made diffs unreadable). What hooks are you running? Curious if anyone found a good one for catching the agent quietly changing behavior nobody asked for.
document fetched 2026-10-24 10:22 · canonical https://reddit.com/r/AI_Agents/comments/1xdgi7q/the_hooks_that_stopped_my_agent_from_shipping