Skills

Creating Claude Hooks

Use when creating or publishing Claude Code hooks - covers executable format, event...

Install

npx skills add AgentWorkforce/relay --skill creating-claude-hooks -g -a claude-code -y
Repository
AgentWorkforce/relay1.1k
Category
Security
Updated
3d ago
License
Apache-2.0
Context cost
Mediumabout 2,635 tokens
Runs scripts
No, instructions only

What it does

Use when creating or publishing Claude Code hooks - covers executable format, event types, JSON I/O, exit codes, security requirements, and PRPM package structure

Creating Claude Code Hooks

Use this skill when creating, improving, or publishing Claude Code hooks. Provides essential guidance on hook format, event handling, I/O conventions, and package structure.

When to Use This Skill

Activate this skill when:

  • User asks to create a new Claude Code hook
  • User wants to publish a hook as a PRPM package
  • User needs to understand hook format or events
  • User is troubleshooting hook execution
  • User asks about hook vs skill vs command differences

Quick Reference

Hook File Format

AspectRequirement
Location.claude/hooks/<event-name>
FormatExecutable file (shell, TypeScript, Python, etc.)
PermissionsMust be executable (chmod +x)
ShebangRequired (#!/bin/bash or #!/usr/bin/env node)
InputJSON via stdin
OutputText via stdout (shown to user)
Exit Codes0 = success, 2 = block, other = error

Available Events

EventWhen It FiresCommon Use Cases
session-startNew session beginsEnvironment setup, logging, checks
user-prompt-submitBefore user input processesValidation, enhancement, filtering
tool-callBefore tool executionPermission checks, logging, modification
assistant-responseAfter assistant respondsFormatting, logging, cleanup

Hook Format Requirements

File Location

Project hooks:

.claude/hooks/session-start
.claude/hooks/user-prompt-submit

User-global hooks:

Read the whole SKILL.md on GitHub

More in Security