Skip to main content

ClaudeConfig

Struct ClaudeConfig 

Source
#[non_exhaustive]
pub struct ClaudeConfig {
Show 31 fields pub preset: Preset, pub cli_path: Option<String>, pub model: Option<String>, pub system_prompt: Option<String>, pub append_system_prompt: Option<String>, pub max_turns: Option<u32>, pub timeout: Option<Duration>, pub stream_idle_timeout: Option<Duration>, pub fallback_model: Option<String>, pub effort: Option<String>, pub max_budget_usd: Option<f64>, pub allowed_tools: Vec<String>, pub disallowed_tools: Vec<String>, pub tools: Option<String>, pub mcp_config: Vec<String>, pub setting_sources: Option<String>, pub settings: Option<String>, pub json_schema: Option<String>, pub include_partial_messages: Option<bool>, pub include_hook_events: Option<bool>, pub permission_mode: Option<String>, pub dangerously_skip_permissions: Option<bool>, pub add_dir: Vec<String>, pub file: Vec<String>, pub resume: Option<String>, pub session_id: Option<String>, pub bare: Option<bool>, pub no_session_persistence: Option<bool>, pub disable_slash_commands: Option<bool>, pub strict_mcp_config: Option<bool>, pub extra_args: Vec<String>,
}
Expand description

Configuration options for Claude CLI execution.

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.
§preset: Preset

Preset that determines the base set of auto-injected CLI flags. Defaults to Preset::Normal.

§cli_path: Option<String>

Path to the claude CLI binary. Defaults to "claude" (resolved via PATH).

Use this to specify an absolute path when the binary is not on PATH, or to select a specific version of the CLI.

§Security

No validation is performed on this value. tokio::process::Command::new() invokes execvp directly without a shell, so shell injection is not possible.

§model: Option<String>

Model to use (--model).

§system_prompt: Option<String>

System prompt (--system-prompt). Defaults to empty string when None.

§append_system_prompt: Option<String>

Append to the default system prompt (--append-system-prompt).

§max_turns: Option<u32>

Maximum number of turns (--max-turns).

§timeout: Option<Duration>

Timeout duration. No timeout when None. Library-only; not a CLI flag.

§stream_idle_timeout: Option<Duration>

Idle timeout for streams. If no event arrives within this duration, the stream yields ClaudeError::Timeout and terminates. Library-only; not a CLI flag.

§fallback_model: Option<String>

Fallback model when default is overloaded (--fallback-model).

§effort: Option<String>

Effort level (--effort). Use effort constants for known values.

§max_budget_usd: Option<f64>

Maximum dollar amount for API calls (--max-budget-usd).

§allowed_tools: Vec<String>

Tools to allow (--allowedTools).

§disallowed_tools: Vec<String>

Tools to deny (--disallowedTools).

§tools: Option<String>

Built-in tool set override (--tools). Defaults to "" (none) when None.

§mcp_config: Vec<String>

MCP server configs (--mcp-config). Defaults to {"mcpServers":{}} when empty.

§setting_sources: Option<String>

Setting sources to load (--setting-sources). Defaults to "" (none) when None.

§settings: Option<String>

Path to settings file or JSON string (--settings).

§json_schema: Option<String>

JSON Schema for structured output (--json-schema).

§include_partial_messages: Option<bool>

Include partial message chunks in stream output (--include-partial-messages).

§include_hook_events: Option<bool>

Include hook events in stream output (--include-hook-events).

§permission_mode: Option<String>

Permission mode (--permission-mode). Use permission_mode constants for known values.

§dangerously_skip_permissions: Option<bool>

Bypass all permission checks (--dangerously-skip-permissions).

§add_dir: Vec<String>

Additional directories for tool access (--add-dir).

§file: Vec<String>

File resources to download at startup (--file).

§resume: Option<String>

Resume a conversation by session ID (--resume).

§session_id: Option<String>

Use a specific session ID (--session-id).

§bare: Option<bool>

Minimal mode (--bare).

§no_session_persistence: Option<bool>

Disable session persistence (--no-session-persistence). Enabled by default.

§disable_slash_commands: Option<bool>

Disable all skills (--disable-slash-commands). Enabled by default.

§strict_mcp_config: Option<bool>

Only use MCP servers from --mcp-config (--strict-mcp-config). Enabled by default.

§extra_args: Vec<String>

Arbitrary CLI arguments for forward compatibility.

Appended before the prompt. Use typed fields when available; duplicating a typed field here may cause unpredictable CLI behavior.

Implementations§

Source§

impl ClaudeConfig

Source

pub fn cli_path_or_default(&self) -> &str

Returns the CLI binary path, defaulting to "claude".

Source

pub fn builder() -> ClaudeConfigBuilder

Returns a new builder.

Source

pub fn to_builder(&self) -> ClaudeConfigBuilder

Creates a builder pre-filled with this configuration’s values.

Source

pub fn to_args(&self, prompt: &str) -> Vec<String>

Builds command-line arguments for JSON output mode.

Includes fixed options such as --print --output-format json.

Source

pub fn to_stream_args(&self, prompt: &str) -> Vec<String>

Builds command-line arguments for stream-json output mode.

Includes --verbose (required for stream-json) and optionally --include-partial-messages.

Trait Implementations§

Source§

impl Clone for ClaudeConfig

Source§

fn clone(&self) -> ClaudeConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ClaudeConfig

Source§

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

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

impl Default for ClaudeConfig

Source§

fn default() -> ClaudeConfig

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

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more