claude-sdk-hooks

Implement lifecycle hooks for the Claude Agent SDK to manage agent behavior.

2|1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Folken2/nuvel --skill claude-sdk-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-sdk-hooks
Source: https://github.com/Folken2/nuvel/tree/main/nuvel/backends/claude_agent_sdk/skills/claude-sdk-hooks
Command: npx skills add https://github.com/Folken2/nuvel --skill claude-sdk-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires claude-agent-sdk, and includes references (resource) components.

What problem does it solve?

This skill addresses the need for granular, deterministic control over an agent's lifecycle, allowing developers to implement safety guards, audit trails, and context management that go beyond simple permission callbacks.

Core Features & Use Cases

  • Event-Driven Hooks: Execute custom logic at specific lifecycle points like PreToolUse, PostToolUse, and UserPromptSubmit.
  • Regex-Based Matching: Apply specific policies to individual tools or groups of tools using the HookMatcher system.
  • Use Case: Implement an audit logger that records every tool call and its output for compliance, or create a safety guard that blocks dangerous shell commands like rm -rf before they execute.

Quick Start

Configure the ClaudeAgentOptions with a PreToolUse hook using a HookMatcher to audit all tool executions.

Frequently Asked Questions about claude-sdk-hooks

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

FAQPage Schema
How do I implement deterministic lifecycle hooks for the Claude Agent SDK?

To implement deterministic lifecycle hooks for the Claude Agent SDK, configure ClaudeAgentOptions with HookMatcher instances to execute custom logic at specific agent events like PreToolUse and PostToolUse.

Can I block dangerous shell commands before they execute in a Claude agent?

Yes, you can block dangerous shell commands in a Claude agent by registering a PreToolUse hook with regex-based matching to create safety guards that prevent specific tool executions like rm -rf.

How do I set up audit logging for Claude agent tool executions?

You set up audit logging for Claude agent tool executions by defining a HookMatcher within your agent configuration to record every tool call and its output for compliance tracking.

Does the Claude Agent SDK support dynamic context injection during agent events?

Yes, the Claude Agent SDK supports dynamic context injection during agent events by utilizing deterministic lifecycle hooks to manage and inject context at specific lifecycle points like UserPromptSubmit.

What is the best way to apply specific security policies to individual agent tools?

The best way to apply specific security policies to individual agent tools is using the regex-based HookMatcher system to target specific tools or groups and enforce deterministic behavior controls.

Do I need the claude-agent-sdk library to register lifecycle hooks?

Yes, you need the claude-agent-sdk library to define and register HookMatcher instances required for configuring and managing deterministic agent lifecycle hooks.