AI ClubhouseVibe Coding Guide
Advanced concepts · Chapter 6 of 6

Hooks

Actions that fire automatically at the right moment.

Everything so far still needs someone to ask. A hook doesn't. It's an action wired to a moment: when X happens, do Y, automatically, every time. The motion-sensor light of the agent world, where nobody flips a switch, you just walk up and it turns on.

Hooks matter because prompts and rules are requests, and requests can be forgotten, by you or occasionally by the agent. A hook is a guarantee. “Format every file after editing” as a rule is a polite suggestion; as a hook, it is physics.

Each hook attaches to one named moment from a fixed menu the tool publishes. You can't invent new moments, only decide what happens at the existing ones. Claude Code's menu, grouped (skim, don't memorize):

Opening and closing a session
SessionStart, SessionEnd
When you send a message
UserPromptSubmit
Around any tool the agent uses
PreToolUse, PostToolUse
When the agent finishes responding
Stop
Helper agents
SubagentStop
When the agent needs your attention
Notification
Behind the scenes
PreCompact

(Cursor publishes its own menu with its own names, so check the tool you're using. Both lists keep growing.)

The distinction that unlocks everything: “pre” hooks can intervene, where the tool pauses and your hook can approve, warn, or block. “Post” hooks can only observe, since the thing already happened; they watch and record. Safety lives in pres; bookkeeping lives in posts.

Tidy up after edits
Auto-format every file the moment it changes. (A post.)
Safety check
Inspect terminal commands before they run; block the scary ones. (A pre.)
Keep a record
Quietly log every change to a file you can review later. (A post.)

Most people meet hooks inside a plugin: installed by someone else, working silently. But the day you think “I wish this happened automatically every time,” you know what to ask for. Tell your agent to set up a hook for it.

AI Clubhouse · Vibe Coding Guide