ClaudeSuperPower
P

PreToolUse (Write|Edit|Bash)

Hook

Fires on

PreToolUsematchingWrite|Edit|Bash

Immediately before a tool runs — this is where an action can be denied.

Where this sits in a session

  1. Session start
  2. Prompt submitted
  3. Prompt expansion
  4. Before tool use
  5. After tool use
  6. Notification
  7. Before compaction
  8. Subagent finished
  9. Turn finished
  10. Session end

Can blockThis hook is able to deny the action or send Claude back to work.

What it runs

Executed automatically when the event fires — no prompt, no confirmation.

command
bash "${CLAUDE_PLUGIN_ROOT}/scripts/hook.sh" claude PreToolUse

Install it yourself

Paste into .claude/settings.json to run this hook without installing the whole plugin. Adjust the paths to point at your own copy of the scripts.

settings.json
{
  "hooks": {
    "PreToolUse": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/hook.sh\" claude PreToolUse"
          }
        ],
        "matcher": "Write|Edit|Bash"
      }
    ]
  }
}

Source

Read this before installing — it runs on your machine with your permissions.

#!/bin/bash
DIR="$(cd "$(dirname "$0")" && pwd)"

if [[ -n "$WSL_DISTRO_NAME" ]]; then
  exec "$DIR/hook-windows-amd64.exe" "$@"
fi

case "$OSTYPE" in
  darwin*)
    case "$HOSTTYPE" in
      arm64) exec "$DIR/hook-darwin-arm64" "$@" ;;
      aarch64) exec "$DIR/hook-darwin-arm64" "$@" ;;
      *)     exec "$DIR/hook-darwin-amd64" "$@" ;;
    esac ;;
  linux*)
    case "$HOSTTYPE" in
      aarch64) exec "$DIR/hook-linux-arm64" "$@" ;;
      *)       exec "$DIR/hook-linux-amd64" "$@" ;;
    esac ;;
  msys*|cygwin*)
    exec "$DIR/hook-windows-amd64.exe" "$@" ;;
  *)
    echo "unsupported platform: OSTYPE=$OSTYPE" >&2
    exit 2 ;;
esac

Shipped by 1 plugin

Installing any of these installs this hook.

Reviews

Log in to leave a review.

No reviews yet — be the first.

Explore related

Other things in this space — across every part of the ecosystem, not just hooks.