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. The table below lists events supported by both Claude Code and Gemini CLI; see the Hook Event Matrix for every canonical event across all providers.

Canonical EventClaude CodeGemini CLI
after_tool_executePostToolUseAfterTool
agent_stopStopAfterAgent
before_compactPreCompactPreCompress
before_promptUserPromptSubmitBeforeAgent
before_tool_executePreToolUseBeforeTool
notificationNotificationNotification
session_endSessionEndSessionEnd
session_startSessionStartSessionStart

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