Hooks let you block or reshape agent actions with your own scripts, for example refusing .js files in a TypeScript project. Context injected by a hook affects the next API request, not the current one.
Key takeaways · AI-distilled
Cline v3.36 hooks are executable scripts named after the agent hookA script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.Full definition → type, placed in a global FolderA named container that holds files and other folders; also called a directory.Full definition → or a project's .clinerules/hooks directory, that receive operation Context and context windowContext is the information available for a generation; the context window is the capacity available to hold it.Full definition → as JSON on stdin.
A hook returns JSON whose cancel FieldOne named piece of a record, such as name or approved_on; a record is one entity's set of values, one per field.Full definition → blocks or allows the operation and whose contextModification text is injected into the conversation, shaping the next API request rather than the current one.
The six hook types are PreToolUse, PostToolUse, UserPromptSubmit, TaskStart, TaskResume and TaskCancel; PreToolUse runs after the model has already chosen its action, so it validates that step rather than steering it.
At release, hooks ran only on macOS and Linux, not Windows, and had to be enabled under Features in Cline settings.
Terms in this piece · Glossary
Context and context window — Context is the information available for a generation; the context window is the capacity available to hold it.
agent hook — A script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.
Folder — A named container that holds files and other folders; also called a directory.
Field — One named piece of a record, such as name or approved_on; a record is one entity's set of values, one per field.