
If you're writing Claude Code hooks, this walks you through the entire lifecycle from design decisions to deployment. It's structured around progressive disclosure, loading detailed references only when you need them, which reportedly cuts token usage by 55%. The core content focuses on five specific pitfalls that break hooks in production: unquoted variables failing on filenames with spaces, missing input validation enabling path traversal, synchronous operations blocking Claude for 30+ seconds, using exit 1 instead of exit 2 so PreToolUse hooks don't actually block, and assuming dependencies exist. Good for both writing new hooks and debugging why existing ones fail intermittently.
$ npx -y skills add secondsky/claude-skills --skill claude-hook-writer --agent claude-codeInstalls into .claude/skills of the current project.
Status: Production Ready Version: 2.0.0 (Optimized with progressive disclosure) Last Updated: 2025-12-17
Expert guidance for writing secure, reliable, and performant Claude Code hooks. This skill validates design decisions, enforces best practices, and prevents common pitfalls.
Hooks execute automatically with user permissions and can read, modify, or delete any file the user can access.
ALWAYS validate and sanitize all input. Hooks receive JSON via stdin—never trust it blindly.
For complete security patterns: Load references/security-requirements.md when implementing validation or securing hooks.
A hook that works 99% of the time is a broken hook. Edge cases (Unicode filenames, spaces in paths, missing tools) will happen.
Test with edge cases before deploying.
Sponsors