hooks-configurationlisted
Install: claude install-skill seanwinslow28/code-brain
# Hooks Configuration
## Purpose
Create, configure, and debug Claude Code hooks that enforce security policies, automate quality checks, and inject context at precise points in the agentic loop. Hooks are deterministic -- they always execute, unlike skills which rely on model judgment.
## When to Use
- Creating a PreToolUse hook to block dangerous commands or sensitive file access
- Setting up PostToolUse hooks for auto-formatting or logging
- Adding a Stop hook to run tests before Claude yields control
- Configuring SessionStart hooks to inject project context
- Debugging a hook that is not firing or is causing errors
- Choosing between command hooks, prompt hooks, and agent hooks
## Examples
**Example 1: Block secrets access**
```
User: "Create a hook that prevents Claude from reading .env files"
Claude: [Uses hooks-configuration] Creates .claude/hooks/block-secrets.py:
import sys, json
data = json.load(sys.stdin)
path = data.get('tool_input', {}).get('file_path', '')
if '.env' in path or 'secrets' in path:
print(f"ACCESS DENIED: '{path}' contains secrets.", file=sys.stderr)
sys.exit(2)
sys.exit(0)
Adds to .claude/settings.json:
"PreToolUse": [{"matcher": "Read|Edit|Write", "hooks": [{"type": "command", "command": "python3 .claude/hooks/block-secrets.py"}]}]
```
**Example 2: Auto-format Python files**
```
User: "Run ruff format every time Claude edits a Python file"
Claude: [Uses hooks-configuration] Configures a PostToolUse hook with matcher "Edit|Write" t