Use when creating Claude Code hooks for code quality, static analysis, or workflow automation. Use when user says "add hook", "enforce linting", "add pre-commit check", "block bad code".
View on GitHubplugins/rcc/skills/writing-hooks/SKILL.md
February 5, 2026
Select agents to install to:
npx add-skill https://github.com/wayne930242/Reflexive-Claude-Code/blob/main/plugins/rcc/skills/writing-hooks/SKILL.md -a claude-code --skill writing-hooksInstallation paths:
.claude/skills/writing-hooks/# Writing Hooks ## Overview **Writing hooks IS creating automated quality gates.** Hooks run on Claude Code events (PreToolUse, PostToolUse, etc.) and can block actions with exit code 2. **Core principle:** Hooks enforce what humans forget. Fast checks only—slow hooks kill productivity. **Violating the letter of the rules is violating the spirit of the rules.** ## Task Initialization (MANDATORY) Before ANY action, create task list using TaskCreate: ``` TaskCreate for EACH task below: - Subject: "[writing-hooks] Task N: <action>" - ActiveForm: "<doing action>" ``` **Tasks:** 1. Analyze requirements 2. RED - Test without hook 3. GREEN - Write hook script 4. Configure settings.json 5. Validate behavior 6. Test blocking Announce: "Created 6 tasks. Starting execution..." **Execution rules:** 1. `TaskUpdate status="in_progress"` BEFORE starting each task 2. `TaskUpdate status="completed"` ONLY after verification passes 3. If task fails → stay in_progress, diagnose, retry 4. NEVER skip to next task until current is completed 5. At end, `TaskList` to confirm all completed ## TDD Mapping for Hooks | TDD Phase | Hook Creation | What You Do | |-----------|---------------|-------------| | **RED** | Test without hook | Write code, observe quality issues slip through | | **Verify RED** | Document violations | Note specific issues that should be caught | | **GREEN** | Write hook | Create script that catches those issues | | **Verify GREEN** | Test blocking | Verify exit code 2 blocks violating code | | **REFACTOR** | Optimize speed | Reduce hook runtime, filter file types | ## Task 1: Analyze Requirements **Goal:** Understand what quality gate to create. **Questions to answer:** - What violation should be blocked? - Which files should be checked? - What tool/command performs the check? - What event triggers the hook? **Event Selection:** | Event | When | Use For | |-------|------|---------| | `PreToolUse` | Before tool runs | Block bad writes before they happen |