In everyday life
It is like the ticket gate at a train station: it checks every ticket before the traveller gets through, whether or not they remember the rules. A camera that films people after they pass stops nobody.
One case
A school’s grade system has a rules file that says “run the type checkerA program that reads the code, without running it, and reports any value used as the wrong kind. before every commit”. In one week the agent makes 20 commits and runs the check before 17. The 3 unchecked commits each break the build, and each one costs a developer 30 minutes. The team adds a hook that runs the check before every commit and blocks the commit when the check fails, and the next week no broken commit gets in.
Every case
Text in a rules file is a request. The agent usually obeys it, and usually is not enough for a rule that must always hold. A blocking hook runs whether or not the agent remembers, stops the step when its check fails, and shows the agent the message, so write that message to name the fix. Git’s own commit hooks can be skipped with a flag, so also deny that flag in the agent’s permissions.
The word
Engineers call this
When a rule must hold every time, enforce it with a blocking script that runs before the step where it matters. Keep written rules for the judgment calls a script cannot check.