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.
Limited to specific tools
Additional assets for this skill
This 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.
This is the single source of truth for hook environment variable patterns.
All hooks in this repository use a consistent environment variable convention:
| Variable Pattern | Purpose | Default | Values |
|---|---|---|---|
CLAUDE_HOOK_{NAME}_ENABLED | Enable/disable hook | Varies by hook | 1/true to enable, 0/false to disable |
CLAUDE_HOOK_ENFORCEMENT_{NAME} | Control enforcement behavior | warn | block, warn, log |
CLAUDE_HOOK_LOG_LEVEL | Logging verbosity | info | debug, info, warn, error |
CLAUDE_HOOK_DEBUG | Debug mode for hooks | Off | 1 to enable |
Hook Default States:
| Category | Hooks | Default | Rationale |
|---|---|---|---|
| Essential | inject-current-date, prevent-backup-files, suggest-docs-delegation, suggest-gemini-docs | Enabled | Low overhead, useful utilities |
| Opt-in | markdown-lint | Disabled | Requires external tooling (markdownlint-cli2) |
| Log Events | All log-* hooks | Disabled | Requires master toggle, can be noisy |
Log Events Special Logic:
CLAUDE_HOOK_LOG_EVENTS_ENABLED controls ALL log hooks:
- If NOT set or "0"/"false": ALL log events disabled (no exceptions)
- If "1" or "true": ALL log events enabled by default
- Individual events can be disabled: CLAUDE_HOOK_LOG_{EVENT}_ENABLED=0
Example: Configure via settings.json:
{
"env": {
"CLAUDE_HOOK_MARKDOWN_LINT_ENABLED": "1",
"CLAUDE_HOOK_LOG_EVENTS_ENABLED": "1",
"CLAUDE_HOOK_LOG_PRETOOLUSE_ENABLED": "0"
}
}
Disable ALL hooks:
Edit .claude/hooks/config/global.yaml:
enabled: false
Changes take effect immediately on next hook execution.
Disable specific hook:
Edit .claude/hooks/<hook-name>/config.yaml:
enabled: false
Change enforcement level:
enforcement: warn # Options: block, warn, log
Changes take effect immediately on next hook execution.
For complete configuration guide, 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 these shared helper functions:
Note: These bash utilities are maintained for legacy compatibility. New hooks should use .NET file-based apps (see
DOTNET-HOOK-MIGRATION.md) or Python with pathlib for cross-platform compatibility.
For usage examples, see Best Practices.
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:
- **Automated enforcement via hooks**: Critical rules enforced automatically via hook-management skill.
| CLAUDE.md Line | Rule | Hook |
|---|---|---|
| 52 | GPG signing required | require-gpg-signing |
| 53 | Git commits via skill | require-explicit-commit |
| 54 | No .bak files | prevent-backup-files |
| 57 | No absolute paths | block-absolute-paths |
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 commandDetailed 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