hook-configuration

Automate Claude Code hook creation and refinement for lifecycle events.

18|1|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/andisab/swe-marketplace --skill hook-configuration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-configuration
Source: https://github.com/andisab/swe-marketplace/tree/main/plugins/context-engineering/skills/hook-configuration
Command: npx skills add https://github.com/andisab/swe-marketplace --skill hook-configuration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Hooks enable deterministic automation for Claude Code lifecycle events (PreToolUse, PostToolUse, UserPromptSubmit, etc.), reducing reliance on ad-hoc model behavior and enabling auditable workflows.

Core Features & Use Cases

  • Deterministic automation: run formatting, logging, and permission checks without model interpretation
  • Event coverage: PreToolUse, PostToolUse, UserPromptSubmit, PermissionRequest, Notification, Stop, SubagentStop, SessionStart, SessionEnd
  • Blocking and permissions: exit-code or JSON-based decisions to block or allow actions
  • Project-wide configuration: centralize hooks in .claude/settings.json for teams

Quick Start

Configure a PreToolUse hook to block edits to sensitive files (e.g., .env) and log attempts to ~/.claude-audit.log.

Frequently Asked Questions about hook-configuration

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

FAQPage Schema
How do I automate Claude Code hooks for security and logging?

Configure hooks in .claude/settings.json to run at lifecycle events like PreToolUse and PostToolUse. Use exit codes or JSON-based blocking signals to enforce policies—such as preventing edits to .env files—and log all attempts to an audit trail without relying on model interpretation.

What Claude Code lifecycle events can I hook into?

Hooks cover PreToolUse, PostToolUse, UserPromptSubmit, PermissionRequest, Notification, Stop, SubagentStop, SessionStart, and SessionEnd. Each event allows you to inject deterministic automation for formatting, validation, permission control, and logging at specific workflow stages.

Can I block tool execution with hooks in Claude Code?

Yes. PreToolUse hooks can exit with non-zero codes or return JSON-based blocking signals to prevent tool execution. This enables permission control and security policies—for example, blocking modifications to sensitive files before they're attempted.

How do I configure hooks for a team in Claude Code?

Centralize all hooks in .claude/settings.json at the project level with event matchers and timeout semantics. This single configuration file ensures consistent, auditable automation across team members without duplicating hook logic.

What's the difference between hooks and ad-hoc Claude Code automation?

Hooks provide deterministic, shell-command based automation that runs reliably at defined lifecycle events, regardless of model behavior. Ad-hoc automation relies on model interpretation and lacks the auditability and control that hooks deliver for production workflows.

Do Claude Code hooks work with JSON-based permission signals?

Yes. Hooks support both exit-code decisions and JSON-based blocking signals for fine-grained permission handling. This allows complex authorization logic—such as conditional approval based on file paths or tool types—to be expressed declaratively in your hook configuration.