Skip to content
Menu

Help article

Hooks

Hooks run your own commands at moments of an agent turn, for example before a shell command or after a file edit, and can allow, deny or add context. They run on your computer through Runner.

  1. Put hooks in ~/.itwins/hooks.json (all folders on that computer) or <folder>/.itwins/hooks.json (one folder). Settings > Hooks lists the hooks iTwins found and their source file.
  2. Events: sessionStart, sessionEnd, beforeSubmitPrompt, beforeShellExecution, afterShellExecution, beforeMCPExecution, afterMCPExecution, beforeReadFile, afterFileEdit, afterAgentResponse, afterAgentThought, subagentStart, subagentStop, preCompact and stop.
  3. Each hook gets the event as JSON on stdin and may print JSON with permission ("allow", "deny" or "ask"), additionalContext, userMessage or agentMessage. A timeout and failClosed can be set per hook.
  4. Tab completion and workspace-open events from the desktop editor have no moment on the web; Settings > Hooks marks such hooks as not run.
Questions? Email support@itwins.com

All help and contact options