Hooks


Hooks

Hooks are another feedback mechanism we can use in Claude code.
​
They run arbitrary commands after certain lifecycle events.
​
There’s one hook I lean on heavily “Stop”.
​
It’s called when Claude has finished generating code. Which maps really nicely to my normal workflow where I would run commands like compile, lint, prettier, etc. to check the code is in a good state before continuing.
​
These commands are generally fast to run and when they fail the error is fed back to the LLM and continue to fix those errors until they pass.
​
I don’t run things like tests here though as they take too long to run and it would be a bit annoying adding on an extra minute or so between code generation sessions.
​
There’s a better hook for those “SessionEnd”
​
This works well because it’s when I’m shutting down the session so I don’t mind it taking a bit more time. Plus at this point in my workflow I’m already going to run them to make sure my pull request will past the CI checks.
​
If you want to set these up yourself run /hooks and select the lifecycle event you want to hook into, then follow the steps, some hooks require a matcher to further refine when it should run, others like "stop" don’t.
​
Have you got any good hooks I should consider?

113 Cherry St #92768, Seattle, WA 98104-2205
​Unsubscribe · Preferences​

Not a vibe coder

I'm sharing the exact methods I use as an AI engineer to build production systems - techniques so effective they work even in niche languages like Elixir. Get the complete playbook delivered to your inbox 👇

Read more from Not a vibe coder

Sub Agents I’ve been playing around with Claude Code sub-agents a lot recently and only just cracked how to get them working reliably. At first I thought they’d just work automatically. After all, the docs do say just prompt Claude with ALWAYS USE and it’ll magically select the right agent. But that never worked for me.Instead I found tagging the agent with @sub-agent-name forced Claude to select it. This feels a bit broken but I guess its messy tool selection and thats a tricky problem. I...

Background Agents My favourite thing about Github Agents is that they run in their own isolated containers and can scale infinitely. Until recently I’ve felt a bit stuck with Claude Code. On one hand its the best code generator. On the other, it doesn’t scale well beyond one instance and I have to wait for it to complete, which sometimes can be quite a while. Now I’ve figured out a way to work on multiple tickets at a time by running multiple instances of claude code. This is something they...