agentworkforce avatar

Creating Claude Hooks

This is your reference for building executable hooks that tap into Claude Code's event system. It covers the four main events (session start, prompt submit, tool call, assistant response), shows you how to handle JSON input from stdin and use exit codes to block operations, and walks through the PRPM package structure if you want to publish. The format requirements are specific: you need shebangs, executable permissions, and proper quoting around variables. Most useful when you're actually writing a hook and need to remember whether blocking is exit 2 or when to use stderr vs stdout. The examples are practical, showing real validation and logging patterns in both bash and TypeScript.

GitHub stars
719
last updated
Jun 11, 2026

Install

$ npx -y skills add agentworkforce/relay --skill creating-claude-hooks --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/agentworkforce/relay
Category
Frontend Development
License
Apache-2.0
First seen
Jun 11, 2026

More from agentworkforce/relay

All 18
1callstackincubator avatarreact-native-testingcallstackincubator/agent-skills>0skills.sh installs
2callstackincubator avatarvercel-react-native-skillscallstackincubator/agent-skillsA collection of agent-optimized React Native skills for AI coding assistants.0skills.sh installs
3CongDon1207 avatarangular-api-serviceCongDon1207/AGENTS.mdAngular devs know that HTTP services can quickly become a mess of repeated code and inconsistent error handling.0skills.sh installs
4davila7 avatarHTML Injection Testingdavila7/claude-code-templatesThis skill should be used when the user asks to "test for HTML injection", "inject HTML into web pages", "perform HTML injection attacks", "deface web applicati0skills.sh installs
5kubesphere avatarfrontend-forge-fe-operationskubesphere/kubesphereOperate FrontendExtension (FE) resources in frontend-forge: create, update, rebuild, inspect package artifacts, download packages, publish, unpublish, delete, a0skills.sh installs
6kubesphere avatarfrontend-forge-fi-operationskubesphere/kubesphereOperate FrontendIntegration resources and the frontend-forge extension. Use when Codex needs to create a FrontendIntegration from FrontendIntegration YAML, upda0skills.sh installs