Claude Code: --dangerously-skip-permissions cannot be used with root

Claude Code refuses to bypass its permission checks when it runs as the root user, or under sudo. The exact message, why Claude Code prints it, and the fix.

Updated November 23, 2026 · Checked against Claude Code 2.1.308, reproduced in EnvHaven 1.9.0

The message

--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons

What it means

Claude Code refuses to bypass its permission checks when it runs as the root user, or under sudo. Containers often run as root by default, which is where most people meet this.

Fix

  1. Run Claude Code as an ordinary user: create one (useradd -m dev) and run claude as that user.
  2. In a Dockerfile, add a non-root user and switch to it with USER dev before the command that starts Claude Code.
  3. If you only need fewer prompts rather than none, use --permission-mode acceptEdits, which works as root.

In an EnvHaven workspace

No. Workspaces run agents as the unprivileged abc user, and Claude Code starts in bypass mode there without this error.

Where this comes from

This message was produced by Claude Code (Claude Code 2.1.308) itself, in a throwaway EnvHaven 1.9.0 container, on 2026-11-23; the text above is copied from that output.