Omniscio

OmniscioToolsClaude Code hooks builder

Claude Code hooks builder

Build the hooks block for your settings.json: choose the lifecycle event, the matcher that filters it, and what should run. The page writes the JSON, names the event and field mistakes Claude Code would reject, and hands you a block to paste into your settings file. It is free, it runs in your browser, and nothing you type is sent anywhere.

Checked against Anthropic's Claude Code documentation. By the Omniscio team. Updated .

Build your hooks block

When it runs

What runs

Your hooks block

    Paste this into the hooks key of your settings file. If the file has no hooks key yet, add it beside permissions; do not replace the rest of the file.

    How a hooks block is read

    The configuration nests three deep: an event name is the key, its value is an array of matcher groups, and each group holds a hooks array of handlers. hooks is a top-level key in the settings file, so it sits beside permissions rather than inside it, and a second event is a sibling of the first.

    The matcher is read in one of three ways. *, an empty string or no matcher at all fires on every occurrence; letters, digits, underscores, hyphens, spaces, commas and a vertical bar are an exact name or a list of exact names; anything else is an unanchored JavaScript regular expression, so Edit.* matches both Edit and NotebookEdit. FileChanged and StopFailure use a narrower set — letters, digits, underscores and the bar only — so a comma in a matcher for either one turns it into a regular expression. An event that takes no matcher ignores one you add.

    The five handler types

    TypeWhat it doesRequired field
    commandRuns a shell command and passes the event JSON on stdincommand
    httpPOSTs the event JSON to a URLurl
    mcp_toolCalls a tool on one of your configured MCP serversserver and tool
    promptSends a prompt to a Claude model for a single-turn judgementprompt
    agentSpawns a subagent that can read and search before decidingprompt

    Exit codes decide what happens

    Exit 0 is success: the action goes ahead unless the hook's own JSON output blocks or denies it. Exit 2 is the blocking error, and on an event that can block Claude Code stops the action and hands the hook's stderr back as the reason. Any other exit code is a non-blocking error, so a policy written against the conventional Unix failure code of 1 fails open — except on the two worktree events, where any non-zero exit fails the action, and except when the hook printed a valid JSON decision, whose fields then decide.

    Not every event can block. The ones that can are PreToolUse, UserPromptSubmit, UserPromptExpansion, Stop, SubagentStop, TaskCreated, TaskCompleted, TeammateIdle, PostToolBatch, ConfigChange (except a change to managed policy settings), PreCompact, PreModelSwitch, Elicitation, ElicitationResult and the two worktree events. PostToolUse cannot, because the tool has already run, and a PreToolUse hook that times out does not block the call unless you set onFailure to block.

    The optional fields this page writes

    • timeout is in seconds and defaults to 600 for command, http and mcp_tool handlers, 30 for prompt and 60 for agent. Claude Code lowers the command default to 30 on UserPromptSubmit, PreModelSwitch and PostModelSwitch, and to 10 on MessageDisplay.
    • if narrows a handler with permission-rule syntax, and is evaluated only on the five tool events.
    • statusMessage replaces the spinner text while the hook runs.
    • args switches a command handler to exec form: the command is spawned directly with no shell, so it has to resolve to a real executable. On Windows that rules out the .cmd and .bat shims npm and npx install; run those in shell form instead.

    Before you commit it

    A command hook runs with your full user permissions, so it can read, change or delete anything your account can. Anthropic's own advice is to review and test every hook command before it goes into a configuration file, quote your shell variables, use absolute paths, and keep hook scripts out of the way of sensitive files.

    Precedence is worth knowing too. Hooks merge across settings levels rather than replacing each other, and a hook's decision does not override your permission rules: a deny rule still blocks the call, and an ask rule still prompts even when a PreToolUse hook returned allow. The hooks guide covers the events in depth, and the settings.json guide covers which file a hook belongs in.

    Where Omniscio fits

    Omniscio is the desktop app we make for running many Claude Code sessions at once. Hooks are a per-session feature of Claude Code, and in Omniscio each session is a real one, so a hook you add here fires the same way it would in a terminal.

    • Sessions are grouped by project, so a hook committed to one repository's settings file reaches exactly that repository's sessions.
    • Every session keeps its own transcript, which is where a hook's output and a blocking message actually show up.

    It runs on Windows, macOS and Linux. The features page lists everything in it today, and the permissions builder covers the other half of a settings file.

    Common questions

    Where do Claude Code hooks go?

    Under a top-level hooks key in a settings file: ~/.claude/settings.json for every project, .claude/settings.json for one project shared with anyone who clones it, or .claude/settings.local.json for yourself. Event names are keys inside that one object, so a second event sits beside the first rather than replacing it.

    What are the three levels of nesting?

    The event name, then a matcher group that filters when it fires, then one or more hook handlers. When an event fires its matching handlers run in parallel, with at most twelve prompt or agent handlers at once; the rest wait, and each one's timeout starts when it starts. A handler defined identically in two settings files runs once.

    What does exit code 2 do?

    It is the blocking error. On an event that can block, Claude Code stops the action and passes the hook's stderr to Claude. Exit 0 is success and any other code is a non-blocking error, so a policy hook should exit 2 rather than 1. The two worktree events are the exception: there any non-zero exit fails the action, and a valid JSON decision still decides.

    Why does my hook never run?

    The commonest cause is an if filter on an event that does not carry tool information. The field is evaluated only on PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest and PermissionDenied, and on any other event a handler with if set never runs.

    Are hooks safe to add?

    A command hook runs with your full user permissions and can read, change or delete anything your account can. Read and test each command before you commit it, and remember that a project's hooks wait for the workspace trust dialog while a -p run treats the folder as trusted.

    See every hook fire, session by session

    Install Omniscio, start your agents, and each session's transcript shows the hooks that ran and the ones that blocked. The guide to running multiple sessions covers the rest of the setup.