I really wish there was a "pre prompt" hook natively. As in, before the agent releases control back to me to prompt it again, it runs the hook.
I have a pre-push hook that runs all lint/prettier/typechecks/tests etc. These are all clearly signposted in the project, the AGENTS and CLAUDE files are set to run them.
Still though, I'll get it saying "All done" and then it'll fail something basic like formatting when I go to push. Or I've come back to a 'ralph wiggum' loop before and found it saying "tests are broken, but that's not part of this commit, so ignoring"
Ask it in your prompt to run pre-commit and the tests when checking things are good.
You can also add a plan exit hook to Claude Code - mine has like 150 bullet points about what I want to see in plans. The first run blocks (exit 2 with a message about what’s expected in a plan); the second run always goes through. So the agent is given plan feedback exactly once and told to go back and make it better. Anything I have to say to it in response to a plan it generates, I think hard about (or ask the agent about) and add that as a new bullet point - and then the plan exit hook is 151 bullet points and I never have to tell the agent that thing again. Working great so far!