# What Hooks Are — Advanced Agent Workflows and Skills

Source: https://www.geekswithgeeks.com/en/agent-workflows/hooks-basics

> Explain how hooks differ from prompt instructions and where they are configured.

## Instructions vs enforcement

A line in a prompt like "always run the formatter" is a request, and the model may forget it. A **hook** is a shell command that the harness itself runs on events such as before or after a tool call. In Claude Code hooks are configured in `settings.json`, and the command receives event details as JSON on standard input.

## Rules the model cannot forget

A hook is code that runs at a fixed moment in the agent's lifecycle, so the rule is enforced rather than requested.

![Three moments: before a tool, after a tool, at stop.](assets/figures/agent-workflows/section-5-map.svg) — Figure 5.1 — Before, after and at stop.

## Speed bump vs sign

A "slow down" sign asks drivers to be careful. A speed bump makes them. Hooks are the speed bump.

## Hooks run with your permissions

A hook is arbitrary code on your machine. Read any hook config you copy from someone else, and keep hook scripts in version control so changes are reviewed.

**Quiz:** How is a hook different from a prompt instruction?

- [ ] It is only a suggestion
- [x] It runs automatically as code at an event
- [ ] It needs the model to remember it
- [ ] It cannot run shell commands

*Answer:* It runs automatically as code at an event. The harness executes hooks itself, so they work even if the model forgets.
