Skip to content

bypassPermissions mode does not execute settings.json shell hooks #768

@jeremy-newhouse

Description

@jeremy-newhouse

Description

When using permission_mode="bypassPermissions", shell hooks configured in ~/.claude/settings.json are never executed. The PreToolUse hook for AskUserQuestion (configured as a shell command) never fires.

Steps to Reproduce

  1. Configure a PreToolUse hook in ~/.claude/settings.json:
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "AskUserQuestion",
      "hooks": [{"type": "command", "command": "/path/to/hook.sh"}]
    }]
  }
}
  1. Run a query that triggers AskUserQuestion:
options = ClaudeAgentOptions(
    permission_mode="bypassPermissions",
    cli_path="/home/tester/.local/bin/claude",
)
async for msg in query(prompt="Ask my name with AskUserQuestion", options=options):
    pass
  1. The hook script is never called (verified via logs and lack of HTTP calls from the hook).

The same hook fires correctly when running claude --print --dangerously-skip-permissions -p "..." directly.

Expected Behavior

Shell hooks from settings.json should still fire in bypassPermissions mode. Permission bypass should skip the interactive permission prompt, not skip all hooks.

Workaround

Use Python hook callbacks via the hooks parameter in ClaudeAgentOptions instead of shell hooks in settings.json.

Environment

  • claude-agent-sdk: 0.1.51
  • Claude CLI: 2.1.86
  • Python: 3.12
  • OS: Linux (Docker)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions