Claude Skill MartBrowse skillsQuick linesLearn by videoTerminal guideWhat is a Skill?
← Back to list

Hook Development for Claude Code

A reference skill for designing, configuring, and debugging Claude Code hooks — prompt-based and command-based — across all nine hook events.

Dev & CodingIntermediate★ 552⑂ 49AI score 8/10Last updated: Sep 16, 2026

What it does

  • Documents all nine hook events (PreToolUse, PostToolUse, Stop, SubagentStop, UserPromptSubmit, SessionStart, SessionEnd, PreCompact, Notification) with a quick-reference table of when to use each.
  • Explains when to choose prompt hooks (LLM reasoning, flexible) versus command hooks (deterministic, fast bash checks).
  • Clarifies the two config shapes: plugin hooks/hooks.json (wrapped in {"hooks": {...}}) versus user .claude/settings.json (events at top level).
  • Gives the hook stdin/stdout JSON contracts, exit codes (0 / 2), permissionDecision, decision: approve|block, and systemMessage.
  • Covers matcher regex patterns (Read|Write|Edit, mcp__.*__delete.*), ${CLAUDE_PLUGIN_ROOT} for portable paths, timeout defaults, parallel-execution implications, and security rules (path traversal, sensitive files, quoting bash variables).
  • Adds patterns for conditionally enabled hooks via flag files or config, plus a debugging workflow with claude --debug and /hooks.

Who it's for

  • Developers building Claude Code plugins or team-wide guardrails.
  • Tech leads who want to block dangerous Bash commands or edits to secrets.
  • Anyone enforcing completion criteria (tests, builds) with a Stop hook.
  • Anyone auto-loading project context or env vars at session start.

Example uses

  1. "Add a PreToolUse hook that denies path traversal and .env writes" → generates hooks.json with a Write|Edit matcher plus a validation script.
  2. "Don't let the agent stop until tests and build pass" → a prompt-based Stop hook returning decision: block with a reason.
  3. "Detect project type on session start and persist it" → a SessionStart command hook appending exports to $CLAUDE_ENV_FILE.

· · · Install guide · · ·

Try it now, no install

Paste this into Claude to use the skill without installing anything.

Read the instructions in this file and follow them to help me:
https://raw.githubusercontent.com/tzachbon/smart-ralph/HEAD/.agents/skills/Hook Development/SKILL.md

What I want: (describe your task here)

If Claude can't open the link, open it yourself and paste the contents instead.

↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.

Install in the Claude app (no terminal)
  1. Download the ZIP with the button below.
  2. In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
  3. Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
↓ Download ZIP
Install in Claude Code

Let Claude do it — paste this into Claude Code

Install the skill I found on Claude Skill Mart.
Copy the .agents/skills/Hook Development folder from the GitHub repo tzachbon/smart-ralph into my ~/.claude/skills/hook-development/.
When it's done, tell me in one line what this skill can do.

Install with a command instead

git clone https://github.com/tzachbon/smart-ralph.git && mkdir -p ~/.claude/skills && cp -r "smart-ralph/.agents/skills/Hook Development" ~/.claude/skills/hook-development

⚠ This is a third-party skill. Check the source repository before installing.

  1. Open a terminal in the folder where you keep repos.
  2. Clone the repository: git clone https://github.com/tzachbon/smart-ralph.git
  3. Create the skills directory: mkdir -p ~/.claude/skills
  4. Copy the whole skill folder (the bundled references/, examples/, and scripts/ are needed): cp -r "smart-ralph/.agents/skills/Hook Development" ~/.claude/skills/hook-development
  5. Verify ~/.claude/skills/hook-development/SKILL.md and its subfolders exist.
  6. Make sure jq is installed (jq --version; macOS: brew install jq, Ubuntu: sudo apt install jq).
  7. Restart Claude Code and try a prompt like "create a PreToolUse hook to block dangerous commands".
  8. Remember: hook config loads at session start, so exit and relaunch Claude Code after any change, and use claude --debug to inspect load and execution logs.