Skip to content

[FEATURE] Add --no-hooks flag to claude -p (non-interactive mode without breaking OAuth/subscription auth) #48840

@kamegg13

Description

@kamegg13

Problem

When running `claude -p` in headless/scripted mode, there is no clean way to disable hooks without also losing OAuth subscription auth.

The only current option to skip hooks is `--bare`, but `--bare` deliberately ignores OAuth tokens and requires `ANTHROPIC_API_KEY` — which means paying per-token even if you have a Pro/Max/Team subscription.

This creates a forced tradeoff:

Goal Flag Side effect
Disable hooks `--bare` ❌ Breaks OAuth, requires API key
Keep OAuth subscription (no flag) ❌ Hooks always run
Disable hooks + keep OAuth Impossible today

The workaround — creating a custom `settings.json` with `disableAllHooks: true` and passing `--settings ./no-hooks.json` — works but is awkward for scripted environments and requires managing an extra file per project.

Concrete use case

I run Claude as an autonomous agent triggered by Dagster pipeline failures on my local machine. The sensor posts to a local FastAPI webhook, which calls:

```bash
claude -p
--model sonnet
--max-turns 15
--allowedTools "Read" "Edit" "Bash(git *)" "Bash(gh pr create *)"
"Job failed: $JOB_NAME — Error: $ERROR. Read logs, fix the code, open a PR."
```

I want this to:

  • ✅ Use my existing Max subscription (not burn API credits)
  • ✅ Skip all hooks (session-start hooks, stop hooks, etc. are irrelevant in automated context)
  • ✅ Be a one-liner, not require a settings file sidecar

Today this is impossible. `--bare` solves hooks but kills OAuth. `--settings` solves it but adds file management overhead.

Proposed solution

Add a `--no-hooks` flag that:

  • Skips all hook execution (PreToolUse, PostToolUse, Stop, etc.)
  • Does not affect the auth chain — OAuth subscription still works normally
  • Is composable with all existing `-p` flags

```bash

Desired behavior

claude -p --no-hooks --model sonnet --max-turns 10 "query"

→ runs with subscription auth, no hooks fired

```

Internally this is equivalent to injecting `{ "disableAllHooks": true }` into the effective settings without touching the auth stack — which `--bare` does too aggressively.

Why this matters

The headless use case (`claude -p`) is increasingly used for:

  • Webhook-triggered autonomous agents (CI, monitoring, on-call)
  • Local automation scripts replacing cron jobs
  • Pipe-based scripting (`cat logs | claude -p "summarize"`)

In all these contexts, hooks are irrelevant or actively harmful (they add latency, side effects, and are designed for interactive sessions). But these users often have subscriptions — they should not be forced onto the per-token API key model just to avoid hooks.

Alternatives considered

Option Works? Drawback
`--bare` Hooks disabled ✅ OAuth broken ❌
`--settings ./no-hooks.json` Both work ✅ Extra file to manage, not composable inline ❌
`ANTHROPIC_API_KEY` env var Works ✅ Pays per-token, bypasses subscription ❌
`--no-hooks` (proposed) Both work ✅

Related

  • The `disableAllHooks` setting already exists in `settings.json` — this flag would just expose it as a CLI argument, consistent with how `--tools ""` exposes tool restrictions inline.

Metadata

Metadata

Assignees

No one assigned

    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