Claude Code hooks enable automated validation, logging, and notifications during AI tool execution. This skill provides templates and best practices for configuring PreToolUse, PostToolUse, Notification, and Stop hooks.
Baixar o ZIP da skill
Upload no Claude
Vá em Configurações → Capacidades → Skills → Upload skill
Ative e comece a usar
Testar
A utilizar "claude-hooks". How do I create a hook that logs every file that Claude writes?
Resultado esperado:
- Add this to your ~/.claude/settings.json under the 'hooks' key:
- • Use PostToolUse event to capture writes after they complete
- • Matcher pattern 'Write' targets only file write operations
- • Command uses $CLAUDE_FILE_PATH environment variable
- • Appends each file path to ~/.claude/file_log.txt
Auditoria de Segurança
SeguroThis skill contains only markdown documentation files with hook configuration templates. No executable code, scripts, network calls, or file system access. Pure reference content for Claude Code hook configuration.
Pontuação de qualidade
O Que Você Pode Construir
Audit tool execution
Log all Claude Code tool calls for compliance auditing and security review
Enforce coding standards
Validate code changes before execution to enforce team conventions
Custom notifications
Send alerts to external systems when specific tools complete or fail
Tente Estes Prompts
Show me how to create a PreToolUse hook that validates Bash commands before they run
Create a PostToolUse hook that logs all file write operations to a file
Configure a Notification hook that sends alerts to Slack when Claude completes tasks
Explain the different matcher patterns I can use to target specific tools like Bash(git:*) or MCP tools
Melhores Práticas
- Keep hooks fast (under 1 second) to avoid blocking Claude Code execution
- Use specific matcher patterns instead of wildcards to target only needed tools
- Handle errors gracefully with proper shell error handling to prevent cascade failures
Evitar
- Using verbose logging in hooks that adds excessive output to the conversation context
- Creating hooks that block indefinitely without timeout handling
- Configuring hooks for all tools (*) when only specific tools need automation
Perguntas Frequentes
Which Claude versions support hooks?
What is the maximum hook execution time?
How do hooks integrate with MCP tools?
Are hooks secure?
Why is my hook not triggering?
How do hooks differ from custom instructions?
Detalhes do Desenvolvedor
Estrutura de arquivos