The Case for Precommit Hooks
March 25, 2026For the last few days I've been messing with AI coding agents. AI coding agents are really great at doing the programming part, but not so great at the remembering part. Sort of like working with a coworker who has amnesia after they close a ticket. So, to remedy this somewhat, I've devised a somewhat new idea that I haven't seen anyone talk about online in regards to agents. The idea is that anything you want to be remembered to be done must be specified in a precommit hook.
Let me give you an example. I have been working on a game codebase, and so there is a clear distinction between the game's code and the UI's code. Therefore, I just asked the AI to make a precommit hook that adds a new test any time the game's code is changed. This has worked great and has increased test coverage of all of the game's features in general. Another problem you might be thinking is what happens if the tests aren't run? Well not an issue, I just added another precommit lint that runs the tests.
What the precommit does is ensure that all rules are satisfied before a commit is allowed to take place. This is great for coding agents (and people too) as it removes the burden of remembering all the boring procedural rules of a codebase. This is also very apt with coding agents because it allows the agent to have no knowledge of these rules unless they are explicitly broken, which is helpful for not needing to create any documentation, and wondering whether the documentation was consulted.