Agent skill · Security

creating-claude-hooks

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

AgentWorkforcegithub.com/AgentWorkforceGitHub ↗
claude-codecan modify filesApache-2.0
Install
npx skills add AgentWorkforce/relay --skill creating-claude-hooks-skill --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 11 KB
Bundled scripts: none
Allowed tools: ReadWriteEditGrepGlobBash
Path: .claude/skills/creating-claude-hooks-skill/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 784
Language: TypeScript

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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 | Aspect | Requirement | | --------------- | ------------------------------------------------- | | **Location** | `.claude/hooks/<event-name>` | | **Format** | Executable file (shell, TypeScript, Python, etc.) | | **Permissions** | Must be executable (`chmod +x`) | | **Shebang** | Required (`#!/bin/bash` or `#!/usr/bin/env node`) | | **Input** | JSON via stdin | | **Output** | Text via stdout (shown to user) | | **Exit Codes** | `0` = success, `2` = block, other = error | ### Available Events | Event | When It Fires | Common Use Cases | | -------------------- | --------------------------- | ---------------------------------------- | | `session-start` | New s

What's inside
Steps it walks through
  1. When to Use This Skill
  2. Quick Reference
  3. Hook File Format
  4. Available Events
  5. Hook Format Requirements
  6. File Location
  7. Executable Requirements
  8. Input/Output Format
  9. JSON Input Structure
  10. Stdout Output
  11. Exit Codes
  12. Schema Validation
  13. Common Mistakes
  14. Basic Hook Examples
Commands it runs
or
chmod +x .claude/hooks/session-start
exit 0  # Success
exit 2  # Block operation
exit 1  # Error (logs but continues)
Log session start
echo "Session started at $(date)" >> ~/.claude/session.log
Check environment
if ! command -v node &> /dev/null; then
echo "Warning: Node.js not installed" >&2
More from relay
All skills →
About this skill
What does the creating-claude-hooks skill do?

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

How do I install it?

Run `npx skills add AgentWorkforce/relay --skill creating-claude-hooks-skill --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From AgentWorkforce/relay, a repository with 784 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going