Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 27 fields pub prompt: String, pub model: Option<String>, pub fallback_model: Option<String>, pub effort: Option<Effort>, pub agent: Option<String>, pub permissions: Permissions, pub permission_mode: Option<PermissionMode>, pub allow_tools: Vec<String>, pub deny_tools: Vec<String>, pub session: Session, pub fork: bool, pub worktree: Option<Option<String>>, pub max_turns: Option<u32>, pub max_budget_usd: Option<f64>, pub timeout_secs: Option<u64>, pub json_schema: Option<String>, pub system_prompt: Option<String>, pub append_system_prompt: Option<String>, pub agent_notice: Option<String>, pub no_agent_notice: bool, pub no_retry: bool, pub no_session_persistence: bool, pub bare: bool, pub safe_mode: bool, pub add_dir: Vec<String>, pub mcp_config: Vec<String>, pub strict_mcp_config: bool,
}
Expand description

A config-and-run request: everything run needs to send one prompt through claude and hand back the typed result. The prompt is the final, already-composed text (the CLI does attach/git/var composition before building this).

Fields§

§prompt: String

The fully-composed prompt to send.

§model: Option<String>

Override the model for this run (None = claude’s default).

§fallback_model: Option<String>

Fallback model when the primary is overloaded (--fallback-model).

§effort: Option<Effort>

Reasoning-effort level (None = claude’s default). The CLI maps its --effort value to this claude-wrapper type in build_config.

§agent: Option<String>

Run under a named subagent definition (--agent).

§permissions: Permissions

Permission posture (default read-only).

§permission_mode: Option<PermissionMode>

A specific claude permission mode composed on top of the posture. None leaves claude’s default. Ignored under Permissions::FullAuto, which bypasses all checks before the mode is read. The CLI maps its --permission-mode value to this claude-wrapper type in build_config.

§allow_tools: Vec<String>

Extra allowed tool patterns layered on top of the posture.

§deny_tools: Vec<String>

Tool patterns to block (ignored under Permissions::FullAuto).

§session: Session

Session continuity (default a fresh session).

§fork: bool

Branch the resumed session instead of continuing it in place. Only meaningful with Session::Resume.

§worktree: Option<Option<String>>

Run in a git worktree: None = no worktree, Some(None) = a fresh anonymous worktree, Some(Some(name)) = a named worktree.

§max_turns: Option<u32>

Cap the agentic turn count (None = uncapped).

§max_budget_usd: Option<f64>

Cap total spend in USD (None = uncapped).

§timeout_secs: Option<u64>

Wall-clock deadline in seconds (None or 0 = no deadline).

§json_schema: Option<String>

Constrain output to a JSON Schema. The value is the inline schema JSON (not a path – the CLI’s path-reading sugar is its own concern).

§system_prompt: Option<String>

Replace claude’s system prompt (--system-prompt). None keeps it.

§append_system_prompt: Option<String>

Append to the system prompt (--append-system-prompt); composed with the agent notice below into one appended block.

§agent_notice: Option<String>

Override the built-in single-turn agent-notice text (--agent-notice). Some("") disables the notice (as does no_agent_notice); None uses the built-in text.

§no_agent_notice: bool

Suppress the built-in single-turn agent notice (--no-agent-notice). Default false – the notice is injected, faithful to the CLI default.

§no_retry: bool

Fail fast on a transient error instead of retrying (--no-retry): a single attempt, no backoff.

§no_session_persistence: bool

Do not persist the session to claude’s history (--no-session-persistence).

§bare: bool

Bare mode (--bare): the minimal claude invocation.

§safe_mode: bool

Safe mode (--safe-mode): claude’s extra guardrails.

§add_dir: Vec<String>

Extra tool-access directories (--add-dir), forwarded verbatim.

§mcp_config: Vec<String>

MCP server config files (--mcp-config), forwarded verbatim.

§strict_mcp_config: bool

Use only the servers in mcp_config, ignoring other MCP sources (--strict-mcp-config).

Implementations§

Source§

impl Config

Source

pub fn new(prompt: impl Into<String>) -> Self

Construct a Config for a plain prompt; chain the setters for the rest.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Config

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> 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