Claude Code dangerously-skip-permissions: When It's Safe

--dangerously-skip-permissions is the Claude Code flag that turns off permission prompts. Most pages about it stop at "YOLO mode, use Docker", and most predate the current permission system, which now has six modes, a classifier-driven auto mode and a list of actions no mode will approve. This is the reference we wanted when we started running Claude Code unattended: what the flag skips, what it still blocks, how to turn it on everywhere, how to fix it when it still asks, and what to pick instead. Every behavior marked as tested comes from 24 runs we made on 2026-10-20 with Claude Code 2.1.304, in disposable Docker containers; the rest is quoted from the official docs, with the link.

The short answer: claude --dangerously-skip-permissions is the same as claude --permission-mode bypassPermissions. Use it only inside a container, a VM or the sandbox runtime, as a non-root user, with nothing in reach that you can't afford to lose or leak.

What --dangerously-skip-permissions does

The command, and its long form

claude --dangerously-skip-permissions
# same thing:
claude --permission-mode bypassPermissions

The CLI reference describes the flag as "Skip permission prompts. Equivalent to --permission-mode bypassPermissions." In practice, file edits, shell commands, web fetches, MCP tools and subagents run without asking. In our test, a subagent started with the Agent tool ran uname -s > sub.txt without a prompt: subagents inherit the parent's mode since v2.1.98.

Where it sits among the six permission modes

Mode What runs without a prompt How to start it
default (shown as Manual) Reads only --permission-mode default (or manual)
acceptEdits Reads, file edits, common filesystem commands (mkdir, touch, mv, cp) --permission-mode acceptEdits, Shift+Tab
plan Reads, plus classifier-approved commands when auto mode is available --permission-mode plan, Shift+Tab
auto Everything, with a classifier reviewing each action Built-in default in the terminal and VS Code since v2.1.283, Shift+Tab
dontAsk Reads in the working directories and pre-approved tools; anything that would prompt is denied --permission-mode dontAsk or settings, never in the Shift+Tab cycle
bypassPermissions Everything, except the hard stops below --dangerously-skip-permissions or --permission-mode bypassPermissions

Source: Permission modes. For a new session, the mode comes from the flag first, then permissions.defaultMode in a settings file, then the built-in default (auto in the terminal and VS Code, default for claude -p and the Agent SDK).

The first-run warning and skipDangerousModePermissionPrompt

The first interactive session in bypass mode shows this dialog, with No, exit preselected (captured in our container):

WARNING: Claude Code running in Bypass Permissions mode
In Bypass Permissions mode, Claude Code will not ask for your approval before running potentially dangerous commands.
This mode should only be used in a sandboxed container/VM that has restricted internet access and can easily be restored if damaged.
By proceeding, you accept all responsibility for actions taken while running in Bypass Permissions mode.
❯ No, exit
  Yes, I accept

Choosing Yes, I accept wrote "skipDangerousModePermissionPrompt": true to ~/.claude/settings.json, and the status bar then showed ⏵⏵ bypass permissions on. claude -p never shows the dialog. The docs note that a repository can't skip it for you: the setting is read from user, local or managed settings only.

What it still blocks (tested)

Deny rules win in every mode

The docs are explicit: "Deny rules block in every mode, including bypassPermissions." We checked with a deny rule on pushes and a real git remote:

{ "permissions": { "deny": ["Bash(git push *)"] } }

With --dangerously-skip-permissions, git push origin main was refused, listed in permission_denials, and the remote branch did not move. The other side of the coin: "Allow rules have no effect in bypassPermissions." Everything is already allowed, so an allowlist does nothing in this mode.

Ask rules, AskUserQuestion and interactive MCP tools

An explicit ask rule still asks. With {"permissions": {"ask": ["Bash(curl *)"]}}:

The same goes for the built-in AskUserQuestion tool, MCP tools marked requiresUserInteraction, and connector tools your organization set to ask.

Critical paths: rm -rf ~ and friends

rm and rmdir on a critical path are never auto-approved, in any mode, even by an allow rule or a hook returning "allow". Critical paths are the filesystem root, its top-level directories (/usr, /etc), your home directory, your working directory and its parents, plus risky forms like rm -rf "$DIR"/* or rm -rf "$(pwd)" (full list). In an interactive bypass session, the docs say such a command asks you with a time limit, then is denied.

What we saw:

Reads outside the working directory

With "permissions": {"blockReadsOutsideWorkingDirectories": true} (v2.1.257+), a Read of /etc/os-release in bypass mode was refused. Without it, Claude Code reads any file your user can read, including ~/.ssh and ~/.aws.

PreToolUse hooks that deny

A PreToolUse hook runs before any permission mode check. The hooks guide says a hook returning permissionDecision: "deny" "blocks the tool even in bypassPermissions mode or with --dangerously-skip-permissions". Our hook:

#!/bin/bash
# PreToolUse policy: deny any Bash command that mentions "hook-target".
input=$(cat)
if echo "$input" | jq -e '.tool_input.command // "" | test("hook-target")' >/dev/null; then
  echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"blocked by policy hook"}}'
fi
exit 0

touch hook-target.txt was refused in bypass mode, and the model reported the hook's reason, "blocked by policy hook". This is the most useful hard stop: a hook can call your own policy, log every call and fail closed.

What it no longer blocks: Claude's own settings

Writes to protected paths (.git, .claude, .vscode, shell rc files) are "never auto-approved except in bypassPermissions mode". With the flag, the Write tool created .claude/settings.json in the project and ~/.claude/settings.json in the home directory without a prompt (since v2.1.126, per the changelog). In other words, an agent in bypass mode can rewrite the files that hold your deny rules and hooks for its next session. Rules you rely on belong in managed settings, or in a --settings file the agent can't write (we mounted ours read-only).

Summary of our tests

Action (Claude Code 2.1.304) claude -p, no flag claude -p --dangerously-skip-permissions
uname -s > os.txt (writes a file) Denied, exit code 0 Ran
git push with a deny rule Denied Denied, remote unchanged
curl with an ask rule Denied Denied (interactive bypass: prompt)
touch refused by a PreToolUse hook Not run Denied with the hook's reason
rm -rf of the working directory Denied even with an allow rule Bash(rm *) Denied
rm -rf build (a subfolder) Not run Ran
Read outside the working directory, blockReadsOutsideWorkingDirectories on Not run Denied
Write .claude/settings.json, ~/.claude/settings.json Not run Ran
Subagent runs a shell command Not run Ran

All runs exit with code 0, whatever was denied. Cells marked "Not run" are combinations we did not test.

How to turn it on everywhere

CLI flag, alias, and resuming a session

The flag is a launch option, so pass it on every start, including when you resume:

claude --dangerously-skip-permissions
claude --continue --dangerously-skip-permissions
claude --resume <session-id> --dangerously-skip-permissions

If you type it often, alias the container rather than the flag, so the short command is also the safe one, for example alias claude-yolo='devcontainer exec --workspace-folder . claude --dangerously-skip-permissions' with Anthropic's reference dev container.

By default: permissions.defaultMode

// ~/.claude/settings.json
{ "permissions": { "defaultMode": "bypassPermissions" } }

We tested both places. In the user settings, claude -p with no flag wrote the file. In the project's .claude/settings.json, the setting was ignored and the same command was denied: since v2.1.257, bypassPermissions in .claude/settings.json or .claude/settings.local.json makes the session start in Manual mode, so a cloned repository can't switch it on for you.

Mid session: --allow-dangerously-skip-permissions and Shift+Tab

You can't enter bypass mode from a session started without it. Start with --allow-dangerously-skip-permissions instead: it adds bypass to the Shift+Tab cycle without starting in it.

claude --permission-mode plan --allow-dangerously-skip-permissions

That is the difference between the two flags: --dangerously-skip-permissions starts in bypass mode, --allow-dangerously-skip-permissions only makes it available. The cycle then runs default, acceptEdits, plan, bypassPermissions, then auto if available. One side effect from the docs: with bypass available in an interactive terminal, plan mode's blocks are not enforced.

VS Code extension and the desktop app

"It still asks for permission": fixes

"cannot be used with root/sudo privileges for security reasons"

As root, our run stopped at once with exit code 1:

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

The fix is to run Claude Code as a normal user: create one in your container (useradd -m dev, USER dev in the Dockerfile). The docs add that "the check is skipped automatically inside a recognized sandbox". The workaround you'll find in issue #9184 is IS_SANDBOX=1: in our root container, IS_SANDBOX=1 claude -p --dangerously-skip-permissions ran. It is a community workaround, not a documented setting, and it only belongs in a container you'd throw away anyway. The refusal is a sensible default: root plus no prompts means one bad command can take the whole machine.

Prompts on edits to .claude/

Issue #37765 reported that the flag still asked before Claude edited its own settings in .claude/. It was closed in April 2026, and the v2.1.126 changelog says the flag "now bypasses prompts for writes to .claude/, .git/, .vscode/, shell config files". On 2.1.304 we got no prompt. If you still see it, update Claude Code.

Subagents

Issue #40241 reported that subagents started with the Agent tool did not inherit bypass mode. It was closed as a duplicate of #42696, fixed in v2.1.98: "Subagents spawned in-process now inherit the parent's permission mode." Our subagent test ran without a prompt.

The setting is ignored

Is it safe? The real risks

What went wrong for others

The case everyone quotes was reported on Reddit in December 2025 and covered by Gigazine: while cleaning up an old repository, Claude Code ran rm -rf tests/ patches/ plan/ ~/, and the trailing ~/ wiped the user's Mac home directory. It is a user report, with no Claude Code version and no Anthropic postmortem, and it is not even clear the flag was on: the article says the user may have used it or may have approved the command without reading it. Today ~/ is a critical path, so that exact removal is never auto-approved. The lesson still stands: the next destructive command will be one no list anticipated.

Prompt injection: the risk no prompt would have caught anyway

The docs warn that bypass mode "offers no protection against prompt injection or unintended actions". An issue body, a web page or a dependency's README can tell the agent to send your environment to a URL, and with no prompts, nothing asks. Honest point: a human clicking "Yes" fifty times an hour was not a reliable filter either. What protects you is what the agent can reach, not how often it asks.

Blast radius: what the agent can reach

List it before you turn the flag on:

Safer alternatives, and when to pick each

Auto mode vs dangerously-skip-permissions

Auto mode also runs without prompts, but a classifier reviews each action first: by default Claude Sonnet 5 (CLAUDE_CODE_AUTO_MODE_MODEL overrides it from v2.1.302). If it blocks 3 actions in a row or 20 in total, auto mode pauses and Claude Code prompts again; in -p the action is skipped instead. On entering auto mode, broad allow rules such as Bash(*), wildcarded interpreters like Bash(python*) and Agent rules are dropped until you leave it. It works on all plans, with recent models only (Opus 4.6+, Sonnet 4.6+, Haiku 5.5 and Fable on the Anthropic API). Its default block list even includes launching an agent loop with --dangerously-skip-permissions outside a sandbox.

Pick auto mode on your own machine when you want fewer prompts. Pick bypass inside a box, when a classifier pause would stall a job nobody is watching.

dontAsk with an exact allowlist, for CI

dontAsk denies anything not pre-approved, which makes it the honest mode for CI: it does exactly what the list says. Our test, with --permission-mode dontAsk --allowedTools "Bash(uname *)": uname -s ran, curl was denied. Allow rules match the command text, so be precise: in a separate run, the same Bash(uname *) rule did not cover uname -s > os.txt: the docs say a redirect is checked against your Edit rules, and "A rule such as Bash(git commit *) allows the command, not the target." Write the rules for the exact commands your job runs.

The built-in Bash sandbox, and why it is not enough alone

/sandbox turns on OS-level isolation (Seatbelt on macOS, bubblewrap on Linux) for shell commands, with an auto-allow option that runs sandboxed commands without prompts. It is not a permission mode, and the docs are clear about its limit: "The sandboxed Bash tool on its own constrains only shell commands, so it is not sufficient for fully unattended runs." File tools, MCP servers and hooks run outside it.

Dev container, sandbox runtime, VM

These put the whole Claude Code process behind one boundary:

Which setup for which job

You want to Mode Isolation
Fewer prompts on your own laptop auto None needed beyond your usual care
Let Claude edit freely, review shell commands acceptEdits None
A CI job that runs a known set of commands dontAsk with exact allow rules The CI runner
A long unattended task with no one watching bypassPermissions Container, VM or srt, non-root, no personal credentials
A read-only review or audit dontAsk with only Read, Grep, Glob allowed Optional

Running it unattended: headless mode and cron jobs

claude -p with and without the flag: the silent refusal

Since v2.1.302, claude -p with no mode set starts in Manual mode and denies any call that needs approval, unless an allow rule, a hook, a canUseTool callback or --permission-prompt-tool approves it. We repeated the test from our Gemini CLI vs Claude Code benchmark on 2.1.304, with a prompt asking for uname -s > os.txt:

$ claude -p "$PROMPT" --output-format json; echo "exit=$?"
...
"permission_denials":[{"tool_name":"Bash","tool_input":{"command":"uname -s > os.txt", ...}}]
exit=0

No file, exit code 0. A cron job that checks only the exit code reports success for a run that did nothing. Check permission_denials in the JSON (or the permission_denied events with stream-json):

claude -p "$PROMPT" --output-format json > out.json
jq -e '.permission_denials | length == 0' out.json >/dev/null || { echo "denied calls"; exit 1; }

With the flag, the same run wrote the file. The hard stops above still apply, and in -p they are denied instead of asked. Our Codex vs Claude Code benchmark has the full headless commands we use for both CLIs.

A checklist for unattended runs

What replaces the human who used to click "Yes":

  1. A non-root user. Claude Code insists, and so should you.
  2. An isolation boundary around the whole process: container, VM or srt, not just the Bash sandbox.
  3. A disposable worktree (git worktree add), so the run can't touch your working copy.
  4. A clean git checkpoint before the run, so git diff and git reset tell you and undo exactly what happened.
  5. No personal credentials mounted. A scoped, short-lived token for the one service the job needs, never your home directory. A weekly dependency update job needs a GitHub token that can open a pull request, and nothing more.
  6. Deny rules for pushes and secrets, in a settings file the agent can't write: Bash(git push *), Read(./.env), Read(~/.ssh/**).
  7. A PreToolUse hook as policy for what rules can't express, failing closed when it can't decide.
  8. Caps: --max-turns and --max-budget-usd in print mode, plus a timeout in your scheduler.
  9. Check the denials, not just the exit code.
  10. A review before anything leaves the machine. The agent commits; a person reads the diff and pushes.

A nightly issue triage is the typical job this fits: it runs at night, reads a lot, writes little, and must not stall on a prompt.

How we run it on our own machines (SideHub)

SideHub runs coding CLIs for workflow steps and scheduled prompts on your own machines, through an agent you install there. An unattended step that stops on a prompt never finishes, so these runs are permissionless. What we put around them is the checklist above. One detail first: for Claude Code, we don't use the flag.

The Claude codes, Codex reviews template shows the whole loop: Claude Code implements unattended, Codex reviews the diff read-only, and you validate before the push.

The equivalent flag in Codex, Gemini CLI, Antigravity and Copilot

CLI (version checked) Skip every prompt Middle ground
Claude Code (2.1.304) --dangerously-skip-permissions auto mode, dontAsk with allow rules
Codex CLI (0.162.1) --dangerously-bypass-approvals-and-sandbox (alias --yolo) --sandbox workspace-write --ask-for-approval never, or --approve-for-me. --full-auto is gone: "unexpected argument"
Gemini CLI (0.64.0) --approval-mode=yolo (--yolo and -y are deprecated) --approval-mode=auto_edit
Antigravity CLI (1.3.4) --dangerously-skip-permissions (in agy --help) toolPermission setting: proceed-in-sandbox, request-review
GitHub Copilot CLI (1.0.95) --allow-all (alias --yolo), same as --allow-all-tools --allow-all-paths --allow-all-urls --allow-all-tools alone

Sources: Codex CLI commands, Gemini CLI reference, Antigravity CLI reference, Copilot CLI reference, and each CLI's --help on 2026-10-20. Codex is the only one whose skip flag also turns off a built-in sandbox, which its docs say to use "only inside an externally hardened environment". How these CLIs behave headless, and what they cost per task, is in our Codex and Gemini benchmarks.

How we tested

Each run went into its own docker run --rm container from debian:bookworm-slim, as a non-root user (uid 1001), with a fresh git repository and a real bare remote so a push would actually land. Only the Claude Code binary and a read-only copy of its sign-in file were mounted: no home directory, no other credentials.

docker run --rm --user 1001:1001 -e HOME=/home/dev \
  -v "$PWD/scripts:/bench/scripts:ro" -v "$PWD/results:/out" \
  -v "$PWD/creds/claude:/usr/local/bin/claude:ro" \
  -v "$PWD/creds/credentials.json:/creds/credentials.json:ro" \
  dspbench:1 /bench/scripts/in-container.sh deny-push

Inside, each test wrote its rules to a settings file and ran one prompt asking for one exact command:

claude -p "$PREAMBLE $PROMPT" --output-format json "${FLAGS[@]}" --settings /tmp/settings.json \
  --strict-mcp-config --no-session-persistence < /dev/null

Then a script recorded the exit code, permission_denials, and the state on disk (files created, remote branch). 23 headless runs and one interactive session driven with tmux, default model (Claude Opus 5.5) on a Claude Max plan, $1.67 in total at API prices according to total_cost_usd. The two root runs used --user 0:0, with and without IS_SANDBOX=1. One run per case: these tests check whether a guard fires, not how often a model tries something.

The verdict

--dangerously-skip-permissions is not reckless by itself; running it where it can reach your real life is. Inside a throwaway container, as a non-root user, with no personal credentials, it is the right tool for long unattended runs, and Claude Code keeps a few real hard stops: deny rules, ask rules, hooks that deny, and critical path removals all held in our tests. On your own machine, use auto mode instead; in CI, use dontAsk with an exact allowlist; for scheduled jobs, check permission_denials, because a refused run still exits 0. And whatever the mode, keep the last step human: read the diff before anything is pushed. The template gallery has unattended workflows built that way, if you want a starting point.