---
published: true
id: hooks
title: Hooks
description: Knowledge captured in João Lopes' learning graph.
tags:
- ai-engineering
- claude-code
- cyberdeck
locale: en
resource: https://joaolopes.dev.br/knowledge/concepts/en/hooks/
created: '2026-03-19'
---

# Hooks
User-defined shell commands that execute at specific lifecycle points in Claude Code, providing deterministic enforcement outside the model's context.

## Definition
Hooks are lifecycle events that fire before and after tool calls in Claude Code. Unlike instructions, hooks run as code — they enforce behavior unconditionally, outside the model's context. Hooks are wired in settings files and point at scripts that run synchronously (PreToolUse can block a tool call) or asynchronously. They fire at the process level on every tool invocation regardless of what agent or subagent triggered it, making them a reliable enforcement mechanism where behavioral modeling is not.

## Source
- [Hooks reference - Claude Code Docs](https://docs.anthropic.com/en/docs/claude-code/hooks)
- [Automate workflows with hooks - Claude Code Docs](https://docs.anthropic.com/en/docs/claude-code/hooks-guide)

## Related
- behavioral-modeling
- [CLAUDE.md](/concepts/en/claude-md.md)
- [AI Agent](/concepts/en/ai-agent.md)
