Skip to content llms.txt

Hooks

Hooks are event-driven automation scripts triggered by AI tool lifecycle events. They let you run custom logic when specific events occur — before or after a tool call, on session start, on file change, and so on.

Supported by Claude Code, Gemini CLI, Copilot CLI, Cursor, Windsurf, Codex, Cline, and Kiro.

Syllago uses a provider-neutral canonical format for hooks, defined by the Hook Interchange Format Specification.

Hooks support four handler types:

TypeDescription
commandShell command executed as a subprocess
httpHTTP POST to a URL
promptLLM-evaluated logic (not all providers support this)
agentDelegated to an agent subprocess

Hook events use provider-neutral names in the canonical format:

Canonical EventClaude CodeGemini CLI
before_tool_executePreToolUsebefore_tool_call
after_tool_executePostToolUseafter_tool_call
before_promptUserPromptSubmitbefore_send
agent_stopStopon_complete
session_startSessionStartsession_start
session_endSessionEndsession_end

Syllago translates event names automatically when converting between providers.

Hooks use matchers to target specific tools or events:

  • Bare string: Tool vocabulary lookup (e.g., "shell", "file_read")
  • Pattern object: Regex on tool name ({"pattern": "file_(read|write|edit)"})
  • MCP object: Server+tool targeting ({"mcp": {"server": "github", "tool": "create_issue"}})
  • Array: OR logic across multiple matchers
CodeMeaning
0Success — parse JSON output
1Non-blocking warning
2Block action (only if blocking: true)
OtherTreated as warning
ProviderHook SupportNotes
Claude CodeFullRichest output contract, all event types
Gemini CLIFullUnique events: before_model, after_model, before_tool_selection
Copilot CLIFullConservative safety design
CursorYesJSON merge into .cursor/settings.json
WindsurfYesJSON merge
CodexYesJSON hooks in .codex/hooks.json
ClineYesFile-based executables in .clinerules/hooks/
KiroYesEmbedded in agent JSON files
Zed, Roo Code, OpenCode, AmpNo

Syllago includes a hook security scanner that detects dangerous patterns when converting hooks:

Risk LevelPatterns Detected
HIGHcurl, rm -rf, piped execution, network commands
MEDIUMBroad matchers, wildcard patterns
LOWSystem paths, environment variable access

Security warnings appear in syllago convert and syllago install output.

When converting hooks between providers, syllago surfaces warnings for:

  • Unsupported events: e.g., Gemini’s before_model has no Claude Code equivalent
  • Capability mismatches: e.g., updated_input (input rewriting) not supported by target
  • Degradation applied: hooks that use the block, warn, or exclude degradation strategy