creating-claude-hooks

Create Claude Code hooks with executable formats and JSON I/O conventions.

790|60|Updated Dec 17, 2025
One-click install
npx skills add https://github.com/khaliqgant/agent-relay --skill creating-claude-hooks-khaliqgant
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: creating-claude-hooks
Source: https://github.com/khaliqgant/agent-relay/tree/main/.claude/skills/creating-claude-hooks-skill/SKILL.md
Command: npx skills add https://github.com/khaliqgant/agent-relay --skill creating-claude-hooks-khaliqgant

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps create Claude Code hooks - covers executable format, events, JSON I/O, exit codes, security requirements, and PRPM package structure.

Core Features & Use Cases

  • Hook format requirements (location, executable, shebang)
  • Events and input/output conventions
  • Exit codes and security considerations
  • Publishing hooks as PRPM packages

Quick Start

Create a Claude hook at .claude/hooks/session-start with the required shebang and executable flag and ensure proper JSON I/O.

Frequently Asked Questions about creating-claude-hooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Claude Code hook?

Create a Claude Code hook by placing an executable script with a shebang (#!/bin/bash, #!/usr/bin/env python, or #!/usr/bin/env node) in .claude/hooks/ or your global hooks directory, then set executable permissions. The hook reads JSON from stdin, processes it, and outputs text to stdout, returning exit code 0 for success, 2 to block execution, or 1 for errors.

What events can Claude Code hooks respond to?

Claude Code hooks support multiple events: session-start runs when a session begins, user-prompt-submit triggers on user input, tool-call fires when Claude invokes a tool, and assistant-response executes after Claude responds. Each event type receives specific JSON input and can enforce exit codes to control Claude Code behavior.

Can I publish Claude Code hooks as PRPM packages?

Yes, Claude Code hooks can be packaged and published as PRPM packages. Follow the hook format requirements—executable permissions, shebang headers, JSON I/O conventions, and proper exit codes—then structure your package with hooks under .claude/hooks/ directory to make them installable across local, CI, and repository workflows.

What languages can I use to write Claude Code hooks?

Claude Code hooks support bash, TypeScript, and Python. Each language requires the appropriate shebang line (#!/bin/bash, #!/usr/bin/env node, or #!/usr/bin/env python) at the top of the executable file. The hook must parse JSON input from stdin and output text to stdout regardless of language choice.

What do Claude Code hook exit codes mean?

Exit code 0 indicates successful hook execution and allows Claude Code to continue. Exit code 2 blocks the current operation (e.g., prevents prompt submission or tool execution). Exit code 1 signals an error occurred during hook processing. These codes enforce security and control flow across session-start, user-prompt-submit, tool-call, and assistant-response events.

Why does my Claude Code hook fail with 'not executable'?

Claude Code hooks require executable permissions on the file. After creating your hook script with the correct shebang, run chmod +x on the file path. Hooks must be placed in .claude/hooks/ (project-level) or the user-global hooks directory, and the filesystem must preserve executable permissions when stored or deployed.