ReferenceHooks Reference

Hooks Reference

This page specifies the exact JSON contract for Syntic Code hooks. For the concepts and use cases, see the hooks guide; here we document the events, the payload passed to your command on stdin, and how Syntic Code interprets your command’s response. Hooks are configured under the hooks key of .syntic/settings.json.

Configuration schema

Each event maps to a list of matchers, each pairing a matcher pattern against tool names with one or more command strings to run:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "bash|write",
        "command": "./scripts/policy-check.sh",
        "timeout": 5000
      }
    ]
  }
}

The matcher is a regular expression tested against the tool name (omit it or use "*" to match all). timeout is optional milliseconds after which the hook is killed and treated as a failure.

Stdin payload

Syntic Code invokes your command and writes a JSON object to its stdin describing the event:

FieldTypeDescription
eventstringThe lifecycle event, e.g. PreToolUse.
session_idstringIdentifier of the current session.
tool_namestringName of the tool involved (tool events only).
tool_inputobjectArguments passed to the tool.
tool_resultobjectResult of the tool (PostToolUse only).
cwdstringThe session working directory.

Response contract

Your command signals its decision through its exit code and output. Exit 0 allows the action; on PreToolUse and Stop, a non-zero exit blocks it. Anything written to stderr is returned to Amara as feedback, so a blocking hook should explain why it blocked. For richer control, a hook may print a JSON object to stdout with a decision field (allow, deny, or ask) and an optional message, which overrides the exit-code behavior. Events fire for SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop, and SessionEnd.