Claude Code hooks explained, with an audit example
By the AgentReceipt team · Updated 13 November 2026
Claude Code can run a command of your choosing when events happen in a session. That makes hooks the natural place to build an audit record.
What a hook is
A hook is a command registered for an event, such as a prompt being submitted, a tool being used or a session ending. Claude Code reads the registration from its settings file and runs the command, passing details of the event.
Why hooks suit auditing
A hook sees things as they happen, so the record does not depend on reconstructing a session afterwards. It does not change what the agent does; it only writes down what happened.
How AgentReceipt uses them
Running agentreceipt init merges its hooks into .claude/settings.json without removing yours. The hooks call agentreceipt record, and agentreceipt finalize builds the receipt when the session ends.
npm install -g @agent-receipt/cli cd your-repo agentreceipt init