Skip to main content

Permissions

Struct Permissions 

Source
#[non_exhaustive]
pub struct Permissions { pub allow: Option<Vec<String>>, pub deny: Option<Vec<String>>, pub ask: Option<Vec<String>>, pub default_mode: Option<PermissionMode>, pub disable_bypass_permissions_mode: Option<DisableFlag>, pub disable_auto_mode: Option<DisableFlag>, pub additional_directories: Option<Vec<String>>, pub block_reads_outside_working_directories: Option<bool>, pub block_writes_outside_working_directories: Option<bool>, pub deny_instead_of_prompting: Option<bool>, pub extra: Extra, }
Expand description

permissions: rules and the starting mode.

Rules use Claude Code’s permission-rule syntax (Bash(git diff:*), Read(./src/**), WebFetch(domain:example.com), mcp__server). Across layers the lists merge, and a deny beats an allow.

Control which tools Claude can use without asking, which ones prompt, and which ones are blocked. Also set the default permission mode for new sessions.

Docs: permissions.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§allow: Option<Vec<String>>

List the tool uses Claude Code approves without asking you. In an MCP rule, * can appear only in the tool name after the mcp__<server>__ prefix, such as mcp__github__get_*; it can’t appear in the server name.

  • Values: array of permission rule strings
  • Default: unset
  • Scope: any settings file.

Docs: allow.

§deny: Option<Vec<String>>

List the tool uses Claude Code blocks. Use it for files that hold API keys, secrets, or environment values: Claude Code excludes matching files from file discovery and search results, denies reads of them, and blocks the Edit and Write tools on the matching paths. Read and Edit deny rules apply to Claude’s built-in file tools, to file commands Claude Code recognizes in Bash, such as cat, head, tail, sed, and tee, and to the targets of Bash redirections such as > file and < file; they don’t apply to a command that reads files without naming them, such as grep -r pattern ., or to arbitrary subprocesses, so for OS-level enforcement enable the sandbox.

  • Values: array of permission rule strings
  • Default: unset
  • Scope: any settings file.

Docs: deny.

§ask: Option<Vec<String>>

List the tool uses that prompt you for confirmation even in a permission mode that would otherwise approve them, such as acceptEdits or bypassPermissions. In dontAsk mode Claude Code denies a matching tool use instead of prompting.

  • Values: array of permission rule strings
  • Default: unset
  • Scope: any settings file.

Docs: ask.

§default_mode: Option<PermissionMode>

Set the default permission mode for new sessions. When you leave it unset, the built-in default for your surface applies.

  • Values: string, one of:
    • "default": Claude Code runs only reads without asking
    • "acceptEdits": Claude Code also runs file edits and common filesystem commands such as mkdir and mv without asking
    • "plan": Claude Code reads and plans but blocks edits until you approve a plan
    • "auto": Claude Code runs without routine prompts; before actions such as shell commands and network requests run, a background classifier checks that they align with your request
    • "dontAsk": Claude Code auto-denies every call that would otherwise prompt, though a mod you installed can still approve some of those calls. File reads inside your working directories, other actions that need no approval, and pre-approved tools still run, apart from reads from network paths
    • "bypassPermissions": Claude Code runs everything without asking
    • "manual": an alias for "default"
  • Default: unset
  • Scope: any settings file. auto and bypassPermissions don’t take effect from project or local settings, so set them in ~/.claude/settings.json instead.

Docs: defaultMode.

§disable_bypass_permissions_mode: Option<DisableFlag>

Prevent anyone from entering bypassPermissions mode. Claude Code then rejects the --dangerously-skip-permissions flag, and ignores an agent definition’s permissionMode: bypassPermissions, so the subagent runs with the parent session’s permission mode.

  • Values: the string "disable"
  • Default: unset
  • Scope: any settings file. Typically set in managed settings to enforce organizational policy.

Docs: disableBypassPermissionsMode.

§disable_auto_mode: Option<DisableFlag>

Set to “disable” to prevent auto mode from being activated. Removes auto from the Shift+Tab cycle and rejects --permission-mode auto at startup. Most useful in managed settings where users cannot override it.

  • Values: "disable"
  • Default: unset

Docs: disableAutoMode.

§additional_directories: Option<Vec<String>>

Give Claude file access to directories outside the one you started in, as additional working directories. Most .claude/ configuration is not discovered from these directories.

Docs: additionalDirectories.

§block_reads_outside_working_directories: Option<bool>

Make Claude’s file tools refuse reads outside your working directories in every permission mode, including bypassPermissions. Claude Code denies Read, Grep, Glob, and LSP calls on those paths and tells Claude to ask you to add the directory with /add-dir. Files Claude Code itself needs stay readable, such as your skills, plugins, rules, agents, commands, and the CLAUDE.md memory file under ~/.claude/.

  • Values: Boolean
    • true: Claude’s file tools refuse reads outside the working directories
    • false: the same as unset; the block still applies if another file sets true
  • Default: unset, so reads outside the working directories follow your permission mode
  • Scope: any settings file. A true in any file applies, so a repository can turn the block on for itself but can’t lift yours.

Docs: blockReadsOutsideWorkingDirectories.

§block_writes_outside_working_directories: Option<bool>

Make the Write, Edit, and NotebookEdit tools refuse paths outside your working directories in every permission mode, including bypassPermissions, apart from some of Claude Code’s own files. The key doesn’t limit shell commands, MCP tools, or the programs hooks run. To limit where shell commands write, turn on sandboxing.

  • Values: Boolean
    • true: turns the block on
    • false: the same as unset; the block still applies if another file sets true
  • Default: unset, so writes outside the working directories follow your permission mode. The block is also on while Claude Code can’t read the permissions object in your managed settings.
  • Scope: any settings file. A true in any file the session loads applies, so a repository can turn the block on for itself but can’t lift yours.

Docs: blockWritesOutsideWorkingDirectories.

§deny_instead_of_prompting: Option<bool>

Set this to true to keep a session running when nobody is there to answer a permission prompt. Claude Code denies a tool call that would otherwise wait on a prompt, and the turn continues. Requires Claude Code v2.1.319 or later.

  • Values: Boolean
    • true: Claude Code denies calls that would otherwise prompt
    • false: the same as unset; calls are still denied if another of these sources sets true
  • Default: unset, so a call that needs approval prompts you
  • Scope: user or managed, and --settings. A repository can’t set it for you.

Docs: denyInsteadOfPrompting.

§extra: Extra

Keys Claude Code accepts here that this crate doesn’t model (newer or undocumented ones), kept as written so the document round-trips.

Trait Implementations§

Source§

impl Clone for Permissions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Permissions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Permissions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Permissions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Permissions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Permissions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Permissions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.