📚Academy
likeone
online

Hooks & Lifecycle

Intercept, inspect, and modify your agent's behavior at every decision point

What Are Hooks?

Hooks are callback functions that fire at specific points in the agent's lifecycle. They let you observe, modify, or block agent behavior without changing the agent's core logic. Think of them as checkpoints where you can inspect what the agent is doing and decide whether to let it continue.

Real-world analogy: Hooks are like security checkpoints at an airport. You pass through multiple checks — ID verification, baggage scan, boarding pass check. At each checkpoint, your journey can be approved, flagged for inspection, or stopped entirely. The traveler (agent) does not control the checkpoints. You do.

The Hook Types

The SDK provides hooks at four critical lifecycle points:

PreToolUse

Fires before a tool is executed. Inspect or modify the tool call parameters. Return deny to block the call entirely. Use this for input validation and permission enforcement.

PostToolUse

Fires after a tool returns its result. Inspect or modify the result before Claude sees it. Use this for output sanitization, logging, and audit trails.

PermissionRequest

Fires when the agent wants to do something that requires explicit permission. Return allow or deny. Use this for human-in-the-loop approval workflows.

Stop

Fires when the agent is about to finish. You can inspect the final result or force the agent to continue working. Use this for quality validation.

🔒

This lesson is for Pro members

Unlock all 355+ lessons across 36 courses with Academy Pro. Founding members get 90% off — forever.

Already a member? Sign in to access your lessons.

Academy
Built with soul — likeone.ai