Permissions & Safety
Product facts change. Mode names, rule syntax and which modes exist (the classifier-basedautomode in particular) are described as of October 2026. Check the permissions documentation and/permissionsin your version before you rely on a detail.
After this lesson, you will be able to:
- Pick the right permission mode (`default`, `acceptEdits`, `plan`, `auto`, `dontAsk`, `bypassPermissions`) for a given workflow
- Write a Bash allowlist that auto-approves safe commands without leaving security holes
- Understand what `--dangerously-skip-permissions` actually does and when it is appropriate (rarely)
- Recognize the four safety failure modes and the patterns that prevent each
Before you start
#The Permission Modes
| Mode | Behavior | When to Use |
|---|---|---|
default | Asks the first time it needs each kind of permission | Learning, unfamiliar code |
acceptEdits | Auto-approves file edits; still asks before most Bash commands | Trusted refactors, you will review the diff |
plan | Read-only: it can explore and propose, not edit or run | Planning and analysis without changes |
auto | A classifier model reviews actions and blocks ones that look risky | Long tasks where constant prompts would slow you down (availability depends on your plan and model; verify) |
dontAsk | Runs only what your rules pre-approve and refuses the rest | Strict workflows, CI |
bypassPermissions | Skips nearly all prompts | DANGEROUS: only inside a disposable container or VM |
Set the mode at session start:
claude --permission-mode acceptEdits # Trust me, I'll review edits
claude --permission-mode plan # Just plan, don't touch anything
claude --permission-mode dontAsk # Strict allowlist only
/help). The /permissions command shows and edits your allow and deny rules.#The Allowlist / Denylist System
{
"permissions": {
"allow": [
"Bash(npm run *)", // any npm run X
"Bash(git status)", // exact match
"Bash(git diff *)", // any git diff variant
"Bash(pytest *)",
"Bash(python -m pytest *)"
],
"deny": [
"Bash(rm -rf *)",
"Bash(sudo *)",
"Read(./.env)", // rules also cover file tools
"Bash(curl *)"
]
}
}
Pattern semantics
- Exact:
Bash(git status)matches onlygit status - Wildcard:
Bash(npm run *)matchesnpm run lint,npm run build, and so on - File tools have rules too:
Read(./.env)andEdit(./src/**)are valid rule forms
Bash(curl *) is a better ban than trying to catch curl ... | sh, because there are many ways to write a pipe to a shell. And a Bash rule never blocks a command from reading a secret: cat .env is a Bash command, so deny the file with a Read rule and a hook as well.#What auto Mode Actually Does
auto mode a separate classifier model reviews actions before they run and tries to block the risky ones, such as actions that go beyond your request, touch infrastructure you did not mention, or are driven by instructions found in a file or web page. You are trading some prompts for a model's judgment, and a model's judgment can be wrong.- It is a way to cut prompt fatigue on long tasks, not a security boundary
- Your deny rules still apply, and explicit allow rules are a more predictable way to speed up the commands you run all the time
- Which plans and models can use it, and how it behaves, is documented separately and changes. Verify before you depend on it (as of October 2026)
#The --dangerously-skip-permissions Flag
bypassPermissions mode from the table above: it skips nearly all permission prompts, so Claude can run tool calls without confirmation.When this is appropriate
- ✅ Automated CI/CD with vetted prompts inside a disposable container with no secrets it does not need
- ✅ A throwaway VM or devcontainer where the worst outcome is deleting the sandbox
When this is NOT appropriate
- ❌ Interactive use on your laptop with sudo access or real credentials in reach
- ❌ Production systems
- ❌ Any time you do not fully trust the content Claude will read (web pages, issues, third-party repos)
.git/ and .claude/ even in this mode, but the exact list changes and is not a substitute for isolation. The container is the safety, not the flag.#Bash Injection Hardening
Prompt injection is when text Claude reads (a README, a web page, a tool result) contains instructions that try to make it run something harmful. Bash is where that hurts most.
What helps, as layers:
- Pattern rules in
permissions(deny first), keeping in mind they match text and can miss variations - PreToolUse hooks that parse the real command and
exit 2on anything unwanted (see the Hooks lesson) - Isolation: a container, a throwaway checkout or a sandbox so the blast radius is small. Claude Code also offers a sandboxed Bash option in recent versions; check the docs for your platform
- Least privilege: no production credentials in the environment, and a clean git state so any change is easy to undo
No single layer is enough. Assume a rule will occasionally miss, and make sure the miss is cheap.
#Four Safety Failure Modes
#Hands-On
.claude/settings.json.Tests: Run it, fix the listed problems, and run it again until it prints OK. Then save the block as .claude/settings.json in a real project and check that allowed commands run, denied ones are refused, and unlisted ones prompt.
#Key Takeaways
- Modes:
defaultto learn,acceptEditsfor trusted refactors,planfor analysis,dontAskfor strict workflows,autoonly after you have checked what it does for your plan,bypassPermissionsonly in a disposable container - Allowlist common safe commands to skip prompts: npm, pytest, git status are obvious starters
- Denylist destructive patterns explicitly, and back the important ones with a PreToolUse hook. Do not trust one layer
--dangerously-skip-permissionsis for automated, isolated contexts only. The container is the safety, not the flag- Rules match text. They are a convenience for everyday use, not a promise that nothing dangerous can run
#Quick Check
You're refactoring a 50-file change and tired of approving each Edit call. Best mode?
Which command line is appropriate for a long, trusted refactor on a feature branch you've already reviewed the plan for?