Skip to content

Hooks ​

A hook is a shell command that runs automatically at a moment in the run lifecycle. Where a rule asks the agent to behave, a hook is deterministic policy: written in bash, enforced in code, same event in → same verdict out. The model cannot talk its way around it.

The command always runs inside the container, never on the host. No active container means hooks do not run.

Hooks live under Settings → Harness, with the rest of the Studio harness (skills, rules, agents).

Some hooks are made available out of the box to all.

Writing one ProTeamEnterprise ​

The paid plans include additional hooks and allow you to write your own.

Settings → Harness → Hooks. Studio opens the hooks editor

ControlWhat it does
Enable hooksMaster switch. Off means no hooks run at all
ScopeWhere the config is stored: Global (host) file, or the current project under /workspace. Commands still run in the container either way
EventWhen the hook fires (expand an event to edit its matcher groups)
MatcherWhich tool or trigger this group applies to (some events run every time and have no matcher)
CommandShell command in the container. stdin is the event JSON; exit 2 blocks; stdout can add context
Timeout (s)Per-command timeout (default 30)
OnEnable or disable that command without deleting it

Add a matcher (or a hook, when the event has no matcher) from the event panel, then add commands under it. Marketplace presets install into the active scope.

Events ​

EventFiresCan
UserPromptSubmitWhen you send a messageBlock the prompt, or add context
SessionStartNew, resumed, or cleared sessionAdd context
PreToolUseBefore a tool runs, before the approval cardBlock, rewrite input, or halt
PostToolUseAfter a tool ranAdd context, or halt
PreCompactBefore history is summarisedObserve / react
StopWhen a run ends on its ownNotify, clean up

Hook vs rule ​

RuleHook
EnforcementThe model decides to follow itDeterministic: code decides
Can block a toolNoYes
Costs contextYes, every turn when always-onNo
Where it runsIn the promptShell inside the container
Hard scope belongs in a hook

Write the scope as a rule so the agent knows it, and as a PreToolUse hook so it cannot ignore it.

Import ProTeamEnterprise ​

Importing hooks is a read-only process on the sources. Staging imported items disabled until you review them is the safe default; you can also import them enabled. Settings → Harness → import.

Last updated: