skarn guardhook events
What the real-time guard gates on each AI coding host: the content every hook event scans, how a block is emitted, and which events the shipped configs wire by default.
skarn 0.39.0
How the guard decides
The host pipes a pending action to skarn guard on stdin - a tool call, a submitted prompt, a spawning subagent, a resolved batch of tool outputs - and the guard scans that single action with the full detection engine before it proceeds. It returns one of three verdicts: deny (block the action), ask (escalate to the user's permission prompt), or allow (silent - nothing is emitted at all). Skarn only ever speaks up to tighten, never to auto-approve.
Where a host offers no ask channel, a would-be ask degrades to a block rather than to an allow. Every reason names the matched rule and a redacted preview - never the raw secret. In audit mode (the default, and the only mode an unlicensed guard runs) the guard never decides: it reports the would-be verdict on a non-deciding channel and writes it to the guard log, so you can measure your real would-block rate before enforcing.
This page is generated from the same model that generates the binary's own manual page, and a build gate asserts it against the guard's source and the shipped hook configs - so it describes what the shipped binary does, not what it once did. The equivalent offline reference is man skarn-guard.
Claude Code
Claude Code fires PascalCase events with a JSON envelope on stdin. Six events are wired by default, the batch output scan among them; the per-result output scan is supported but opt-in because it fires on every tool result.
Routing. Codex shares Claude's PreToolUse and PermissionRequest names, so auto-detection keys on a Codex-only tell (turn_id, or the apply_patch/spawn_agent tools); a Claude event carries none of them and routes to the Claude adapter. VS Code Copilot also shares the envelope, so its own tool-name vocabulary routes it to the Copilot adapter. The shipped Claude PermissionRequest hooks pass --agent claude explicitly anyway.
Fail mode. Claude Code fails OPEN on a guard failure: an exit code other than 0 or 2, a hook that cannot start, invalid JSON on stdout and a timeout all let the action go ahead unless the hook entry sets onFailure to block (Claude Code 2.1.295 or later), which the shipped configs leave unset; the one exception is Windows without Git Bash, where a shell-form PreToolUse or PermissionRequest command hook that fails or times out with onFailure unset blocks the call. Elsewhere exit 2 and a blocking JSON decision are the only blocks, and exit 2 is not honored on PermissionRequest, where only the decision object denies. In enforce, an event the guard cannot fully classify (unparseable, oversized, a repeated key, a tool input nested past the flatten bound, or a Read of a dotenv file whose requested lines lie past the 4 MiB the guard reads) asks, and denies under --strict, with the same verdict the guard log records; when the event is too large to parse, the answer takes the shape of the event named in the bytes the guard did read; with no event name and no --event pin it takes the PreToolUse shape, which another event may ignore. On PreToolUse, when the event's top-level permission_mode is bypassPermissions or dontAsk, every ask the guard would write is a deny instead, because Claude Code 2.1.322 was measured to run the tool with no prompt after a hook's ask in both modes. That covers a rule-driven ask, whose reason keeps the rule id and redacted preview and adds that the permission mode runs an ask without a prompt, the regex work-limit floor, and every unclassifiable ask, a rules-load or analysis failure included. For an oversized or malformed event the guard looks for the mode at the top level of the bytes it received, where any occurrence that names bypassPermissions or dontAsk counts, and it takes the event name from those bytes only when every top-level occurrence is readable and agrees; when no such mode is found (it sits past the 4 MiB read cutoff, or the bytes hold no top-level permission_mode the guard can read), the ask stands and --strict turns it into a deny. An absent mode or any other mode (default, acceptEdits, plan, auto) changes nothing, PostToolBatch still reports an ask through additionalContext, and PermissionRequest still denies every ask it receives. The host documentation says PermissionRequest fires only when a call needs a permission decision, which those two modes skip, so the PreToolUse answer is the gate there. Audit reports the would-be deny wherever it already reports a verdict, and blocks nothing. Because audit decides nothing, Claude Code's own permission handling is unchanged: when its rules ask for a call the guard flagged, its permission dialog can offer to save the command, secret included, as a permission rule, and on Claude Code 2.1.325 that dialog did not show the guard's audit systemMessage. A scan-infrastructure failure (unreadable rules) still asks in enforce with or without --strict, denies in bypassPermissions and dontAsk, and writes no guard log line. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
tool_name plus the flattened tool_input; a Bash command is also carried raw so a tool description cannot poison the package parse; for a Read call the guard opens the file the call names (a regular text file, up to 4 MiB) and judges that content for secrets and credentials only, with the secret rules, the payloads decoded out of it and the credential-store detectors (dotenv-file-read, credential-file-read and the other Read-keyed stores), so a credential in the file is found before the read runs while prompt-poisoning and every other heuristic never read a file before the call; a Read of a dotenv file larger than 4 MiB whose requested lines are not all inside the bytes the guard read gets the cannot-classify verdict, and an offset or limit that is not a positive integer makes the guard scan the whole file without counting the read as a whole read of a credential store; a Bash command opens no file to judge what it reads: a cat, head or tail in it, a redirection or a script is judged on the command text alone. A Write, Edit or Bash call whose target is a declared hook file of a supported assistant is the one other case that opens a file: the guard reads that hook file (a regular file, or a hook directory of regular files; at most eight hook files or hook directories per call, each file of a hook directory counted among the call's 256 path lookups, and 4 MiB of hook content per call in total) to judge whether the call removes, downgrades, silences or edits the skarn hook | hookSpecificOutput.permissionDecision = deny or ask, with the redacted reason in permissionDecisionReason | hookSpecificOutput.additionalContext | yes |
PermissionRequest |
the same tool_name plus tool_input as PreToolUse, at the permission-decision step | hookSpecificOutput.decision.behavior = deny, with the redacted reason in decision.message, which the host documentation says tells Claude why the call was denied, and on the universal systemMessage | systemMessage | yes |
UserPromptSubmit |
prompt | top-level decision = block, with the redacted reason in reason | hookSpecificOutput.additionalContext | yes |
UserPromptExpansion |
command_name and expanded_prompt | top-level decision = block, with the redacted reason in reason | hookSpecificOutput.additionalContext | yes |
TaskCreated |
task_subject (or the task_title older releases sent) and task_description | top-level decision = block, with the redacted reason in reason (Claude Code deletes the task and returns the reason to Claude as the tool error; it ignores continue = false on this event) | systemMessage | yes |
PostToolUse |
tool_input as the input and tool_output (falling back to tool_response) as the tool result of an in-scope tool, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them, with the result also feeding the tool-output detectors; a string output is scanned as sent and an object or array as flattened key: value lines; the input is scanned again here, so in audit mode a call that PreToolUse already flagged can write a second flagged record | top-level decision = block, with the redacted reason in reason | hookSpecificOutput.additionalContext | opt-in |
PostToolBatch |
every in-scope call in tool_calls[]: each tool_input as the input and each tool_output (falling back to tool_response) and tool_error as the tool result, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them; the input is scanned again here, so in audit mode a call that PreToolUse already flagged can write a second flagged record; the batch is analyzed as one interaction named after its first in-scope call that is not a Read (a Read names it only when nothing else in scope is in it, and every Read member is also judged on its own path and output) and carrying no single shell command, so evidence from two calls can combine into one finding; the three rules that read shell syntax (dynamic-payload-exfiltration, gh-pr-exfiltration and exfiltration-channel) judge each shell call on its own command, whatever call the batch is named after and in whatever order the calls arrive, so a command's own text gets the verdict it gets on PreToolUse, and exfiltration-channel counts a known service only when a shell call names it, while the evidence that raises it to critical (a detected secret or a reconnaissance finding) may come from any call in the batch; every other shell rule, and those three when the command of a shell call cannot be isolated or the input was truncated, judge the flattened input instead, and only when the batch is named after a shell call, so a batch led by a non-shell call skips them; a batch never takes the written grade of a command-shaped rule, so an encoded-data pipeline in any call of the batch keeps the command rule | top-level decision = block on a deny, with the redacted reason in reason; an ask rides hookSpecificOutput.additionalContext and does not stop the turn | hookSpecificOutput.additionalContext | yes |
Stop |
nothing from the event: it triggers a throttled, scoped, offline scan of recent sessions on this machine | never blocks (advisory only) | systemMessage with suppressOutput | yes |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Grok Build (formerly Cursor)
Grok Build (formerly Cursor) fires camelCase events, each with its own stdin shape and its own verdict schema - unlike Claude's single envelope. Skarn wires five blocking events by default, preToolUse with the matcher Write|Delete.
Routing. Four of the five camelCase event names are unique to Cursor. preToolUse is also an event name of the Copilot CLI and of Kiro, so under auto-detection a preToolUse event routes to Cursor only when it carries cursor_version, which every Cursor event sends and no other host does. The shipped Cursor configs pin --agent cursor.
Fail mode. In enforce, an unparseable event exits 2 (Cursor's schema-agnostic hard block) and a tool input the guard cannot fully classify asks on the shell and MCP events, with or without --strict (--strict turns that ask into a deny); audit records the would-be verdict and blocks nothing. A scan-infrastructure failure (unreadable rules) still exits 2 only under --strict plus enforce. A shell command, or a Cursor file write or delete, that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way. Cursor's own file writes, edits and deletes reach the guard through preToolUse, which does not enforce ask, so enforce answers every would-be ask there as a deny. Cursor sends an edit as a write of the whole file after the edit, so a credential already in that file is judged again on every edit and blocks the edit in enforce until the value is accepted with skarn guard accept.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
beforeShellExecution |
command (mapped to the canonical Bash tool) | permission = deny or ask, with the redacted reason in user_message and agent_message | none - Cursor's blocking events carry no non-deciding channel, so audit stays silent and relies on the guard log | yes |
beforeReadFile |
file_path as the input and content as the result (credential-file recon and dotenv contents), the content also scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of it | permission = deny (allow/deny only, so a would-be ask degrades to deny) | none (see beforeShellExecution) | yes |
beforeMCPExecution |
tool_input, under the canonical mcp__<server>__<tool> name | permission = deny or ask, with the redacted reason in user_message and agent_message | none (see beforeShellExecution) | yes |
beforeSubmitPrompt |
prompt | continue = false, with the redacted reason in user_message | none (see beforeShellExecution) | yes |
preToolUse |
Cursor's Write and Delete tools only: for a Write, file_path and content under the canonical Write tool, the content being the whole file after the change, because Cursor sends every create, overwrite, edit and notebook edit as a Write; for a Delete, file_path. Every other tool on this event is allowed without a scan: beforeShellExecution, beforeReadFile and beforeMCPExecution judge shell, read and MCP calls, so each is judged once, and no wired Cursor event judges Grep, Task or any other tool | permission = deny, with the redacted reason in user_message and agent_message (Cursor does not enforce ask on this event, so a would-be ask degrades to deny) | none (see beforeShellExecution) | yes |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Codex CLI
Codex's hook system mirrors Claude's - PascalCase events and a near-identical PreToolUse JSON - but its verdict semantics differ: permissionDecision ask and a bare allow both FAIL OPEN, so a would-be ask degrades to deny. Codex fires more events than Skarn wires; the rest are evaluated and deliberately left off the matrix (verified against the OpenAI Hooks guide, 2026-08-30): SessionStart and SubagentStart carry only session and subagent metadata (model, permission_mode, agent_id/type), no credential-bearing tool or prompt content; PreCompact and PostCompact carry only a compaction trigger over already-seen transcript the recall scan covers; SubagentStop carries last_assistant_message (so it is NOT content-free), but that post-hoc subagent output lands in the session store the recall scan and the turn-end advisory already cover, so it is a deliberate deferral pending the cross-action daemon the codex README names. SessionEnd, which the previous sweep recorded as absent and the reference now documents, carries a session id, a transcript path where one exists, and a reason (always other); it fires on archive, on deletion, on a normal close, and after 30 minutes idle, so it reaches a lifecycle moment the turn-scoped Stop row cannot - a codex session that ends without another turn produces no Stop, and if the shared hourly advisory budget was spent on the other host in the meantime that session's nudge is simply lost. It stays unwired anyway: its output is advisory and cannot steer Codex, so the nudge has no committed surface there, and Codex runs it synchronously under a 1-second default timeout capped at 3 seconds, which the recent-session scan can exceed on a large store. The gap is recorded rather than closed.
Routing. Codex shares Claude's event names, so pass --agent codex explicitly. Auto-detection falls back to a Codex-only tell: turn_id (on every turn-scoped event, PermissionRequest included) or the apply_patch/spawn_agent tools.
Fail mode. In enforce, an event the guard cannot fully classify (unparseable, oversized, a repeated key, or a tool input nested past the flatten bound) is denied in the schema of the event that fired, with or without --strict (Codex has no ask channel, so the ask the log records degrades to a deny); when the event is too large to parse, the deny takes the shape of the event named in the bytes the guard did read; with no event name and no --event pin it takes the PreToolUse shape, which another event may ignore. Audit records the would-be verdict and blocks nothing. A scan-infrastructure failure (unreadable rules) still denies only under --strict plus enforce. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
tool_name plus the flattened tool_input; only Bash carries a raw shell command (apply_patch's command field is patch text) | hookSpecificOutput.permissionDecision = deny, with the redacted reason in permissionDecisionReason | systemMessage alone - the Codex reference lists continue, stopReason and suppressOutput as unsupported on this event, so Skarn sends none of them (its parser today rejects only continue:false, but Skarn does not rely on that) | yes |
PermissionRequest |
the same tool_name plus tool_input as PreToolUse | hookSpecificOutput.decision.behavior = deny, with the redacted reason in message | systemMessage alone - the reference lists the same three universal fields as unsupported here as on PreToolUse | yes |
UserPromptSubmit |
prompt | top-level decision = block, with the redacted reason in reason | continue = true plus systemMessage - this event supports the universal fields | yes |
PostToolUse |
tool_input as the input and tool_response as the tool result of an in-scope tool, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them; the input is scanned again here, so in audit mode a call that PreToolUse already flagged can write a second flagged record | top-level decision = block, with the redacted reason in reason | continue = true plus systemMessage - this event supports the universal fields | opt-in |
Stop |
nothing from the event: it triggers a throttled, scoped, offline scan of this machine's recent codex sessions | never blocks (advisory only) | systemMessage with suppressOutput; it carries no decision, so Codex never continues the turn | yes |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
GitHub Copilot CLI
The Copilot CLI's native payload is camelCase (toolName / toolArgs / sessionId) and carries no event-name field on most events, so the event is inferred from the field shape; permissionRequest is the exception: on CLI 1.0.82 its payload names itself with hookName and carries the arguments as toolInput rather than toolArgs (measured live 2026-08-30), the guard reads both keys, and the shipped config entry still pins it with --event permissionRequest so an older CLI that sends the preToolUse shape there is answered in the right schema. preToolUse and permissionRequest both block; the other events run full detection and write the audit log but cannot decide. GitHub documents fourteen Copilot CLI hook events; Skarn declares five of them (preToolUse, permissionRequest, userPromptSubmitted, userPromptTransformed, postToolUse) plus preMcpToolCall, and evaluates the rest as deliberately not wired (verified against the GitHub hooks reference, 2026-08-30): sessionStart carries an initialPrompt (scannable), but a session-open detection arm beyond userPromptTransformed is out of this round's scope; subagentStart and subagentStop carry subagent metadata (agentName, transcriptPath), and the subagent's own tool calls are gated by preToolUse while any post-hoc output lands in the session store the recall scan covers; postToolUseFailure carries the failed call's toolArgs plus its error text, which can hold output preToolUse never saw, so leaving it unwired is a deliberate coverage deferral of the same class as the opt-in postToolUse output scan; errorOccurred and notification carry human-readable error and message text (a low-value surface deferred this round, not a claim they can never carry a secret); preCompact carries a compaction trigger and any customInstructions over already-seen transcript; agentStop (Stop) and sessionEnd carry only a stopReason/reason over transcript the recall scan covers. Every one of these is a deliberate coverage deferral, not an assertion that the event can never carry a credential.
Routing. The camelCase field set is the CLI tell. A Copilot payload in Claude-compat mode is byte-indistinguishable from a real Claude event (field names AND tool names), so the shipped Copilot configs always pass --agent copilot explicitly. The CLI loads hooks from policy, then the user, then the repository (its hook files and its inline settings block), then plugins (GitHub hooks reference, 2026-08-30), and how several hooks for one event compose differs by event. On preToolUse any hook returning deny blocks the tool, so a Skarn deny there is final; measured on CLI 1.0.70 the entries after the denying one did not run at all, and on 1.0.61 under SDK 1.0.1 the host's own SDK-registered callback was never invoked for that call either. On permissionRequest every configured hook runs and their outputs are MERGED with later outputs overriding earlier ones, so a Skarn deny there is not final: a hook loading after it that answers allow replaces the decision. That is why preToolUse remains the durable gate and permissionRequest is a second chokepoint rather than a stronger one. A sandbox escape narrows what the merge can produce: when toolInput carries requestSandboxBypass: true, GitHub's reference states that a hook allow never pre-approves the request or short-circuits the user prompt and only a deny propagates, so the merged permissionRequest decision on such a call can block it or leave it to the interactive prompt, never pre-approve it; a hook loading after Skarn can still replace the deny with an allow that falls through to the user. A top-level disableAllHooks: true in the repository's .github/copilot/settings.json skips every hook from repository files, user files, plugins and inline blocks for that repository, the operator's own included, and logs nothing when it does; machine policy hooks keep running under it (GitHub documents them as unaffected; measured on CLI 1.0.82 in a trusted repository, where the same session suppressed the user hook and honored the policy hook's deny). It silences the layers it reaches across events (sessionStart as well as preToolUse) and leaves the host application's own SDK-registered callbacks running, so doctor reads that file and reports the file layer as inert rather than counting it as protection or calling the machine unprotected.
Fail mode. preToolUse fails CLOSED on a non-zero exit, but a hook TIMEOUT fails OPEN (the shipped configs set timeoutSec 10). permissionRequest treats exit 2 as a deny. In enforce, an unparseable event exits 2, and a tool input the guard cannot fully classify, or a read of a dotenv file whose requested lines lie past the 4 MiB the guard reads, asks on preToolUse (denies under --strict, and on permissionRequest, which has no ask), with or without --strict; audit records the would-be verdict and blocks nothing. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
preToolUse |
toolName plus toolArgs (an object, or a JSON string that is parsed and flattened); every view and read is in scope before the call, with or without --strict, and when it names a file in path the guard opens that file and judges it as it judges a Claude Code Read (a regular text file, up to 4 MiB, only the lines a view_range names, and the whole file when the view_range is not one the guard reads), so a detected secret in the lines it reads denies, a KEY=value line in a dotenv file asks (dotenv-file-read), a dotenv file larger than 4 MiB read past the bytes the guard read gets the cannot-classify verdict, and a credential store read whole with no credential in it is not flagged by its path, except GnuPG key material, whose path alone is the credential; arguments the guard cannot read (a JSON string that does not parse or does not hold an object, or a value that is neither an object nor a string when no readable fallback key is present) are answered as input the guard cannot classify, with or without --strict | top-level permissionDecision = deny or ask, with the redacted reason in permissionDecisionReason | additionalContext | yes |
permissionRequest |
toolName plus the arguments under toolInput (the key CLI 1.0.82 sends on this event, an object or a JSON string that is parsed and flattened) or toolArgs (the preToolUse key, read for an older CLI); a view or read is opened and judged as on preToolUse | top-level behavior = deny, with the redacted reason in message; that decision short-circuits the normal permission flow, but not other hooks - every configured permissionRequest hook runs and later outputs override earlier ones, so a hook loading after Skarn can answer allow and replace the deny | none | yes |
userPromptSubmitted |
prompt | nothing is emitted - the CLI ignores this event's hook output | none | yes |
userPromptTransformed |
transformedPrompt (the transformed, model-facing prompt text; the payload also carries the pre-transformation prompt, and this row is inferred on transformedPrompt before the prompt-only userPromptSubmitted branch) | nothing is emitted - this event's only output channel is modifiedTransformedPrompt, which rewrites the model-facing prompt, and Skarn declines that mutation channel by policy; there is no block or decision channel on this event, so it is detection and audit-log ONLY | none | opt-in |
preMcpToolCall |
arguments, under the canonical mcp__<server>__<tool> name | nothing is emitted - this event's output controls only MCP request metadata | none | opt-in |
postToolUse |
toolArgs as the input (an object, or a JSON string that is parsed and flattened) and toolResult as the tool result, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them; the input is scanned again here, so in audit mode a call that preToolUse already flagged can write a second flagged record | advisory only - never blocks | additionalContext | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
GitHub Copilot (VS Code agent mode)
VS Code agent mode speaks a second Copilot dialect, with PascalCase event names in a Claude-shaped envelope, camelCase tool_input keys, and VS Code's own tool-name vocabulary (such as run_in_terminal and create_file), which Skarn maps to canonical names. MCP calls arrive as PreToolUse with an mcp_<server>_<tool> name.
Routing. VS Code discovers hooks from ~/.claude/settings.json (chat.hookFilesLocations), so a machine already running Skarn's Claude guard receives VS Code Copilot events. The VS Code tool-name vocabulary routes them to the Copilot adapter instead of a silent Claude fast-allow; the shipped configs pin --agent copilot.
Fail mode. VS Code blocks only on exit 2; any other non-zero exit fails OPEN. In enforce, an unparseable event exits 2, and a tool input the guard cannot fully classify, or a read of a dotenv file larger than the 4 MiB the guard reads (a read_file of one whatever lines it asks for), asks (denies under --strict), with or without --strict; audit records the would-be verdict and blocks nothing. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
tool_name (VS Code vocabulary, mapped to canonical) plus the flattened tool_input; every read is in scope before the call, with or without --strict: a read_file names its file in filePath, and the guard opens and judges the whole saved file on disk, up to 4 MiB, whatever range it asks for (startLine and endLine, or offset and limit), so a secret outside the requested lines can deny, while an unsaved edit in an open editor, which read_file can return, is not judged and a request for the first line of a dotenv file larger than 4 MiB gets the cannot-classify verdict; a Claude-shaped Read names its file in file_path and is judged as a Claude Code Read, offset and limit included; a view or read names no path field the guard reads a file from, so it is judged on its arguments only; a tool_input that is not an object is answered as input the guard cannot classify | hookSpecificOutput.permissionDecision = deny or ask - both fully honored (the exact inverse of the CLI, where the decision is top-level) | systemMessage | yes |
UserPromptSubmit |
prompt | top-level decision = block, with the redacted reason in reason | systemMessage | yes |
PostToolUse |
tool_input as the input and tool_response (falling back to tool_result, the key GitHub documents for the VS Code-compatible payload) as the tool result, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them; the input is scanned again here, so in audit mode a call that PreToolUse already flagged can write a second flagged record | top-level decision = block, with the redacted reason in reason | systemMessage | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Gemini CLI
Gemini CLI fires eleven PascalCase events with a JSON envelope on stdin; hooks ship on by default since v0.26.0. Skarn gates three of them - BeforeTool (the enforcing pre-execution gate), BeforeAgent (the submitted prompt, an egress channel), and AfterTool (the tool result, opt-in) - and every other event fast-allows. The stdout protocol is strict: the host requires that a hook print nothing to stdout but its final JSON object, so the guard's emit arm is the sole stdout writer and an allow prints nothing at all. Gemini's PUBLISHED output schema documents only allow and deny (alias block), with no ask value; gemini-cli 0.49.0 does route an undocumented decision "ask" on BeforeTool to an interactive confirmation, but skarn deliberately does not emit it: a version that drops the undocumented behavior would read "ask" as no decision and let the call through, so a would-be ask degrades to deny (fail-closed on an undocumented channel). Timeouts are MILLISECONDS here, not seconds (the shipped entries use 5000).
Routing. The Before*/After* event vocabulary is unique to Gemini - no other host uses those names - so auto-detection is unambiguous; the shipped configs pin --agent gemini anyway, the same policy every other host follows. MCP tools arrive named mcp_<server>_<tool> with SINGLE underscores, so the guard keys MCP treatment on that prefix rather than on the canonical mcp__ form.
Fail mode. A non-2 non-zero exit is a warning and fails open; exit 2 blocks with stderr as the reason. A licensed enforce exits 2 on an event the guard cannot parse (malformed, oversized, or a repeated key) and denies a tool input it cannot fully classify (nested past the flatten bound), with or without --strict, and the guard log records the same verdict; a scan that cannot run (unreadable rules) exits 2 only under --strict plus enforce; an out-of-scope action still fast-allows, and an unlicensed or free-tier guard is forced to audit and exits 0. A hook that runs past its timeout has its decision discarded and the call proceeds, and the observed wait tracks the hook's own runtime up to about 30 seconds rather than the configured value, so the timeout bounds nothing - a fast guard is the real protection. From gemini-cli 0.56.0 a crashed, timed-out, or exit-2 hook also prints a 'Hook execution for <event>: N succeeded, M failed' summary and a '[WARNING] Hook(s) [skarn-guard] failed' line on stderr; only the exit-2 case blocks. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
BeforeTool |
tool_name (mapped from Gemini's own vocabulary: run_shell_command, write_file, replace, read_file, read_many_files, web_fetch, google_web_search, invoke_agent) plus the flattened tool_input; a run_shell_command command is also carried raw so a tool description cannot poison the package parse | top-level decision = deny, with the redacted reason in reason (a would-be ask degrades to deny: the published schema documents no ask value, and the undocumented one gemini-cli 0.49.0 honors here would fail open on any version that drops it) | systemMessage | yes |
BeforeAgent |
prompt | top-level decision = deny, with the redacted reason in reason | systemMessage | yes |
AfterTool |
tool_input as the input and tool_response as the tool result, an object carrying llmContent, returnDisplay, and an optional error, flattened into the scanned bytes, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them; from gemini-cli 0.56.0 llmContent arrives wrapped in <untrusted_context> tags, which are scanned through and trigger nothing on their own; the input is scanned again here, so in audit mode a call that BeforeTool already flagged can write a second flagged record | top-level decision = deny, with the reason replacing the tool result before the model sees it | systemMessage | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Grok Build CLI
Grok Build CLI fires a PascalCase event set with a JSON envelope on stdin, in a camelCase dialect of its own: hookEventName carries a snake_case VALUE ("pre_tool_use"), the tool fields are toolName/toolInput/toolUseId/toolInputTruncated, and PostToolUse adds toolResult. Skarn gates three of those events - PreToolUse (the only enforcement point grok offers), UserPromptSubmit (the submitted prompt, an egress channel), and PostToolUse (the tool result, opt-in) - and every other event fast-allows. Grok has NO non-deciding channel: its passive events ignore stdout entirely and every recognized PreToolUse output decides, so the guard emits nothing at all in audit mode and the would-be verdict lands only in the guard log, which skarn guard report reads. Timeouts are seconds (the shipped entries use grok's 5-second default). The honest posture is fail-open: every grok hook failure, timeout, crash or malformed output is recorded for the session scrollback and blocks nothing, so an explicit deny is the only thing that stops a call.
Routing. The camelCase hookEventName key is unique to grok - Claude, Codex, Cursor and VS Code Copilot spell it hook_event_name, and the Copilot CLI carries no event-name field - so an unpinned grok payload auto-detects on key presence, before the Copilot CLI's toolName/sessionId structural tells that it would otherwise trip. Grok is also the ONE place the guard overrides an explicit --agent pin: grok natively runs the hooks configured in ~/.claude/settings.json and ~/.cursor/hooks.json and invokes them with its own dialect, so a hook pinned --agent claude is handed grok events it cannot read. When the process environment carries GROK_HOOK_EVENT (grok's runner injects it for every hook and strips any value a config sets) AND the payload carries hookEventName, the event routes to the grok adapter whatever the pin says. Neither signal alone moves a pin, and a real Claude payload under a claude pin is unaffected either way. MCP tools arrive under their resolved server__tool name with no prefix; the guard rewrites that to the canonical mcp__ form so every tool-keyed detector sees an MCP call, and an MCP call never fast-allows.
Fail mode. Every failure fails open, which is grok's own posture for hooks: a non-zero exit other than 2 is recorded and blocks nothing. Exit 2 is an explicit PreToolUse deny, and a deny on stdout is honored regardless of the exit code (a stdout allow paired with exit 2 still denies, so the guard never pairs the two). A licensed enforce turns an unparseable event into one stderr line and exit 2, and denies a tool input it cannot fully classify, with or without --strict; audit records the would-be verdict and blocks nothing. A scan-infrastructure failure (unreadable rules) still exits 2 only under --strict plus enforce. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
toolName (mapped from grok's own vocabulary: run_terminal_command, run_terminal_cmd, bash, search_replace, edit, hashline_edit, write, read_file, hashline_read, web_fetch, web_search, spawn_subagent) plus the flattened toolInput; a shell command is also carried raw, from command or from cmd when command is absent, so a tool description cannot poison the package parse | top-level decision = deny, with the redacted reason in reason (a would-be ask degrades to deny: grok's schema has no ask value) | nothing - grok has no non-deciding channel, so the would-be verdict goes to the guard log only | yes |
UserPromptSubmit |
prompt | nothing - grok ignores stdout on this event, so it is detection and audit only | nothing - the would-be verdict goes to the guard log only | yes |
PostToolUse |
toolInput as the input and toolResult as the tool result, typed as arbitrary JSON, so a string result is scanned as sent and an object one is flattened into the scanned bytes, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them; the input is scanned again here, so in audit mode a call that PreToolUse already flagged can write a second flagged record | nothing - grok ignores stdout on this event | nothing - the would-be verdict goes to the guard log only | opt-in |
pre_tool_use |
the same event as PreToolUse | top-level decision = deny | nothing | yes |
user_prompt_submit |
the same event as UserPromptSubmit | nothing | nothing | yes |
post_tool_use |
the same event as PostToolUse | nothing | nothing | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Antigravity CLI (agy)
The Antigravity CLI (agy) fires five PascalCase events - PreToolUse, PostToolUse, PreInvocation, PostInvocation, Stop - with a camelCase protojson envelope on stdin and NO event-name field: the hooks.json entry that fired is the only thing that names the event, so the adapter reads the event off the payload shape (a toolCall whose error key is absent or null is the PreToolUse it gates; any other error value, including the empty string a successful PostToolUse carries, marks a non-tool event, and every other shape fast-allows). PreToolUse is the whole guard surface on this host: PreInvocation carries no prompt text and PostToolUse carries no tool output, so there is no prompt-submit gate and no result scan (verified on agy 1.1.18 and 1.1.19). The stdout contract is a flat {"decision","reason"} object, and agy FAILS CLOSED on everything but an explicit allow: a deny blocks, and a crash, a timeout (seconds; the shipped entries use 5), invalid JSON, and an empty {} (a missing decision) all block the call and the model sees the hook-failure text; only an empty stdout was observed to proceed (1.1.19), which is undocumented and which the guard never relies on. The guard therefore answers EVERY tool event with an explicit decision: enforce prints deny or allow, audit prints allow with the would-be verdict in reason (agy has no non-deciding channel), an out-of-scope tool gets an explicit allow, and a non-tool event gets the empty object. ask is not a block on agy (it hands the call to the permission layer, which auto-denies in print mode), so a would-be ask degrades to deny. An allow never grants a permission: agy's own permission check still runs after the hook.
Routing. The camelCase toolCall / conversationId / workspacePaths / artifactDirectoryPath field set is unique to agy - Claude, Codex, Cursor, Gemini, and VS Code Copilot use snake_case envelopes, the Copilot CLI spells its fields toolName/toolArgs/sessionId, and grok's tell is hookEventName - so an unpinned agy payload auto-detects (before the Claude PascalCase fallback, so a future payload that adds hook_event_name still routes here); the shipped configs pin --agent antigravity anyway, uniform policy. The agy tool vocabulary on the hook wire was pinned live (1.1.19): a file write fires as write_to_file (TargetFile/CodeContent) and an edit as replace_file_content or multi_replace_file_content (TargetFile/ReplacementContent), while run_command, view_file, browser_*, the read_url_content/open_browser_url/search_web network steps, and the agency_tool_call/invoke_subagent/browser_subagent subagent steps keep their step-type spellings; the step-type spellings of the write tools (file_change, code_action, edit_notebook) stay mapped and matched as drift aliases. The MCP dispatch is call_mcp_tool on the hook wire (the binary's hook tool table) and mcp_tool in the transcript the scan parser reads; both are rewritten to the canonical mcp__ form (from the ServerName/ToolName args), so an MCP call never fast-allows. The grok override still applies: a hook process grok spawned routes to grok whatever the pin.
Fail mode. Fail-closed by the host's design, on every outcome but an explicit allow: a crashed, slow (past the entry's timeout, in seconds), or malformed skarn BLOCKS the tool call, and a missing skarn binary blocks every matched call the same way (sh -c exits 127). Enforce and audit are both hard gates here - audit cannot fail more open than enforce, so a machine where the hook is wired and the binary is gone blocks matched calls until the binary is back or the entry is removed. A licensed enforce answers an event the guard cannot parse, or a tool input it cannot fully classify, with an explicit deny, with or without --strict; audit answers an explicit allow that names the would-be verdict. A scan-infrastructure failure (unreadable rules) still denies only under --strict plus enforce and answers an explicit allow otherwise. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
toolCall.name mapped to canonical (run_command to Bash; write_to_file, file_change, and code_action to Write; replace_file_content and multi_replace_file_content to Edit; notebook_edit and edit_notebook to NotebookEdit; view_file to Read; browser_subagent, invoke_subagent, and agency_tool_call to spawn_agent; every other browser_* plus execute_browser_javascript, capture_browser_screenshot, read_url_content, and open_browser_url to WebFetch; search_web to WebSearch; call_mcp_tool and mcp_tool to mcp__) plus the flattened toolCall.args, with the TargetFile/AbsolutePath path lifted to a canonical file_path line for the write-target detectors; a run_command's CommandLine is also carried raw so toolSummary and toolAction cannot poison the package parse | top-level decision = deny, with the redacted reason in reason (a would-be ask degrades to deny: ask is not a block on agy); an allow is printed explicitly, because the contract requires a decision and an empty {} is a deny | top-level decision = allow, with the would-be verdict (and the unlicensed or free-tier advisory) in reason - agy has no non-deciding channel | yes |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Kimi Code
Kimi Code fires PascalCase events with a JSON envelope on stdin - hook_event_name, session_id, cwd - because its hook runner builds the payload from camelCase keys and snake-cases them on the way out, so the shape is Claude's with two differences that matter: every payload carries a client_type naming the host, and UserPromptSubmit delivers prompt as an ARRAY of content blocks rather than a string (verified on kimi-code 0.39.1). Of the twenty events kimi defines, only PreToolUse, UserPromptSubmit and Stop can block; the rest are fire-and-forget, so a verdict on one would be a claim the host does not honor. Both blocking events skarn gates are wired by default. PermissionRequest is deliberately not wired - it is observation-only on kimi, unlike Claude Code, where it is a real second gate - and Stop stays unwired because blocking it forces the assistant to keep going.
Routing. Kimi shares Claude's envelope and event names, so the tell is the client_type field its own hook runner stamps on every payload: no other host emits it, and the value is matched rather than just the key, so only kimi's own CLI identity routes here. The pin still matters and every shipped entry carries it: a host embedding kimi's older hook engine sends no client_type, and that payload is byte-shaped like Claude's. The misroute is not symmetric - a claude-routed PreToolUse deny happens to be schema-compatible and still blocks, but a claude-routed UserPromptSubmit answers with a top-level decision block that kimi does not honor, so the prompt is allowed while the guard log records a deny that never happened, under a claude label that corrupts the per-assistant denominators guard report is built from. The kimi tool vocabulary is Claude's for everything skarn gates except FetchURL (mapped to WebFetch), Agent and AgentSwarm (mapped to spawn_agent) and ReadMediaFile (mapped to Read); MCP calls already arrive in Claude's own mcp__<server>__<tool> form.
Fail mode. Fail-open by the host's design: exit 2 blocks, exit 0 with a deny object blocks, and every other non-zero exit, every hook error and every timeout allows the action. The shipped entries set timeout = 10, below kimi's 30-second default. A licensed enforce answers an unparseable event with exit 2 and one stderr line, and denies a tool input it cannot fully classify, with or without --strict; audit records the would-be verdict and blocks nothing. A scan-infrastructure failure (unreadable rules) still exits 2 only under --strict plus enforce. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
tool_name mapped to canonical (FetchURL to WebFetch, Agent and AgentSwarm to spawn_agent, ReadMediaFile to Read; Bash, Write, Edit, WebSearch, Read and the mcp__ form are already Claude's names) plus the flattened tool_input; a Bash command is also carried raw so a tool description cannot poison the package parse | hookSpecificOutput.permissionDecision = deny, with the redacted reason in permissionDecisionReason and exit 0 | none - kimi has no non-deciding channel; the guard log carries the audit trail | yes |
UserPromptSubmit |
prompt, flattened across the content-block array kimi delivers it in (a bare string is still accepted) | exit 2 with the redacted reason on stderr, which kimi takes as the block message; stdout untouched | none - kimi has no non-deciding channel; the guard log carries the audit trail | yes |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Cline
Cline runs hooks as executable files named after the event, one file per event, discovered in ~/Documents/Cline/Hooks/ and a workspace's .clinerules/hooks/ (the CLI also reads ~/.cline/hooks/, .cline/hooks/ and a --hooks-dir). Two runners read those files. The VS Code extension's runner sends the PascalCase event under a camelCase hookName - PreToolUse, PostToolUse, UserPromptSubmit - beside clineVersion, taskId and workspaceRoots, with the tool call under preToolUse as a tool name and a map of string parameters, and gives the hook 30 seconds. The SDK runner behind the cline CLI maps the same file names onto its own event names - tool_call, tool_result, prompt_submit - and sends those under hookName, with the real tool input under tool_call.input beside the legacy object, and gives a tool hook 120 seconds (verified on cline 3.0.60 and the 4.1.16 extension source). Each runner reads one JSON object from stdout on the events it waits for: cancel true ends the task with errorMessage as the reason, both runners append contextModification as hook context for PreToolUse, and once that object parses the exit code is ignored. The extension's own runner handles 4.x extension sessions and waits for every event it fires; since extension 4.1.26 it also injects a UserPromptSubmit contextModification into the model context; the SDK runner waits only for tool_call and tool_result and fires prompt_submit detached with stdout discarded, so the prompt event blocks under the extension's runner alone. Both gated events are wired by the shipped executables; PostToolUse is supported opt-in, and the task lifecycle, notification and compaction events carry nothing to gate and fast-allow.
Routing. Cline's tell is the camelCase hookName key beside a taskId or clineVersion: both of its runners stamp them and no other host sends hookName, so an unpinned event auto-detects. The shipped executables pin --agent cline all the same, because Cline's event names collide with Claude Code's and Codex's and a hook file is copied between machines and forks where nothing else names the host. The SDK tool vocabulary is mapped onto the canonical tool names - run_commands and execute_command to Bash, read_files and read_file to Read, editor and replace_in_file to Edit, write_to_file to Write, fetch_web_content and web_fetch to WebFetch, search_codebase and search_files to Grep, new_task to spawn_agent, apply_patch and spawn_agent unchanged - and use_mcp_tool is rebuilt as mcp__<server>__<tool> from its own server_name and tool_name. The gated set matches the Claude arm: Grep fast-allows and Read is strict-only.
Fail mode. Fail-open by the host's design: only a parsed stdout object carrying cancel true blocks. A non-zero exit without that object, a timeout, and an unparseable stdout all allow the action. The extension also skips a POSIX file without the exec bit; the CLI can run it through its shebang interpreter. The guard always exits 0 and speaks only through the object. A licensed enforce answers an unparseable event, or a tool input it cannot fully classify, with the cancel object, with or without --strict; audit records the would-be verdict and blocks nothing. A scan-infrastructure failure (unreadable rules) still cancels only under --strict plus enforce. The shipped files include POSIX shell and Windows PowerShell hooks. On Windows both runners look for <HookName>.ps1 and ignore the extensionless files. The extension runs powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File; the CLI runs powershell -File and does not run a .ps1 hook under a Restricted execution policy. Both launch forms are tested with native skarn.exe: stdin arrives byte for byte and stdout reaches Cline as exactly one JSON object without a byte-order mark. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
the tool name mapped to canonical, plus the flattened tool input (the SDK's tool_call.input when present, else the extension's parameters map); a shell command is also carried raw - run_commands as its command list joined by newlines, execute_command as its single command - so a tool description cannot poison the package parse | one stdout object, cancel true with the redacted reason in errorMessage, exit 0; Cline ends the task with that message | one stdout object, cancel false with the would-be verdict and the redacted rule in contextModification, which Cline appends to the conversation as hook context; the licence and education notices ride the same field | yes |
tool_call |
the same call as PreToolUse, under the name the SDK runner sends for the same executable | as PreToolUse | as PreToolUse | yes |
UserPromptSubmit |
userPromptSubmit.prompt, the submitted prompt text | cancel true with the redacted reason in errorMessage; the task ends before the prompt reaches the model provider | cancel false with the would-be verdict in contextModification | yes |
prompt_submit |
the same prompt as UserPromptSubmit, under the name the SDK runner sends for the same executable | the advisory object, never a cancel: the SDK runner fires this event detached and reads nothing back, so the guard log records the verdict with enforceable false and skarn guard report never counts it as a block | as UserPromptSubmit | yes |
PostToolUse |
the tool name and input as PreToolUse, plus postToolUse.result, the tool output, which is also scanned as the tool result with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of it | cancel true with the redacted reason; the output already exists, so the cancel ends the task rather than withholding the result | cancel false with the would-be verdict in contextModification | opt-in |
tool_result |
the same call and output as PostToolUse, under the name the SDK runner sends for a PostToolUse file | as PostToolUse | as PostToolUse | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Copilot in Code
Copilot in Code is the coding workspace of the Microsoft Copilot app on Windows. It runs the GitHub Copilot CLI agent, and that agent runs command hooks from the Copilot CLI's own hook file format, so the copilot adapter answers them and the shipped copilot configs serve both hosts. Code reads every *.json in each profile's hooks folder, where skarn setup --agent copilot-code writes skarn.json, and the .github/hooks folder of a folder project, which skarn setup --agent copilot --scope project writes. A new session loaded a changed profile hook file; whether an app restart is also needed was not measured. On Copilot app `156.0.4314.58` with GitHub Copilot CLI `1.0.93` on Windows, preToolUse, postToolUse, userPromptSubmitted, sessionStart and sessionEnd fired a command hook; errorOccurred was registered and did not fire; permissionRequest, userPromptTransformed and preMcpToolCall were not shown to fire. A repository project's .github/hooks, and its worktrees, were not measured, and neither was whether Code shows additionalContext. On macOS setup writes the same hook file to each profile. On Copilot app `158.0.4370.33`, with GitHub Copilot CLI `1.0.108` on macOS, no matching guard event was observed from a profile's hook file on Windows or macOS, while the .github/hooks/skarn.json of a folder project fired userPromptSubmitted, preToolUse and permissionRequest in audit mode on both; whether a deny is honoured on app `158.0.4370.33` was not measured.
Routing. Code sends the Copilot CLI's flat camelCase payload, one call per hook run, including each call of a parallel batch: sessionId, timestamp, cwd, toolName and toolArgs as an object. The shipped configs pin --agent copilot, so the call takes the copilot adapter's CLI dialect. Nothing in the payload names Code, so the guard reads the attribution from its own environment instead. Code sets COPILOT_HOME to the profile directory, and a COPILOT_HOME whose parent directory is named CopilotCodingHome labels the record copilot-code rather than copilot (a linked COPILOT_HOME resolves through its session-state directory, as the scan side does). Code's terminal tool undocked-terminal-run_terminal is scanned as Bash with its command, WebGrounding-web as WebSearch and WebGrounding-browse as WebFetch. A terminal canvas is scanned as Bash too: open_canvas with canvasId terminal carries the command in input.command, and invoke_canvas_action with actionName send_terminal_input carries it in input.input. A terminal canvas call the guard cannot read takes the ambiguous-input verdict over its raw text, an ask in enforce (a deny with --strict) that Code receives as a deny: an input that is not an object, a command or input field that is not a string, a send_terminal_input with no input field, and a toolArgs string that does not parse. A terminal canvas opened with no command runs nothing and fast-allows, because the terminal's own schema makes input.command optional. Every other canvas call, rename_session and list_canvas_capabilities fast-allow. A payload carrying only a batched toolCalls array, the shape the agent records for its own in-process hooks, is unclassifiable and exits 2 in enforce.
Fail mode. On Copilot app `156.0.4314.58` a preToolUse deny was honoured and its reason shown, and a hook that exited nonzero denied the tool. A hook that ran past timeoutSec was killed and the tool it held then ran, measured on one call; the shipped configs set timeoutSec 10. A would-be ask is answered with a deny in enforce on Copilot in Code, because ask was not measured there and Code can run unattended; the standalone Copilot CLI keeps its interactive ask. The guard log keeps the decided ask, so skarn guard report counts that call as a prompt, as on every host that turns an ask into a block. A tool input the guard cannot fully classify, and a read of a dotenv file whose requested lines lie past the 4 MiB the guard reads, are such a would-be ask. In enforce an unparseable event exits 2; audit records the would-be verdict and blocks nothing. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
preToolUse |
toolName plus toolArgs (an object on Code; the JSON string an older CLI sends is parsed too); undocked-terminal-run_terminal and a terminal canvas are scanned as Bash with their command; every view and read is opened and judged as on the Copilot CLI, with or without --strict, so a detected secret in the lines the guard reads denies, and a KEY=value line in a dotenv file, or a dotenv file larger than 4 MiB read past the bytes the guard read, is a would-be ask that enforce answers deny; skarn guard accept can release a secret finding by its value fingerprint, but not a dotenv-file-read finding or a cannot-classify verdict, because neither carries a value to fingerprint | top-level permissionDecision = deny, with the redacted reason in permissionDecisionReason; a would-be ask is answered deny as well | additionalContext | yes |
userPromptSubmitted |
prompt, which on Code carries the blocks the app injects around the typed text | nothing is emitted - the CLI ignores this event's hook output | none | yes |
postToolUse |
toolArgs as the input and toolResult (resultType and textResultForLlm on Code) as the tool result, both scanned with the secret rules and with the base64, hex, percent-encoded and gzip payloads decoded out of them | advisory only - never blocks | additionalContext | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Server-side agent runtimes (skarn envelope)
Your runtime client wraps LangChain, Strands, AgentCore, the OpenAI Agents SDK, Google ADK, an MCP server or an in-house loop and calls skarn guard --agent sdk on stdin. You send Skarn's own versioned JSON envelope with v 1, event and a required runtime label. You can include session_id, cwd and identity; identity is an assertion that the guard does not authenticate. For pre_tool_use and post_tool_use, tool carries name, kind, optional server and input as an object or string. A post_tool_use also carries result as a string or object; a user_prompt_submit carries prompt as a string. The guard maps kind shell to Bash, write to Write, edit to Edit, read to Read, fetch to WebFetch and mcp to mcp__<server>__<name>. A missing kind or kind other maps to sdk-tool, which has no structural meaning in the engine; the guard scans the content and never gives the runtime tool name structural meaning. For kind mcp the guard builds the name the way every host builds an MCP name, so a known MCP tool such as serena read_file keeps the meaning it has on every other host. The guard also scans the raw tool name as a tool: <name> line. In the verdict object and log it replaces the name with sdk-tool when the name exceeds 64 bytes, contains a byte outside [A-Za-z0-9_.-], looks like a credential by the same screen the fleet drop applies to a tool, or contains a matched value, and whenever a finding in the call was decoded out of an encoded payload, because an encoded name does not contain its decoded value. The guard scans every kind without --strict, including read; the strict Read gate is a laptop-host rule. You get v, verdict, enforce, reason, rule, fingerprint, severity, incidents, chain, tool and notice in the JSON verdict object. Enforce needs a paid license; audit is the default. You need no hook config file: skarn setup and skarn doctor do not cover this host, and no shipped config wires it. The guard reads stdin and writes stdout; it opens no socket.
Routing. The guard checks for an integer v and a string runtime after every vendor tell. Your runtime client pins --agent sdk anyway. Without the pin, an envelope that lacks an integer v or a string runtime is not recognized as sdk and falls to the Claude adapter, so the one-object answer to an unclassifiable call holds only under --agent sdk; with the pin, the sdk object answers even inside a grok hook process.
Fail mode. Your client is a program that reads the verdict object. Every call gets one object and exit 0. An unclassifiable call answers ask, or deny under --strict; a scan-infrastructure failure answers ask. Missing or unknown v or event, a missing runtime, an unknown kind, a result that is a number or a bool, unparseable JSON or a repeated key gets reason unparseable tool event and tool sdk-tool. An input nested past the flatten bound gets reason tool input too deeply nested or ambiguous to classify. Audit returns the same object with enforce false, as does a call without a paid license. Your client blocks nothing when enforce is false. Your client must treat a nonzero exit or a missing or unparseable object as its own failure and fail closed to ask. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
pre_tool_use |
the tool input as a flattened object or a string, the raw tool name line and, for kind shell, the command, with encoded payloads decoded out of them | the verdict field of the object with enforce true and the redacted reason in reason; your client blocks on deny and degrades ask per runtime | the same object with enforce false; your client blocks nothing | opt-in |
post_tool_use |
the tool input as a flattened object or a string, the raw tool name line and, for kind shell, the command, plus result as the tool result, with encoded payloads decoded out of them | the verdict field of the object with enforce true and the redacted reason in reason; your client blocks on deny and degrades ask per runtime | the same object with enforce false; your client blocks nothing | opt-in |
user_prompt_submit |
the prompt on an egress channel, so a secret in it denies | the verdict field of the object with enforce true and the redacted reason in reason; your client blocks on deny and degrades ask per runtime | the same object with enforce false; your client blocks nothing | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Kiro CLI
Kiro CLI 3.x runs two agent harnesses in one binary, V3 by default and V2 on request, and each reads hooks from its own surface. V3 runs every standalone hook file in ~/.kiro/hooks/ and the workspace's .kiro/hooks/, a v1 document whose hooks array carries PascalCase triggers with a command action, plus the hooks of the agent or profile a session selects. V2 runs only the camelCase hooks of the agent config a session selects and never loads a hook file. Both harnesses send one JSON envelope on stdin with hook_event_name, session_id and cwd, plus tool_name and tool_input on tool events. The verdict is the process exit code: exit 2 blocks the call and the model receives the stderr text as the reason, exit 0 lets it run, and Kiro reads every other code as a warning and runs the tool. Skarn gates PreToolUse, the one event that blocks, and scans UserPromptSubmit, PostToolUse, Stop and the session-start events; every other trigger is allowed at exit 0. Hook-file timeouts are seconds, and the shipped entries use 10. Enforcement was measured blocking on macOS on both harnesses with Kiro CLI 3.3.0. On Windows, where Kiro CLI 2.18.1 ran hooks and ignored their exit codes, the adapter runs audit semantics by design, and enforcement on Linux is not yet claimed for 3.x.
Routing. No field of a Kiro payload tells it apart from the hosts Skarn also guards: a V3 tool event has the shape of a Claude Code or Copilot CLI event, and a V2 tool event that of a Copilot CLI one. An unpinned V3 execute_bash call reaches an adapter that leaves it unscanned, an unpinned V3 read_file or MCP call gets a JSON answer Kiro ignores, and an unpinned V2 tool event is refused as unparseable under the wrong host name. Kiro therefore never auto-detects, every shipped entry pins --agent kiro, and doctor reports a wired hook without the pin as dead. Tool names arrive in each harness's own vocabulary (V2 read, write and shell; V3 read_file, fs_write and execute_bash) and map to the canonical tools. A V2 MCP call arrives as @server/tool and a V3 one as mcp_server_tool; a name the adapter does not recognize is scanned as a possible MCP call and never fast-allowed.
Fail mode. Exit 2 is the only block, and the guard never exits 1. A timeout, a missing binary and a hook that fails to start all let the call run. Kiro has no ask channel, so in enforce an ask blocks like a deny. A licensed enforce answers a tool event the guard cannot parse, and a tool input nested past its flatten bound, with exit 2 and one stderr line. The exit 2 decision is made before anything is written, so a closed stderr still blocks. A scan-infrastructure failure (unreadable rules) exits 2 only under --strict plus enforce. A Windows build exits 0 on every event and records the would-be verdict as an audit record. A call that removes, downgrades, silences or edits the skarn hook is an agent-hook-removal finding: enforce denies a removal, a downgrade or a silencing that the hook file the guard reads proves, and answers every other such call the way it answers a tool input it cannot fully classify. A shell command that names a credential file and runs a program whose name is computed at run time is an unresolved-program-exfiltration finding, answered that same way.
| Event | Scans | Enforce | Audit | Shipped |
|---|---|---|---|---|
PreToolUse |
tool_name mapped from each harness's vocabulary (V3 read_file, fs_write, fs_append, str_replace, execute_bash, execute_pwsh, delete_file, web_fetch, remote_web_search) plus the flattened tool_input; a shell command is carried raw from command, so a description cannot poison the package parse; a read is scanned only under --strict, and then for its path, never for the file it names | exit 2 with the redacted reason on stderr (a would-be ask blocks too: Kiro has no ask channel) | one plain-text stdout line, which Kiro writes and ignores on this event; the guard log is the record | yes |
UserPromptSubmit |
prompt | the advisory line on stdout and exit 0, because the Kiro CLI does not block a prompt | one plain-text stdout line, which Kiro adds to the model's context | yes |
PostToolUse |
tool_input as the input and tool_response as the tool result, flattened as arbitrary JSON (a string on V3, an object of items with Text fields on V2) | the advisory line on stdout and exit 0 | one plain-text stdout line, which Kiro writes and ignores on this event | opt-in |
Stop |
assistant_response when present; a V3 Stop carries nothing to scan | the advisory line on stdout and exit 0 | one plain-text stdout line, which Kiro ignores on this event | opt-in |
SessionStart |
prompt when present; no measured session-start event carried one, so there is usually nothing to scan | the advisory line on stdout and exit 0 | one plain-text stdout line, which Kiro adds to the model's context | opt-in |
preToolUse |
the same as PreToolUse, with the V2 tool names read, write and shell | exit 2 with the redacted reason on stderr | one plain-text stdout line, which Kiro ignores on this event | yes |
userPromptSubmit |
prompt | the advisory line on stdout and exit 0 | one plain-text stdout line, which Kiro adds to the model's context | yes |
postToolUse |
the same as PostToolUse | the advisory line on stdout and exit 0 | one plain-text stdout line, which Kiro ignores on this event | opt-in |
stop |
assistant_response | the advisory line on stdout and exit 0 | one plain-text stdout line, which Kiro ignores on this event | opt-in |
agentSpawn |
prompt when present; the measured V2 agentSpawn carries none | the advisory line on stdout and exit 0 | one plain-text stdout line, which Kiro adds to the model's context | opt-in |
"Shipped" means the hook configs in the Skarn repository wire the event by default. An opt-in event is fully supported by the binary - add a block for it to your own config to enable it.
Wiring it up
skarn setup detects the AI coding agents installed on the machine and merges the guard hook into each one's native config in audit mode - existing hooks untouched, every modified file backed up and rewritten atomically, and the run ends with a self-test that proves the wiring end to end. skarn doctor then verifies it stays alive: it names any event your installed config does not gate, and it catches a dead hook (a wired command whose binary no longer exists), which every host silently fails open on.
Full option reference: the guard, setup, and doctor sections of the manual.