Omniscio

OmniscioGuidesAgent SDK permissions

Claude Agent SDK permissions: modes, rules and the six-step check

The Agent SDK gives you two declarative controls — rules and a mode — and one callback for everything else. Knowing which one decided a call is the difference between a prompt you expected and one that never arrived.

This page owns the evaluation order, the rules and the modes. Custom tools owns tools of your own, hooks owns callbacks that can rewrite or block a call, and the SDK overview owns the first agent.

Sources read November 26, 2026. By the Omniscio team. Updated .

The six steps, in order

When Claude requests a tool, Claude Code checks the call at these steps. Each one can decide the call, send it to your canUseTool callback, or pass it on.

  1. Hooks. A hook can deny the call outright or pass it on. An allow from a hook does not skip the deny-rule and ask-rule steps, and it cannot approve an rm aimed at a critical path.
  2. Deny rules. A match from disallowed_tools or a settings file denies the call, and canUseTool is not called. This happens even in bypassPermissions mode and when a hook returned allow.
  3. Ask rules. A match from an ask rule in settings.json falls through to your callback, even in bypassPermissions mode. Tools that need user interaction, such as AskUserQuestion, fall through to your callback the same way, even when an allow rule matches.
  4. Permission mode. The active mode approves some calls and passes others on. bypassPermissions approves anything that reaches this step apart from the actions no mode auto-approves, and acceptEdits approves file operations.
  5. Allow rules. A match from allowed_tools or settings.json approves the call. A call a tool approves on its own, such as a file read inside the working directories, resolves here too.
  6. canUseTool. If nothing earlier resolved the request, your callback decides. In dontAsk mode this step is skipped and the call is denied.

The consequence to internalise: an auto-approved tool never reaches canUseTool. A permission check you put in the callback is silently bypassed for any call an earlier step actually approves. A call that falls through despite a matching rule still reaches it.

What the callback looks like

Pass canUseTool in your query options. It receives the tool name, the tool input, and a context carrying a cancellation signal and optional suggestions. Return an allow, optionally with a rewritten input, or a deny with a message.

import type { CanUseTool } from "@anthropic-ai/claude-agent-sdk";

const handleToolRequest: CanUseTool = async (toolName, input, options) => {
  if (toolName === "Bash") {
    return { behavior: "deny", message: "User denied this action" };
  }
  return { behavior: "allow", updatedInput: input };
};

const options = { canUseTool: handleToolRequest };

Allow and deny rules

Set allowedTools and disallowedTools in TypeScript, or allowed_tools and disallowed_tools in Python. Any other tool not listed is still available to Claude, and a call to it that needs approval falls through to the permission mode.

OptionEffect
allowedTools: ["Read", "Grep"]Read and Grep are auto-approved, apart from reads from network paths. Other tools still exist and fall through to the mode and canUseTool
disallowedTools: ["Bash"]The Bash tool definition is removed from the request
disallowedTools: ["Bash(rm *)"]Bash stays available; calls matching rm * are denied in every mode. Other Bash calls, including /bin/rm, fall through
disallowedTools: ["*"]Tool-name globs work in deny rules: "*" matches every tool and "mcp__*" every MCP tool

Allow rules accept globs only after a literal mcp__<server>__ prefix, with the server segment spelled out: mcp__puppeteer__* works, while an unanchored allowedTools: ["*"] or ["mcp__*"] is ignored and auto-approves nothing.

For a locked-down agent, pair the list with dontAsk. The listed calls run, apart from the calls dontAsk always denies, and every other call that would prompt is denied instead.

const options = {
  allowedTools: ["Read", "Glob", "Grep"],
  permissionMode: "dontAsk"
};

The trap: allowedTools does not constrain bypassPermissions. In that mode Claude Code approves a call to an unlisted tool anyway, unless it is one of the actions no mode auto-approves. If you need bypass mode but want specific tools blocked, use disallowedTools.

Path patterns

Scoped Read and Edit rules take a path. Edit(path) governs every built-in tool that writes files, including Write and NotebookEdit, so a write rule written as Write(path) matches no call.

  • //path is absolute: a deny rule of Edit(//secrets/**) blocks writes under /secrets from Claude's file tools and from Bash commands such as tee and > file.
  • /path is inside the session's working directory: Edit(/secrets/**) matches the secrets directory there.

A script Claude runs that opens files itself can still write under /secrets. For enforcement by the operating system rather than by Claude Code's tools, that is a sandbox question.

The permission modes

A mode sets the default for the whole session. With Claude Code v2.1.302 or later, a session starts in default unless you set a mode or its settings files set permissions.defaultMode.

ModeWhat it decides
defaultNo mode-based approvals; a call that needs approval and matches no allow rule reaches canUseTool
dontAskTurns each prompt into a denial without calling canUseTool; allow-listed calls still run
acceptEditsAuto-approves file edits and filesystem operations inside the working directories or an added directory
bypassPermissionsRuns tools without prompts, apart from the actions no mode auto-approves
planClaude explores and plans; file edits outside protected paths still reach canUseTool even when an allow rule matches
autoA model classifier reviews actions such as shell commands and network requests

Set it at query time, or change it mid-session

const q = query({
  prompt: "Help me refactor this code",
  options: { permissionMode: "default" }
});

Call setPermissionMode() in TypeScript or set_permission_mode() in Python to change it while the session runs. The new mode takes effect immediately for subsequent tool requests, so you can start restrictive and loosen it after reviewing Claude's approach.

What a subagent inherits

A subagent’s AgentDefinition can carry its own permissionMode. Where it actually runs depends on the main session:

  • Main session in plan: the subagent runs in plan mode too, even when its definition asks for acceptEdits, so its edits on your source files still reach your callback.
  • Main session in acceptEdits, auto or bypassPermissions: the subagent inherits that mode.
  • Main session in default or dontAsk: the subagent runs in the mode its definition sets. Even then Claude Code never applies a bypassPermissions value the definition sets, and applies auto only when auto mode is available to that subagent. The bypassPermissions exception requires Claude Code v2.1.267 or later.

What each mode approves

default

No mode-based approvals: a call that needs approval and matches no allow rule reaches canUseTool, and a call that needs no approval runs.

acceptEdits

Approves file edits with the Edit, Write and NotebookEdit tools, and the filesystem commands mkdir, touch, rm, rmdir, mv, cp and sed, for paths inside the working directory or a directory you added. It does not approve a path outside that scope, a protected path, a recognized critical-path removal, or a touch with an option, a glob or a prefix such as timeout 5.

dontAsk

Denies every call that would prompt, without calling canUseTool. Five kinds of call are denied even when an allow rule matches: connector tools your organization set to ask, tools that require user interaction, custom tools marked always_ask, reads from network paths, and recognized critical-path removals.

bypassPermissions

Approves calls without prompting, apart from the actions no mode auto-approves. Hooks still run and can block. Deny rules, explicit ask rules and hooks are evaluated before the mode check. On Linux and macOS, Claude Code refuses to start in this mode as root or under sudo outside a recognized sandbox.

plan

Edits made with Claude's file tools outside protected paths reach your callback, even when an allow rule matches or a PreToolUse hook returns allow. When auto mode is available, shell commands, web fetches, web searches and read-only MCP calls that no allow rule approves go to auto mode's classifier instead. That review is on by default; set useAutoModeDuringPlan to false to turn it off.

auto

A classifier approves or blocks each action it reviews. If you switch a session in auto mode to a model auto mode does not support, the session changes to default and a system message with subtype status reports permissionMode: "default". Switch back to a supported model and call setPermissionMode("auto") to return.

The callback that never runs

The TypeScript SDK emits a Node.js process warning once when you pass canUseTool in a configuration where calls are auto-approved first. Its code is CLAUDE_SDK_CAN_USE_TOOL_SHADOWED. Two configurations trigger it: permissionMode: 'bypassPermissions', and an allowedTools entry that is only a tool name such as "Read".

The warning blocks nothing. To see the calls an allow rule approves, put your checks in a PreToolUse hook, which runs for those calls too. To have your callback run for a listed tool's calls that need approval, remove that tool's bare entry from allowedTools.

Sources

Every line on this page rests on the Anthropic documentation below, read on the date beside it.

  • Configure permissions, for the evaluation order, the rule options, path patterns, the six modes, subagent inheritance, the mode details and the shadowed-callback warning. Read November 26, 2026.
  • Handle approvals and user input, for the canUseTool callback signature and the allow and deny return shapes. Read November 26, 2026.

No Agent SDK session was run for this page. Every option name, default and message is transcribed from those pages.

Common questions

What order does the Agent SDK check permissions in?

Six steps: hooks, deny rules, ask rules, the permission mode, allow rules, and finally the canUseTool callback. A hook can deny but an allow from a hook does not skip the deny and ask rules. A deny rule wins over every later step, including bypassPermissions.

Does allowedTools restrict which tools the agent can use?

No. allowedTools pre-approves the tools you list; every other tool still exists and a call to it that needs approval falls through to the permission mode and canUseTool. To remove a built-in tool entirely, put its bare name in disallowedTools, which removes the tool definition from the request.

What does dontAsk mode do?

It turns every call that would prompt into a denial, without calling canUseTool. Calls approved by allowedTools or settings.json allow rules still run, as do calls that need no approval in default mode, such as file reads inside the working directories, apart from the calls dontAsk always denies. Pair it with allowedTools for a locked-down agent.

Why is my canUseTool callback never called?

An earlier step approved the call. In bypassPermissions mode, and for an allowedTools entry that is only a bare tool name such as Read, calls are approved before canUseTool is consulted, and the SDK emits a CLAUDE_SDK_CAN_USE_TOOL_SHADOWED warning once. Use a PreToolUse hook to see those calls, or remove the bare entry.

How do I change the permission mode mid-session?

Call setPermissionMode() in TypeScript or set_permission_mode() in Python on the client or query object. The new mode takes effect immediately for subsequent tool requests, so you can start restrictive and loosen it as trust builds.

Every session, one window

Omniscio runs several agent sessions side by side in one window, each with its own context and its own diff view. Any model, any harness: Claude Code, Codex, OpenCode, Devin, Pi, and Hermes all supported.