Skip to content

Hooks

Hooks are event-driven scripts that execute at specific points in the Claude Code lifecycle. PopKit includes 23 hooks for various events.

Hooks in PopKit:

  • Event-driven: Triggered by specific lifecycle events
  • Portable: Use cross-platform path conventions
  • Validated: Follow JSON stdin/stdout protocol
  • Tested: Have comprehensive test coverage
  • SessionStart: When Claude Code session begins
  • SessionEnd: When session ends
  • SessionResume: When session is restored
  • FirstMessage: Before first user message
  • UserMessage: After each user message
  • AssistantMessage: After Claude’s response
  • FileCreate: When file is created
  • FileModify: When file is modified
  • FileDelete: When file is deleted
  • GitCommit: Before/after git commits
  • GitPush: Before/after git push
  • GitPR: When pull request is created

All hooks use a standard JSON protocol:

Input (stdin):

{
"event": "SessionStart",
"data": {
"cwd": "/path/to/project",
"timestamp": "2026-01-14T12:00:00Z"
}
}

Output (stdout):

{
"status": "success",
"message": "Hook executed successfully",
"data": {}
}

PopKit hooks follow Claude Code portability standards:

  • Use ${CLAUDE_PLUGIN_ROOT} for plugin-relative paths
  • Double-quoted paths for Windows compatibility
  • Forward slashes for cross-platform support
  • Python shebang: #!/usr/bin/env python3

Hooks are defined in hooks/hooks.json with:

{
"SessionStart": {
"type": "command",
"command": "python \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.py\"",
"timeout": 10000
}
}

See the Hook Development Guide for details.