creating-hooks

Automate Claude Code hooks defined in YAML frontmatter for lifecycle events.

225|62|Updated Dec 29, 2025
One-click install
npx skills add https://github.com/lexler/skill-factory --skill creating-hooks-lexler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: creating-hooks
Source: https://github.com/lexler/skill-factory/tree/main/output_skills/ai/claude-code/creating-hooks
Command: npx skills add https://github.com/lexler/skill-factory --skill creating-hooks-lexler

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests>=2.31.0, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This skill enables precise, repeatable control over Claude Code behavior by defining hooks that run at lifecycle events such as PreToolUse, PostToolUse, and SessionStart, ensuring actions occur exactly when needed.

Core Features & Use Cases

  • Deterministic hook execution: supports command, prompt, and agent hooks that trigger at specific events.
  • Frontmatter-scoped hooks: define hooks within the skill frontmatter so they activate only when the skill is active.
  • Project and plugin integration: hooks can be scoped to a project or applied globally and can reference scripts in scripts/ or documentation in references/.

Quick Start

  • Open Claude Code and enable the skill to load its frontmatter-defined hooks.
  • Use the /hooks menu to add or customize hooks like PreToolUse for a Bash command, or Stop to prompt for verification via prompt or agent hooks.

Frequently Asked Questions about creating-hooks

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

FAQPage Schema
How do I create deterministic hooks for Claude Code lifecycle events?

You create deterministic hooks for Claude Code by defining them in YAML frontmatter, which triggers command, prompt, or agent hooks at specific lifecycle events like PreToolUse, PostToolUse, and SessionStart.

What is the best way to automate Claude Code behavior for specific tool actions?

The best way to automate Claude Code behavior is by setting up frontmatter-scoped hooks that run commands or prompts at specific tool lifecycle events, ensuring actions occur exactly when needed within a project.

Can I scope Claude Code hooks to a specific project instead of applying them globally?

Yes, you can scope Claude Code hooks to a specific project by defining them within the skill frontmatter so they activate only when that skill is active, rather than applying them globally.

How do I add matchers and timeouts to Claude Code hooks?

You add matchers and timeouts to Claude Code hooks by defining these optional parameters alongside command, prompt, or agent hook configurations in the YAML frontmatter, allowing precise control over when execution triggers.

Does setting up Claude Code hooks require external scripts?

No, Claude Code hooks do not require external scripts, but they support referencing scripts in a scripts directory or documentation in a references directory to execute complex deterministic actions during lifecycle events.