Arvore Repo Hub

Hooks

Hooks let you run shell commands or prompt the AI at specific points during an editor session. Cursor, Claude Code, and Kiro all support hooks, and hub.yaml provides a unified way to define them once and generate the correct format for each editor.

What Are Hooks?

Hooks are automation triggers that fire at editor lifecycle events — like when a file is edited, before a shell command runs, or when the AI session starts. They’re useful for:

  • Formatting code after edits
  • Blocking dangerous commands
  • Running initialization scripts
  • Auditing AI actions
  • Summarizing work at session end

hub.yaml Schema

Hooks are defined at the top level of hub.yaml, keyed by event name (in snake_case):

hooks:
  pre_tool_use:
    - type: command
      command: "./hooks/block-dangerous.sh"
      matcher: "rm -rf|drop table"
  after_file_edit:
    - type: command
      command: "./hooks/format.sh"
  session_start:
    - type: command
      command: "./hooks/init.sh"
  stop:
    - type: prompt
      prompt: "Summarize what was done and what's left to do"

Hook Entry Fields

FieldTypeRequiredDescription
typestringYescommand (shell script) or prompt (AI-evaluated)
commandstringWhen type=commandShell command or script path
promptstringWhen type=promptPrompt text for the AI to evaluate
matcherstringNoRegex pattern to filter when the hook fires
timeout_msnumberNoTimeout in milliseconds

Event Reference

Hub uses snake_case event names. hub generate maps them to each editor’s naming convention. Events exclusive to one editor are silently skipped for the others.

Shared Events

hub.yamlCursorClaude CodeKiro
session_startsessionStartSessionStart
session_endsessionEndSessionEnd
pre_tool_usepreToolUsePreToolUsepre_tool_use
post_tool_usepostToolUsePostToolUsepost_tool_use
stopstopStopagent_stop
subagent_startsubagentStartSubagentStart
subagent_stopsubagentStopSubagentStop
pre_compactpreCompactPreCompact
before_submit_promptbeforeSubmitPromptUserPromptSubmitprompt_submit

Cursor-Only Events

hub.yamlCursor
before_shell_executionbeforeShellExecution
after_shell_executionafterShellExecution
before_mcp_executionbeforeMCPExecution
after_mcp_executionafterMCPExecution
after_file_editafterFileEdit
before_read_filebeforeReadFile
before_tab_file_readbeforeTabFileRead
after_tab_file_editafterTabFileEdit
after_agent_responseafterAgentResponse
after_agent_thoughtafterAgentThought

Claude Code-Only Events

hub.yamlClaude Code
notificationNotification
permission_requestPermissionRequest
task_completedTaskCompleted
teammate_idleTeammateIdle
post_tool_use_failurePostToolUseFailure

Kiro-Mapped Events

hub.yamlKiro
pre_tool_usepre_tool_use
post_tool_usepost_tool_use
stopagent_stop
before_submit_promptprompt_submit
after_file_editfile_save

Note: Kiro hooks are managed via the Kiro panel UI, not through configuration files. When generating for Kiro, hub generate will display the hooks that should be configured manually in the Kiro IDE.

How hub generate Works

When you run hub generate, hooks are generated in each editor’s native format:

Cursor.cursor/hooks.json:

{
  "version": 1,
  "hooks": {
    "afterFileEdit": [
      {
        "type": "command",
        "command": "./hooks/format.sh"
      }
    ]
  }
}

Claude Code — merged into .claude/settings.json:

{
  "permissions": { "..." : "..." },
  "hooks": {
    "PreToolUse": [
      {
        "type": "command",
        "command": "./hooks/block-dangerous.sh",
        "matcher": "rm -rf|drop table"
      }
    ]
  }
}

Kiro — hooks are displayed as instructions for manual setup in the Kiro panel UI. Kiro supports the following hook triggers: Prompt Submit, Agent Stop, Pre Tool Use, Post Tool Use, File Create, File Save, File Delete, and Manual Trigger.

CLI Commands

hub hooks list

List hooks installed in the local hooks/ directory.

hub hooks list

hub hooks add <source>

Install hooks from the registry, a git repository, or a local path.

hub hooks add format-on-save            # From registry
hub hooks add company/shared-hooks      # From GitHub repo
hub hooks add ./my-hooks                # From local path
hub hooks add format-on-save --repo myorg/my-registry  # Custom registry
FlagDescription
--hook <name>Install a specific hook only (for repo sources)
-r, --repo <repo>Override registry repository

After installing, add the hook to hub.yaml to bind it to an event.

hub hooks remove <name>

Remove a hook from the local hooks/ directory.

hub hooks remove format-on-save

Examples

Format on Save

hooks:
  after_file_edit:
    - type: command
      command: "./hooks/format.sh"

Block Dangerous Commands

hooks:
  pre_tool_use:
    - type: command
      command: "./hooks/block-dangerous.sh"
      matcher: "rm -rf|drop table|force push"

Session Summary

hooks:
  stop:
    - type: prompt
      prompt: "Summarize everything that was done in this session and list any remaining tasks."