Hooks
A hook is your own shell command that the agent runs at a certain moment of its work: before a tool call, after it, when the user sends a message, when a turn ends. Hooks are written in the Claude Code hooks format, so the agent reads a Claude Code hooks file as is.
Ask the agent: "Add a hook: run prettier after every edit of a .ts file". It creates .explyt/hooks.json with the right entry.
Where the agent looks for hooks
| File | Whose |
|---|---|
~/.explyt/hooks.json | yours, for all projects |
<project>/.explyt/hooks.json | the project's |
~/.claude/settings.json, <project>/.claude/settings.json, <project>/.claude/settings.local.json | Claude Code; only the hooks key is read |
~/.codex/hooks.json, <project>/.codex/hooks.json | Codex |
hooks/hooks.json of every plugin enabled in the project | a Marketplace plugin |
<project> is the session's working directory; the agent doesn't search up the tree. Claude Code and Codex files are read only if you allowed importing that tool's settings (/import-agents or otherAgents in settings). A missing file is simply skipped.
File format
{
"hooks": {
"PreToolUse": [
{ "matcher": "Bash", "hooks": [ { "type": "command", "if": "Bash(rm *)", "command": "~/bin/no-rm.sh" } ] }
],
"PostToolUse": [
{ "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "npx prettier --write \"$(jq -r .tool_input.file_path)\"" } ] }
]
}
}
Event → list of groups with a matcher → list of hooks handlers. The agent runs only type: command handlers; http, mcp_tool, prompt and agent are skipped with a warning (make an HTTP request with curl in a command).
| Handler field | Meaning |
|---|---|
type | command; required |
command | required; runs through the shell of the bash tool in the project root |
args | if set, command runs directly with these arguments, without a shell |
if | a condition on the call arguments for tool events: Bash(git *), Edit(*.ts) |
timeout | seconds; 600 by default, 30 for UserPromptSubmit and Stop |
statusMessage | the text the terminal shows while the handler runs |
async | start without waiting; the handler's decisions have no effect |
The command receives the event data as a JSON object on stdin and CLAUDE_PROJECT_DIR in the environment; ${CLAUDE_PROJECT_DIR} is substituted in command and args. Exit code 0 with a JSON object on stdout applies its fields; code 2 blocks the action with stderr as the reason (on events that can be blocked); any other code, a timeout or invalid JSON is a hook error: the agent shows a notice, and the action goes ahead.
An empty matcher or * matches everything; letters, digits, _, -, spaces, , and | make a list of exact names; anything else is a regular expression.
Events
| Event | When | What it can do |
|---|---|---|
SessionStart | a session started, resumed, forked or was cleared, and after a summary | add context |
SessionEnd | the session ended | observe |
UserPromptSubmit | the user's message reached the agent | add context, block the message |
PreToolUse | before a tool call | allow, deny, ask, add context |
PermissionRequest | before a confirmation question | allow, deny |
PostToolUse, PostToolUseFailure | after a tool call | add context, replace the output (PostToolUse) |
PostToolBatch | after the tool calls of one model turn | add context |
Stop | the turn ended normally | continue the turn with a reason |
StopFailure | the turn ended with an error | observe |
SubagentStart, SubagentStop | a subagent started or finished | add context for the subagent (at start) |
PreCompact | before a context summary or a clearing of old tool outputs | block it |
PostCompact | after a successful summary or clearing | observe |
For PreCompact and PostCompact the matcher is manual for /compact and auto for automatic compaction. Notification, PreModelSwitch, PostModelSwitch and other Claude Code events that have no matching moment here are skipped with a warning that suggests what to use instead. Inside a subagent only PreToolUse, PermissionRequest, PostToolUse, PostToolUseFailure, PostToolBatch, PreCompact and PostCompact fire.
Tool names
tool_name is the name as in Claude Code: Bash, Read, Write, Edit (also matches MultiEdit), Grep, Glob, LS, Agent (and Task), WebFetch, WebSearch, TodoWrite, AskUserQuestion, Skill; an MCP server tool is mcp__<server>__<tool>. A matcher also matches the agent's own tool name (bash, edit, …). There is no notebook tool: NotebookEdit matches nothing.
Approving project hooks
Hooks from a project file (.explyt/hooks.json, .claude/settings*.json, .codex/hooks.json) run only after you approve them.
A new file waits in the same startup question that approves project MCP servers (MCP servers). A checked row allows the file, an unchecked one denies it, and a dismissed question leaves it waiting. The answer is stored along with the answers about servers and survives edits to the file; you can change it with the a key on the file's row in /hooks.
The hooks.projectFiles setting changes the rule for files without an answer:
ask(default) asks the question;allowruns them without a question;denynever runs them and never asks.
When nobody can answer (a run without a UI, a subagent, an IDE without forms, the bypassPermissions and afk modes), a file without an answer doesn't run under ask.
Your global hooks (~/.explyt/hooks.json) don't need approval.
Plugin hooks
The hooks/hooks.json of a Marketplace plugin runs in every project where the plugin is enabled, without a question: enabling a plugin is consent to all of its parts, as with its MCP servers. So before installing, look at hooks/hooks.json in the plugin's repository; the source link is on its catalog page. You can turn off a plugin's file only with your own setting, its plugin:<id>/hooks.json ID in the global hooks.disabledFiles; disabling the plugin removes its hooks. A plugin hook command gets ${PLUGIN_ROOT} (the installation directory) and ${PLUGIN_DATA} (the plugin's data directory) substituted, and besides them CLAUDE_PLUGIN_OPTION_<KEY> in the environment for each plugin variable, secrets included. An invalid plugin hooks file shows up in /hooks as a problem of the plugin. How the hooks file is described in the plugin format is covered in the format reference.
What a hook can do without asking you
An approved project hook (or any project hook under allow) can skip confirmation: an allow answer to PreToolUse or PermissionRequest runs the call without a question in the default and paranoid modes. Calls that the confirmation table marks as "always ask", such as sudo, still ask; deny blocks in any mode. Hook files are protected paths: writing to .explyt/hooks.json, .codex/hooks.json and .explyt/plugins.json (enabling a plugin there runs its hooks) asks for confirmation in the default and paranoid modes.
Settings
| Key | Level | Default | Meaning |
|---|---|---|---|
hooks.enabled | global only | true | false turns off all hooks |
hooks.disabledFiles | both | [] | IDs of files that don't run; a project entry turns off only project files, global and plugin files only the global one |
hooks.projectFiles | global only | ask | what a project file without an answer does: ask, allow, deny |
/hooks shows the file IDs (global:.explyt/hooks.json, project:.claude/settings.json, plugin:<id>/hooks.json, …). disableAllHooks from Claude Code and Codex files is not read; turn off the file through hooks.disabledFiles instead. Settings levels are described in Settings.
The /hooks command
/hooks in the terminal shows each file, its hooks, state and approval; the command doesn't exist in an IDE session.
When changes take effect
Hook files and the hooks.* keys are read once at session start: an edit applies after /reload or in a new terminal session, and in the IDE in a new chat. Switches and approvals in /hooks apply at once.
Differences from Claude Code
- The default
Stoptimeout is 30 s, not 600. updatedInput,continue: false,stopReason,onFailureanddeferare not read;asyncRewakeworks as plainasync;onceis not read.PreModelSwitchandPostModelSwitchare not supported.- Context added by a hook is cut at 10,000 characters with a marker.
permission_modein the input can beparanoidorafk;StopFailurealways passeserror: "unknown".
A Codex hook turned off in its config.toml runs here; turn off the file through hooks.disabledFiles. A matcher on apply_patch catches nothing; match Write and Edit instead.