Hooks: automatic actions
Hooks are commands the app runs by itself on certain events. Mine keep my memory in sync, guard the servers and the secrets, check Python and block a bad push.
What a hook is
A hook is a shell command configured in the settings that the app runs on its own when something happens: a session starts, a tool is about to run, a task ends. The difference from a note in memory is important: a memory is something Claude should remember, a hook is something that will happen, whether it remembers or not.
The ones I have
- At the start of every session, a script runs in the background and makes sure the memory folder of each project is linked to the cloud drive where my notes live. It is idempotent and writes a log: that is how the same memory follows me between computers.
- A guard for network and servers, before every shell command: it blocks outright the moves that would cut everyone’s internet or mail (flushing the firewall rules, installing another one) and asks for confirmation on the delicate ones.
- A guard for secrets: before reading or editing a file that holds some (configs with passwords, tokens) it asks permission, so they do not end up in the conversation; it refuses to put them in a commit or to open their permissions, and after an edit it flags values that Docker Compose would mangle.
- A syntax check after every edit to a Python file: if it does not compile, the error goes straight back to Claude instead of showing up at deploy time.
- In this site, before any push, a hook runs the build and blocks if it fails, and the push still asks for my confirmation: publishing here means going live.
The global configuration, the skills and these scripts now live in a private repository, so they restore on a new Mac with a clone.
What I would add
My usage report spotted commits whose message did not follow my format: a hook that checks it before the commit would be a small script. Another candidate is a reminder to update the memory at the end of a long session. Neither is in place yet.
A word of caution
A hook runs with my permissions and without asking, so it should be short, readable and boring. The best ones I can think of do one thing and say so in a log.