Claude Code --dangerously-skip-permissions: What It Skips and What Still Applies

aidockersecurityself-hosting
Claude Code --dangerously-skip-permissions: What It Skips and What Still Applies

--dangerously-skip-permissions turns off permission prompts in Claude Code. Claude Code refuses it as root, so run it as a normal user. Deny rules and hooks still apply, but the agent can delete rules kept in the project's settings. Keep the rules you rely on in a root-owned managed settings file.

As root, Claude Code refused the flag. An undocumented environment variable switched that refusal off:

Terminal in the dev container as root. Claude Code with dangerously-skip-permissions prints that it cannot be used with root or sudo privileges and exits 1. The same command started with IS_SANDBOX=1 prints OK and exits 0.

The tests ran on November 20, 2026, in a dev container based on Anthropic's reference container, with Claude Code 2.1.329. The host was a 2 vCPU / 8 GB Ubuntu 24.04 VPS with Docker 29.10. The test sessions used print mode (claude -p, which runs one prompt and exits), and I didn't test macOS.

What Does dangerously-skip-permissions Do in Claude Code?

Claude Code normally asks before it runs a command or edits a file. The flag starts the session in bypassPermissions mode, where tool calls run right away. The permission modes docs say it equals --permission-mode bypassPermissions. --allow-dangerously-skip-permissions only adds the mode to the Shift+Tab cycle.

The first interactive start in this mode shows a warning, and the selected answer is to exit (Claude Code 2.1.330, November 22):

Claude Code's warning. In Bypass Permissions mode it will not ask for approval before running potentially dangerous commands, and the mode should only be used in a sandboxed container or VM that has restricted internet access and can easily be restored if damaged. No, exit is selected, with Yes, I accept below it.

The flag turns off more than the prompts:

Two columns. Turned off by the flag: permission prompts, protected-path checks for .git, .claude and .vscode, and allow rules, which no longer matter. Still enforced: deny rules, PreToolUse hooks, root-owned managed settings in /etc/claude-code, and the refusal to run as root, which IS_SANDBOX=1 removes. A note below says the project settings file is a file the agent can edit, and in the test it deleted its own deny rule and the next session ran curl.

Bypass mode also skips the check on protected paths, where Claude Code asks even when other edits are approved. They include .git, .claude, .devcontainer, .vscode, and .mcp.json. With the flag on, the Write tool created .git/hooks/pre-commit and .claude/notes.txt without a prompt. The Write tool can't make the hook executable, but a Bash chmod +x can. In a dev container the repo is shared with the host, so that hook can run on the host the next time you commit there.

Why Does Claude Code Say dangerously-skip-permissions Cannot Be Used With Root/Sudo?

The docs say Claude Code refuses this flag as root on Linux and macOS, and sudo makes it root too. The long form, --permission-mode bypassPermissions, failed with the same error.

The fix is a non-root user. The dev container's Dockerfile creates a claude user and switches to it before installing Claude Code:

# Claude Code refuses to skip permissions as root, so it runs as this user.
# The base image's ubuntu user holds UID 1000, which the Dev Containers CLI
# needs free to give claude the same UID as the owner of your repo on the host.
RUN userdel --remove ubuntu \
    && useradd --create-home --shell /bin/bash claude \
    && mkdir -p /workspace /home/claude/.claude \
    && chown -R claude:claude /workspace /home/claude/.claude

USER claude
RUN curl -fsSL https://claude.ai/install.sh | bash

The full file is in the complete dev container.

What Is IS_SANDBOX=1 in Claude Code?

Some posts about the root error suggest setting IS_SANDBOX=1, and in my test it removed the root check (the screenshot at the top). The Claude Code docs don't mention the variable, only that the check is skipped inside a recognized sandbox. An undocumented switch can change in any release, so run Claude Code as a normal user instead.

My root runs also left three root-owned files in the claude user's config volume at /home/claude/.claude. They were a session transcript and two plugin files. Find and fix them with:

docker exec -u root <container> find /home/claude/.claude -not -user claude
docker exec -u root <container> chown -R claude:claude /home/claude/.claude

After the chown, find printed nothing, and claude auth status still showed the login.

Do Deny Rules Work With dangerously-skip-permissions?

Yes. A deny rule is a settings entry that blocks matching tool calls. A PreToolUse hook is a command Claude Code runs before each matching tool call, and exit code 2 blocks the call.

I put two deny rules and one hook in a test project's .claude/settings.json:

{
  "permissions": {
    "deny": ["Bash(curl:*)", "Read(./secret.txt)"]
  },
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r .tool_input.command | grep -qE \"^rm( |$)\" && { echo \"rm is blocked by a hook\" >&2; exit 2; } || exit 0"
          }
        ]
      }
    ]
  }
}

The hook only matches commands that start with rm, so it is a demo and would miss /bin/rm. With the flag on, I asked Claude to run curl, read secret.txt, delete a file with rm, and run ls:

Claude's own report with permissions skipped: steps 1 to 3 were blocked and only step 4 ran. The curl command was denied by a deny rule, reading secret.txt was denied by a deny rule, and rm was blocked by the PreToolUse hook.

The docs say deny rules block in every mode, and allow rules have no effect in bypass mode.

Can Claude Code Remove Its Own Deny Rules?

Yes, when they live in the project, because the settings file is part of the repo. I started a fresh project with only the Bash(curl:*) deny rule and asked Claude, with the flag on, to remove it:

Terminal in the dev container. In the first session Claude reports it removed the curl deny rule, and the settings file now shows an empty deny list. In the second session Claude runs curl against api.github.com/zen and prints Encourage flow.

The edit took one tool call. The next session ran the curl command the rule used to block.

Where Should the Rules You Rely On Live?

Put them in managed settings, a policy file your own settings files can't override. On Linux, Claude Code reads it from /etc/claude-code/managed-settings.json. This command creates it as root in the container, readable by everyone and writable only by root:

docker exec -u root <container> bash -c 'mkdir -p /etc/claude-code && printf "{\n  \"permissions\": { \"deny\": [\"Bash(curl:*)\"] }\n}\n" > /etc/claude-code/managed-settings.json && chmod 644 /etc/claude-code/managed-settings.json && ls -l /etc/claude-code'

Then I asked Claude, with the flag on, to run curl and to edit the managed file to remove the rule:

Terminal in the dev container. The managed settings file is owned by root with mode 644. With permissions skipped, Claude says it will do step 1 but not step 2, step 1 was denied by the permission system, and it won't do step 2. The managed file still holds the curl deny rule.

The model declined to edit the file. Root owns it with mode 0644, and the agent's user can only use sudo for the firewall script, so file permissions should stop a direct write.

A file created with docker exec is gone after a rebuild. To keep it, put managed-settings.json next to the Dockerfile and add this line before USER claude (I didn't test this line):

COPY managed-settings.json /etc/claude-code/managed-settings.json

The docs also describe "disableBypassPermissionsMode": "disable" under permissions, which makes Claude Code reject the flag. Dev container vs sandbox explains why a container beats the built-in sandbox, and the firewall guide covers what still gets out. Remote Control takes the same mode through --permission-mode bypassPermissions.

Summary

--dangerously-skip-permissions turns off prompts and protected-path checks, and it refuses root unless the undocumented IS_SANDBOX=1 is set. Deny rules and PreToolUse hooks still apply in bypass mode. The agent removed a project deny rule with one edit, while the same rule in a root-owned managed file held. Run Claude Code as a non-root user in a container, and keep every rule you depend on where that user can't write.

My self-hosting course covers setting up and securing the VPS these containers run on.

Thanks for reading.

And stay awesome!


Frequently Asked Questions

What does dangerously-skip-permissions do in Claude Code?

It starts Claude Code in bypassPermissions mode, so tool calls run without permission prompts, including writes to protected paths such as .git and .claude. Deny rules, PreToolUse hooks, and managed settings still apply, and allow rules stop mattering.

Why does Claude Code say dangerously-skip-permissions cannot be used with root/sudo?

On Linux and macOS, Claude Code refuses to skip permissions when it runs as root, and it exits with code 1. The fix is to run it as a non-root user, for example a dedicated user inside a dev container.

What is IS_SANDBOX=1 in Claude Code?

It is an environment variable that removed the root check in testing, so the flag ran as root. It is not documented anywhere in the Claude Code docs, so it can change without notice. Run Claude Code as a non-root user instead.

Do deny rules work with dangerously-skip-permissions?

Yes. In testing, deny rules for a curl command and for reading a file both blocked the call in bypass mode, and a PreToolUse hook blocked rm. The docs say deny rules block in every mode.

Can Claude Code remove its own deny rules?

Yes, if they live in the project. In bypass mode Claude edited .claude/settings.json, emptied the deny list, and the next session ran the blocked command. Put rules you rely on in a root-owned managed settings file instead.

Browse all Self-Hosting guides →
Loading comments...

Whenever you're ready, there are 5 ways I can help you:

  1. Pragmatic Self-Hosting: Learn to deploy and run your apps on a VPS with Dokploy and Tailscale. Keep administration private, automate releases, and practice restoring backups, with source code and a runbook you can reuse.
  2. Pragmatic Clean Architecture: Join 5,000+ students in this comprehensive course that will teach you the system I use to ship production-ready applications using Clean Architecture. Learn how to apply the best practices of modern software architecture.
  3. Modular Monolith Architecture: Join 2,800+ engineers in this in-depth course that will transform the way you build modern systems. You will learn the best practices for applying the Modular Monolith architecture in a real-world scenario.
  4. Pragmatic REST APIs: Join 1,900+ students in this course that will teach you how to build production-ready REST APIs using the latest ASP.NET Core features and best practices. It includes a fully functional UI application that we'll integrate with the REST API.
  5. Patreon Community: Join a community of 5,000+ engineers and software architects. You will also unlock access to the source code I use in my YouTube videos, early access to future videos, and exclusive discounts for my courses.

The .NET Weekly

One practical .NET tip, every Saturday.

Join 66,000+ engineers who read it. Free, and you can unsubscribe any time.