pub struct Settings {
pub permissions: PermissionSet,
pub env: Option<HashMap<String, String>>,
pub model: Option<String>,
pub hooks: Option<Hooks>,
pub sandbox: Option<Sandbox>,
pub attribution: Option<Attribution>,
pub enabled_plugins: Option<HashMap<String, bool>>,
pub cleanup_period_days: Option<u32>,
pub language: Option<String>,
pub bypass_permissions: Option<bool>,
pub extra: HashMap<String, Value>,
}Expand description
The main settings structure for Claude Code.
This represents the full schema of a Claude Code settings file, supporting all configuration options available at user and project levels.
Fields§
§permissions: PermissionSetTool permission configuration controlling what Claude Code can access.
env: Option<HashMap<String, String>>Environment variables to set for tool execution.
model: Option<String>Override the default Claude model.
hooks: Option<Hooks>Hook configurations for pre/post tool execution.
sandbox: Option<Sandbox>Sandbox configuration for command execution.
attribution: Option<Attribution>Attribution settings for git commits and PRs.
enabled_plugins: Option<HashMap<String, bool>>Map of enabled plugins.
cleanup_period_days: Option<u32>Number of days before session cleanup (default: 30).
language: Option<String>Preferred response language.
bypass_permissions: Option<bool>When true, Claude Code starts with permissions bypassed (equivalent to
--dangerously-skip-permissions). Useful when an external tool like
Clash is the sole permission handler.
extra: HashMap<String, Value>Any additional fields not explicitly defined.
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn with_permissions(self, permissions: PermissionSet) -> Self
pub fn with_permissions(self, permissions: PermissionSet) -> Self
Creates a Settings instance with the specified permissions.
Sourcepub fn with_env(self, env: HashMap<String, String>) -> Self
pub fn with_env(self, env: HashMap<String, String>) -> Self
Creates a Settings instance with the specified environment variables.
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Creates a Settings instance with the specified model.
Sourcepub fn with_hooks(self, hooks: Hooks) -> Self
pub fn with_hooks(self, hooks: Hooks) -> Self
Creates a Settings instance with the specified hooks.
Sourcepub fn with_sandbox(self, sandbox: Sandbox) -> Self
pub fn with_sandbox(self, sandbox: Sandbox) -> Self
Creates a Settings instance with the specified sandbox configuration.
Sourcepub fn with_attribution(self, attribution: Attribution) -> Self
pub fn with_attribution(self, attribution: Attribution) -> Self
Creates a Settings instance with the specified attribution.
Sourcepub fn with_bypass_permissions(self, enabled: bool) -> Self
pub fn with_bypass_permissions(self, enabled: bool) -> Self
Creates a Settings instance with bypass_permissions enabled or disabled.
Sourcepub fn is_clash_installed(&self) -> bool
pub fn is_clash_installed(&self) -> bool
Returns true if these settings were installed by clash.
This checks for the presence of the _clashInstalled marker field.
Sourcepub fn mark_clash_installed(&mut self)
pub fn mark_clash_installed(&mut self)
Marks these settings as installed by clash.
This sets the _clashInstalled field to true.
Sourcepub fn clear_clash_installed(&mut self)
pub fn clear_clash_installed(&mut self)
Clears the clash installation marker from these settings.
Sourcepub fn with_clash_installed(self) -> Self
pub fn with_clash_installed(self) -> Self
Builder method to mark settings as clash-installed.