ClaudeCodeOptionsBuilder

Struct ClaudeCodeOptionsBuilder 

Source
pub struct ClaudeCodeOptionsBuilder { /* private fields */ }
Expand description

Builder for ClaudeCodeOptions

Implementations§

Source§

impl ClaudeCodeOptionsBuilder

Source

pub fn system_prompt(self, prompt: impl Into<String>) -> Self

Set system prompt

Source

pub fn append_system_prompt(self, prompt: impl Into<String>) -> Self

Set append system prompt

Source

pub fn allowed_tools(self, tools: Vec<String>) -> Self

Add allowed tools

Source

pub fn allow_tool(self, tool: impl Into<String>) -> Self

Add a single allowed tool

Source

pub fn disallowed_tools(self, tools: Vec<String>) -> Self

Add disallowed tools

Source

pub fn disallow_tool(self, tool: impl Into<String>) -> Self

Add a single disallowed tool

Source

pub fn permission_mode(self, mode: PermissionMode) -> Self

Set permission mode

Source

pub fn add_mcp_server( self, name: impl Into<String>, config: McpServerConfig, ) -> Self

Add MCP server

Source

pub fn mcp_servers(self, servers: HashMap<String, McpServerConfig>) -> Self

Set all MCP servers from a map

Source

pub fn mcp_tools(self, tools: Vec<String>) -> Self

Set MCP tools

Source

pub fn max_turns(self, turns: i32) -> Self

Set max turns

Source

pub fn max_thinking_tokens(self, tokens: i32) -> Self

Set max thinking tokens

Source

pub fn max_output_tokens(self, tokens: u32) -> Self

Set max output tokens (1-32000, overrides CLAUDE_CODE_MAX_OUTPUT_TOKENS env var)

Source

pub fn model(self, model: impl Into<String>) -> Self

Set model

Source

pub fn cwd(self, path: impl Into<PathBuf>) -> Self

Set working directory

Source

pub fn continue_conversation(self, enable: bool) -> Self

Enable continue conversation

Source

pub fn resume(self, id: impl Into<String>) -> Self

Set resume conversation ID

Source

pub fn permission_prompt_tool_name(self, name: impl Into<String>) -> Self

Set permission prompt tool name

Source

pub fn settings(self, settings: impl Into<String>) -> Self

Set settings file path

Source

pub fn add_dirs(self, dirs: Vec<PathBuf>) -> Self

Add directories as working directories

Source

pub fn add_dir(self, dir: impl Into<PathBuf>) -> Self

Add a single directory as working directory

Source

pub fn extra_args(self, args: HashMap<String, Option<String>>) -> Self

Add extra CLI arguments

Source

pub fn add_extra_arg( self, key: impl Into<String>, value: Option<String>, ) -> Self

Add a single extra CLI argument

Source

pub fn control_protocol_format(self, format: ControlProtocolFormat) -> Self

Set control protocol format

Source

pub fn include_partial_messages(self, include: bool) -> Self

Include partial assistant messages in streaming output

Source

pub fn fork_session(self, fork: bool) -> Self

Enable fork_session behavior

Source

pub fn setting_sources(self, sources: Vec<SettingSource>) -> Self

Set setting sources

Source

pub fn agents(self, agents: HashMap<String, AgentDefinition>) -> Self

Define programmatic agents

Source

pub fn cli_channel_buffer_size(self, size: usize) -> Self

Set CLI channel buffer size

Controls the size of internal communication channels (message, control, stdin buffers). Default is 100. Increase for high-throughput scenarios to prevent message lag.

§Arguments
  • size - Buffer size (number of messages that can be queued)
§Example
let options = ClaudeCodeOptions::builder()
    .cli_channel_buffer_size(500)
    .build();
Source

pub fn build(self) -> ClaudeCodeOptions

Build the options

Trait Implementations§

Source§

impl Debug for ClaudeCodeOptionsBuilder

Source§

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

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

impl Default for ClaudeCodeOptionsBuilder

Source§

fn default() -> ClaudeCodeOptionsBuilder

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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