Permission Flow
Before a tool runs, Claude Code decides one of three things: allow it, ask you, or deny it. Several parts take a turn: rules, hooks, the permission mode, safety checks, and sometimes a classifier model. This page shows the order and where you can act.
Example
You set deny: ["Bash(git push:*)"] and allow: ["Bash(bun test)"]. You run in default mode.
- Claude asks to run
git push origin main. Thedenyrule matches, so Claude Code denies the call. No prompt shows. - Claude asks to run
bun test. No deny or ask rule matches. Theallowrule matches, so it runs. - Claude asks to run
rm -rf build. No rule matches. The mode isdefault, so you get a prompt.
The Order of Checks
Official pages: Configure Permissions and Choose a Permission Mode. The docs do not give the full order. The steps below follow the program, so treat the exact order as unstable.
Step by Step
- Explicit
denyandaskrules apply first, before workspace trust. Source: the official Settings Reference. PreToolUsehooks can allow, deny, or ask. A hookallowdoes not override adenyoraskrule. Source: the Mod API type file of the 2.1.312 program (schemas/claude-code.d.ts) and the program texthook allows approve the command.- Allow sources let the call run:
allowrules, the rules ofacceptEdits, and read-only command lists. Program texts:Read-only command is allowedandAuto-allowed with sandbox (autoAllowBashIfSandboxed enabled). - The mode decides the rest.
defaultprompts.dontAskdenies.autoasks the classifier.bypassPermissionsallows. The other modes follow the rules on Permission Modes. - A prompt runs
PermissionRequesthooks first. Then the dialog shows.Notificationhooks fire for unanswered requests in SDK hosts.CLAUDE_CODE_DISABLE_PERMISSION_PROMPT_NOTIFY_HOOKS=1stops that. - An auto mode denial fires
PermissionDenied. The hook can ask for a retry.
A safety check covers rm -r on a mounted drive, the folder that holds mounted drives (/Volumes, /media, WSL /mnt/c), or a top-level file or folder of a drive. Since 2.1.304 the program says it "requires explicit approval and cannot be auto-allowed by permission rules". CLAUDE_CODE_DISABLE_MOUNTED_DRIVE_RM_PROMPT turns this prompt off (Tools and Bash).
Claude Code also checks deny and ask rules at startup. It warns about a rule that matches no tool (matches no tool · check for typos). It also warns about a rule that gives a raw string where the tool needs its own matcher (never matches). Source: the program (chunk-ytgxgfq5.js:1100).
Since 2.1.311, a warning about a rule from a settings file shows once per user until the rule changes. The program saves a key for each shown warning in the seenSecurityWarnings entry of the user config file (the last 256 keys), and the key holds the source, the settings file, and the warning text (chunk-ytgxgfq5.js:1174, chunk-5zvdwenv.js:16).
Built-in safety checks, called circuit breakers, can also force a prompt. Some are immune to bypassPermissions. See Permission Modes. The diagram omits them because the program does not show where they run.
The working folders matter too.
A path outside the working folders gets the reason workingDir (Path is outside allowed working directories).
permissions.blockReadsOutsideWorkingDirectories: true refuses reads outside the working folders in every mode.
What You Can Change at Each Step
| Step | What you change |
|---|---|
| Rules | permissions., ask, deny. See Permission Rules. |
| Hooks | Pre, Permission, and Permission hooks. See the Hooks pages. |
| Safety checks | Mostly fixed. block, --, and isolate enable some. |
| Mode | permissions. and --. See Permission Modes. |
| Sandbox | sandbox. keys. See Sandbox. |
| Classifier | The auto setting. See Auto Mode. |
Where It Sits in a Turn
The check runs in the tool stage of every turn. See The Agent Loop for the stages around it and Architecture for the pieces.