Summary
Multiple issues with the Claude Code hooks system preventing proper validation and blocking of unsafe operations.
Environment
- Platform: macOS (Darwin 24.5.0)
- Claude Code Version: 1.0.38 (Claude Code)
- Working Directory: Git repository
- Configuration File:
.claude/settings.local.json
Issues Identified
1. Template Variable Interpolation Failure
Expected: Template variables like {{tool.name}}, {{timestamp}}, and {{tool.input.file_path}} should be replaced with actual values.
Actual: Template variables appear literally in executed commands.
Evidence:
# Debug log shows literal template variables instead of interpolated values
$ tail /tmp/claude-hook-debug.log
[DEBUG] Hook fired for tool: {{tool.name}} at {{timestamp}}
[DEBUG] Hook fired for tool: {{tool.name}} at {{timestamp}}
2. Hook Configuration Changes Not Respected
Expected: Changes to .claude/settings.local.json should take effect after Claude Code restart.
Actual: Configuration changes are ignored; old hook behavior persists even after restart.
Evidence:
- Modified hook configuration multiple times
- Restarted Claude Code after each change
- Old debug hook continues executing despite being removed from config
- New simple test hooks never execute
3. Hook Commands Not Blocking Operations
Expected: When a PreToolUse hook command exits with non-zero status, the tool operation should be blocked.
Actual: Tool operations proceed regardless of hook command exit status.
Evidence:
- Created validation script that exits with code 1 on unsafe patterns
- Hook wrapper correctly returns exit code 1 when validation fails
- File operations still succeed despite validation failures
Configuration Tested
Final Hook Configuration
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "echo 'Write hook fired' >> /tmp/claude-simple-test.log"
}
]
}
]
}
}
Validation Script
- Created working validation script that detects unsafe patterns
- Returns proper exit codes (0 for safe, 1 for unsafe)
- Tested independently - works correctly outside Claude Code
Steps to Reproduce
- Create
.claude/settings.local.json with PreToolUse hooks
- Configure hooks with template variables and command that can fail
- Restart Claude Code
- Perform Write/Edit operations that should trigger hooks
- Observe that:
- Template variables aren't interpolated
- Hook commands execute but don't block operations
- Configuration changes aren't respected
Expected Behavior
- Template variables should be replaced with actual values
- Hook configuration changes should take effect after restart
- PreToolUse hooks returning non-zero exit codes should block tool operations
- Hooks should provide effective validation/blocking capabilities
Workarounds Implemented
Since Claude Code hooks are not functional, we've implemented alternative safeguards:
- ESLint rules with custom patterns detection
- Pre-commit hooks for validation
- Git safety rules to prevent bypassing quality gates
Request
Please investigate and fix the Claude Code hooks system to enable proper validation and blocking of unsafe operations as documented.
Summary
Multiple issues with the Claude Code hooks system preventing proper validation and blocking of unsafe operations.
Environment
.claude/settings.local.jsonIssues Identified
1. Template Variable Interpolation Failure
Expected: Template variables like
{{tool.name}},{{timestamp}}, and{{tool.input.file_path}}should be replaced with actual values.Actual: Template variables appear literally in executed commands.
Evidence:
2. Hook Configuration Changes Not Respected
Expected: Changes to
.claude/settings.local.jsonshould take effect after Claude Code restart.Actual: Configuration changes are ignored; old hook behavior persists even after restart.
Evidence:
3. Hook Commands Not Blocking Operations
Expected: When a PreToolUse hook command exits with non-zero status, the tool operation should be blocked.
Actual: Tool operations proceed regardless of hook command exit status.
Evidence:
Configuration Tested
Final Hook Configuration
{ "hooks": { "PreToolUse": [ { "matcher": "Write", "hooks": [ { "type": "command", "command": "echo 'Write hook fired' >> /tmp/claude-simple-test.log" } ] } ] } }Validation Script
Steps to Reproduce
.claude/settings.local.jsonwith PreToolUse hooksExpected Behavior
Workarounds Implemented
Since Claude Code hooks are not functional, we've implemented alternative safeguards:
Request
Please investigate and fix the Claude Code hooks system to enable proper validation and blocking of unsafe operations as documented.