Hooks let you block or reshape AI agentAn AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.Full definition → 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 folder or a project's .clinerules/hooks directory, that receive operation context windowThe maximum amount of text a model can consider at once — its working memory for the current conversation or task.Full definition → as JSON on stdin.
A hook returns JSON whose cancel field 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 window — The maximum amount of text a model can consider at once — its working memory for the current conversation or task.
AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
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.