Warn Loudly on bypassPermissions Mode at Session Start

Every PreToolUse hook in this catalog only runs because the permission system calls it — `bypassPermissions` mode skips that entirely. This can't block the mode from applying (SessionStart has no blocking support), but it makes sure a human actually sees that it's active, the same spirit as the existing auto-approved-MCP warning.

Model & Permission Governance Event: SessionStart Claude Code Open source · Free

1. Save this as the hook script

#!/usr/bin/env python3
"""SessionStart hook — warns if the session is running in
bypassPermissions mode. Non-blocking (exit 1): visible, doesn't stop the
session."""
import json, sys

data = json.load(sys.stdin)
mode = data.get("permission_mode", "")

if mode == "bypassPermissions":
    print("WARNING: this session is running in bypassPermissions mode — "
          "every PreToolUse/PermissionRequest hook in this project is being "
          "skipped. Confirm this is intentional.", file=sys.stderr)
    sys.exit(1)

sys.exit(0)

Save to a path inside your project, e.g. .claude/hooks/warn-on-bypass-permissions-mode.sh, then chmod +x it.

2. Wire it into .claude/settings.json

{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {"type": "command", "command": "python3 .claude/hooks/warn-on-bypass-permissions-mode.py"}
        ]
      }
    ]
  }
}

Before you use this

A hook runs with your local shell's permissions — review the script above before adding it, the same way you'd review any script you didn't write yourself. See our guide on hook security risks for the specific CVEs this category of feature has already produced.

Related hooks

← All hooks
FEEDBACK