Agent hooks support various trigger types, each designed for specific automation scenarios. Understanding these types helps you choose the right approach for your workflow needs.
File hooks trigger when files matching specific glob patterns are created, saved, or deleted in your workspace. These hooks require a patterns array to specify which files to watch.
Triggers when files matching specific patterns are saved.
Use cases:
Triggers when new files matching specific patterns are created in your workspace.
Use cases:
Triggers when files matching specific patterns are deleted.
Use cases:
{ "name": "Hook Name", "description": "What this hook does", "version": "1", "enabled": true, "when": { "type": "fileEdited", // or fileCreated | fileDeleted "patterns": ["**/*.ts", "**/*.tsx"] }, "then": { "type": "askAgent", "prompt": "Your prompt here" } }
Contextual hooks trigger based on agent interactions. They don't use file patterns.
Triggers when the user submits a prompt.
When using the shell command action, the user prompt can be accessed via the USER_PROMPT environment variable.
Use cases:
Triggers when the agent has completed its turn and finished responding to the user.
Use cases:
{ "name": "Hook Name", "description": "What this hook does", "version": "1", "enabled": true, "when": { "type": "promptSubmit" // or agentStop }, "then": { "type": "askAgent", // or runCommand "prompt": "Your prompt here" // or "command": "npm run build" } }
Manual hooks are triggered on-demand by the user. When a manual hook has a description and uses the askAgent action, it becomes available as a slash command in the chat panel using the hook's filename.
Manually execute a hook from the Agent Hooks panel or via slash command.
Use cases:
{ "name": "Hook Name", "description": "Required for slash command", "version": "1", "enabled": true, "when": { "type": "userTriggered" }, "then": { "type": "askAgent", "prompt": "Your prompt here" } }
| Field | File Hooks | Contextual Hooks | Manual Hooks |
|---|---|---|---|
name | Required | Required | Required |
description | Optional | Optional | Required for slash commands |
version | Required | Required | Required |
enabled | Optional (default: true) | Optional (default: true) | Optional (default: true) |
when.type | fileEdited, fileCreated, fileDeleted | promptSubmit, agentStop | userTriggered |
when.patterns | Required | N/A | N/A |
then.type | askAgent | askAgent, runCommand | askAgent |
promptSubmit and agentStop triggers
Hook types