Central authority for Claude Code hooks management in this repository. Automates enforcement of critical repository rules through hooks. Use when adding hooks, managing hooks, configuring hooks, troubleshooting hooks, or understanding hook behavior. Delegates to docs-management skill for official hooks documentation. Provides organization-specific patterns, configuration management, and workflow guidance.
Central authority for managing Claude Code hooks in this repository. Use when adding, configuring, troubleshooting hooks, or enforcing repository rules through PreToolUse/PostToolUse automation.
/plugin marketplace add melodic-software/claude-code-plugins/plugin install claude-code-observability@melodic-softwareThis skill is limited to using the following tools:
references/architecture/design-principles.mdreferences/architecture/multi-language-strategy.mdreferences/audit-framework.mdreferences/configuration/hook-config-guide.mdreferences/development/best-practices.mdreferences/development/creating-hooks-workflow.mdreferences/development/testing-guide.mdreferences/inventory/active-hooks.mdreferences/inventory/hook-lifecycle.mdreferences/troubleshooting/common-issues.mdreferences/troubleshooting/debugging-guide.mdSTOP - Before providing ANY response about Claude Code hooks:
- INVOKE
docs-managementskill- QUERY using keywords: hooks, PreToolUse, PostToolUse, hook events, hook configuration, or related topics
- BASE all responses EXCLUSIVELY on official documentation loaded
Skipping this step results in outdated or incorrect information.
Before responding, verify:
If ANY checkbox is unchecked, STOP and invoke docs-management first.
Central authority for managing Claude Code hooks in this repository. Automates enforcement of critical repository rules that were previously manual in CLAUDE.md.
Architecture: Vertical slice organization with externalized configuration, multi-language support, immediate config reload, and comprehensive testing.
Keywords: hooks, hook management, automation, validation, enforcement, PreToolUse, PostToolUse, SessionEnd, hook configuration, plugin hooks, local hooks, CLAUDE_HOOK_ENABLED, hook environment variables, enable hook, disable hook
Use this skill when:
For ALL Claude Code hooks capabilities, configuration patterns, and syntax, you MUST use the docs-management skill.
ALWAYS use docs-management for:
Keywords for docs-management searches:
Organization-specific implementation:
What do you want to do?
plugin-development skill (see below)If you're working with plugin hooks (hooks bundled in a Claude Code plugin), use the plugin-development skill instead. Plugin hooks use a different configuration pattern:
| Aspect | Local Hooks (this skill) | Plugin Hooks |
|---|---|---|
| Location | .claude/hooks/ directory | Plugin hooks/hooks.json |
| Configuration | YAML files (config.yaml) | Environment variables |
| Consumer Control | Edit config files directly | Via settings.json env section |
For plugin hooks: Invoke plugin-development skill and see the Plugin Hook Configuration section.
All references in this skill are conditional load - they are loaded only when needed based on the workflow you're following.
Architecture References (load when understanding design):
references/architecture/design-principles.md → When understanding vertical slice, DRY, config-over-hardcoding principlesreferences/architecture/multi-language-strategy.md → When implementing or migrating to Python/TypeScriptInventory References (load when working with hooks):
references/inventory/active-hooks.md → When reviewing what hooks are active and their configurationsreferences/inventory/hook-lifecycle.md → When enabling/disabling hooks or changing enforcement modesConfiguration References (load when configuring):
references/configuration/hook-config-guide.md → When modifying global.yaml or config.yaml filesDevelopment References (load when creating/testing):
references/development/creating-hooks-workflow.md → When creating a new hook from scratchreferences/development/testing-guide.md → When writing tests for hooksreferences/development/best-practices.md → When ensuring code quality and following patternsTroubleshooting References (load when debugging):
references/troubleshooting/common-issues.md → When encountering problems (hook not running, config not applying, etc.)references/troubleshooting/debugging-guide.md → When performing advanced debugging or profilingdocs-management skill queries (always)This architecture ensures optimal token efficiency while maintaining comprehensive guidance coverage.
For complete details, see Active Hooks Reference.
All hooks use environment variables for configuration. See Configuration Guide for complete details.
Quick actions:
CLAUDE_HOOK_{NAME}_ENABLED=1 in .claude/settings.json env sectionCLAUDE_HOOK_{NAME}_ENABLED=0 or remove the variableCLAUDE_HOOK_ENFORCEMENT_{NAME} to block, warn, or logCLAUDE_HOOK_DEBUG=1Example configuration in .claude/settings.json:
{
"env": {
"CLAUDE_HOOK_MARKDOWN_LINT_ENABLED": "1",
"CLAUDE_HOOK_LOG_EVENTS_ENABLED": "1"
}
}
For environment variable patterns, default states, and legacy YAML configuration, see Configuration Reference.
.claude/hooks/
├── config/
│ └── global.yaml # Shared configuration
├── shared/ # Shared utilities (all hooks)
│ ├── json-utils.sh # JSON parsing helpers
│ ├── path-utils.sh # Path manipulation utilities
│ ├── config-utils.sh # Config loading utilities
│ └── test-helpers.sh # Test assertion framework
├── prevent-backup-files/ # Vertical slice: Hook 1
│ ├── bash/ # Language-specific implementation
│ ├── config.yaml # User configuration (enabled, enforcement)
│ ├── hook.yaml # Hook metadata (name, version, description)
│ ├── README.md # Hook documentation
│ └── tests/ # Tests for THIS hook
├── require-gpg-signing/ # Vertical slice: Hook 2
│ ├── bash/
│ ├── config.yaml
│ ├── hook.yaml
│ ├── README.md
│ └── tests/
├── <other-hooks>/ # Additional hooks follow same pattern
├── test-runner.sh # Discovers & runs all *.test.sh files
└── README.md # Quick reference
Key principles:
For complete architecture details, see Design Principles.
All hooks have access to shared helper functions in .claude/hooks/shared/. See Best Practices for usage examples.
Note: Bash utilities maintained for legacy compatibility. New hooks should use Python with pathlib for cross-platform compatibility.
Disable all hooks temporarily:
# Edit .claude/hooks/config/global.yaml
enabled: false
View hook activity:
# Edit .claude/hooks/config/global.yaml
log_level: debug
Run all tests:
bash .claude/hooks/test-runner.sh
Test specific hook:
bash .claude/hooks/<hook-name>/tests/integration.test.sh
Test manually:
echo '{"tool": "Write", "file_path": "test.txt"}' | \
bash .claude/hooks/<hook-name>/bash/<hook-name>.sh
For complete workflow guidance, see Hook Lifecycle.
CLAUDE.md references hooks for automated enforcement. See Active Hooks for the complete list of rules automated by hooks.
This skill provides the validation criteria used by the hook-auditor agent for formal audits.
| Resource | Location | Purpose |
|---|---|---|
| Audit Framework | references/audit-framework.md | Query guides and scoring criteria |
| Category | Points | Key Criteria |
|---|---|---|
| Configuration Structure | 25 | Valid hooks.json, required fields, valid event types |
| Hook Scripts | 20 | Scripts exist, proper structure, exit codes |
| Matchers | 20 | Appropriate tool/path matchers |
| Environment Variables | 15 | Follows naming convention, documented |
| Testing | 20 | Has tests, tests pass, adequate coverage |
Thresholds: 85+ = PASS, 70-84 = PASS WITH WARNINGS, <70 = FAIL
The hook-auditor agent (Haiku model) performs formal audits using this skill:
skills: hook-management/audit-hooks commandWhen auditing hooks that use external technologies (scripts, packages, runtimes), the auditor MUST validate claims using MCP servers before flagging findings.
Technologies Requiring MCP Validation:
Validation Rule:
Never flag a technology usage as incorrect without first:
Stale Data Warning:
Detailed Documentation:
Quick Access:
.claude/hooks/.claude/hooks/shared/ (includes unit tests).claude/hooks/config/global.yaml.claude/hooks/README.md.claude/hooks/test-runner.shQuery: "Use the hook-management skill to add a new hook"
Expected Behavior:
Success Criteria: User receives step-by-step guidance for hook creation
Query: "My hook isn't running, help me debug it"
Expected Behavior:
Success Criteria: User identifies and resolves hook execution issue
Query: "How do I disable the GPG signing hook?"
Expected Behavior:
Success Criteria: User successfully disables specific hook
Query: "Explain the hooks directory structure"
Expected Behavior:
Success Criteria: User understands hook organization principles
Query: "What hook events are available in Claude Code?"
Expected Behavior:
Success Criteria: User receives current official documentation via docs-management
v1.3.0 (2025-12-01): Environment variable standardization
CLAUDE_HOOK_{NAME}_ENABLED patternv1.2.2 (2025-11-30): Plugin hooks delegation
.claude/hooks/), plugin hooks use different patternsv1.2.1 (2025-11-25): Audit improvements
v1.2.0 (2025-11-24): Configuration architecture clarification
config.yaml (user config) and hook.yaml (metadata)config.yaml for runtime configurationv1.1.0 (2025-11-18): Progressive disclosure refactoring
v1.0.0 (2025-11-18): Initial release
Date: 2025-12-01 Model: claude-opus-4-5-20251101
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.