[BUG] PreToolUse hook does not block tool use

Resolved 💬 2 comments Opened Jul 25, 2025 by moltar Closed Jul 26, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.60 (Claude Code)
  • Operating System: macOS
  • Terminal: iTerm2

Bug Description

The hook runs, but it does not block execution.

Steps to Reproduce

I have a hook configure likeso:

  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/noecho.ts"
          }
        ]
      }
    ]
  },

The hook is a pretend use case to block echo executions.

I prompted claude code with:

run a bash command "echo 1"

And it executed the command:

⏺ Bash(echo 1)
  ⎿  1

I logged the event:

{
  "session_id": "c7439455-a23e-46b8-ac11-2b294fab8009",
  "transcript_path": "{SNIP}/c7439455-a23e-46b8-ac11-2b294fab8009.jsonl",
  "cwd": "{SNIP}",
  "hook_event_name": "PreToolUse",
  "tool_name": "Bash",
  "tool_input": {
    "command": "echo 1",
    "description": "Echo the number 1"
  }
}

If I pipe the same event to the hook:

echo '{EVENT}' | .claude/hooks/noecho.ts

I get this:

{
  "response": {
    "decision": "block",
    "reason": "reason",
    "continue": false
  }
}

Expected Behavior

Command to be blocked.

Actual Behavior

Command is executed.

Additional Context

N/A

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗