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.
Canonical Format
Section titled “Canonical Format”Syllago uses a provider-neutral canonical format for hooks, defined by the Hook Interchange Format Specification.
Handler Types
Section titled “Handler Types”Hooks support four handler types:
| Type | Description |
|---|---|
command | Shell command executed as a subprocess |
http | HTTP POST to a URL |
prompt | LLM-evaluated logic (not all providers support this) |
agent | Delegated to an agent subprocess |
Event Names (Canonical)
Section titled “Event Names (Canonical)”Hook events use provider-neutral names in the canonical format:
| Canonical Event | Claude Code | Gemini CLI |
|---|---|---|
before_tool_execute | PreToolUse | before_tool_call |
after_tool_execute | PostToolUse | after_tool_call |
before_prompt | UserPromptSubmit | before_send |
agent_stop | Stop | on_complete |
session_start | SessionStart | session_start |
session_end | SessionEnd | session_end |
Syllago translates event names automatically when converting between providers.
Matcher Types
Section titled “Matcher Types”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
Exit Code Contract
Section titled “Exit Code Contract”| Code | Meaning |
|---|---|
0 | Success — parse JSON output |
1 | Non-blocking warning |
2 | Block action (only if blocking: true) |
| Other | Treated as warning |
Provider Support
Section titled “Provider Support”| Provider | Hook Support | Notes |
|---|---|---|
| Claude Code | Full | Richest output contract, all event types |
| Gemini CLI | Full | Unique events: before_model, after_model, before_tool_selection |
| Copilot CLI | Full | Conservative safety design |
| Cursor | Yes | JSON merge into .cursor/settings.json |
| Windsurf | Yes | JSON merge |
| Codex | Yes | JSON hooks in .codex/hooks.json |
| Cline | Yes | File-based executables in .clinerules/hooks/ |
| Kiro | Yes | Embedded in agent JSON files |
| Zed, Roo Code, OpenCode, Amp | No | — |
Hook Security
Section titled “Hook Security”Syllago includes a hook security scanner that detects dangerous patterns when converting hooks:
| Risk Level | Patterns Detected |
|---|---|
| HIGH | curl, rm -rf, piped execution, network commands |
| MEDIUM | Broad matchers, wildcard patterns |
| LOW | System paths, environment variable access |
Security warnings appear in syllago convert and syllago install output.
Portability Warnings
Section titled “Portability Warnings”When converting hooks between providers, syllago surfaces warnings for:
- Unsupported events: e.g., Gemini’s
before_modelhas no Claude Code equivalent - Capability mismatches: e.g.,
updated_input(input rewriting) not supported by target - Degradation applied: hooks that use the
block,warn, orexcludedegradation strategy
See Also
Section titled “See Also”- Hook Interchange Format Specification — full canonical format specification
- Content Types Overview — full provider compatibility matrix
- Format Conversion — how syllago converts between provider formats