pub struct ClaudeCodeOptionsBuilder { /* private fields */ }Expand description
Builder for ClaudeCodeOptions
Implementations§
Source§impl ClaudeCodeOptionsBuilder
impl ClaudeCodeOptionsBuilder
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
Set system prompt
Sourcepub fn append_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn append_system_prompt(self, prompt: impl Into<String>) -> Self
Set append system prompt
Sourcepub fn allowed_tools(self, tools: Vec<String>) -> Self
pub fn allowed_tools(self, tools: Vec<String>) -> Self
Add allowed tools
Sourcepub fn allow_tool(self, tool: impl Into<String>) -> Self
pub fn allow_tool(self, tool: impl Into<String>) -> Self
Add a single allowed tool
Sourcepub fn disallowed_tools(self, tools: Vec<String>) -> Self
pub fn disallowed_tools(self, tools: Vec<String>) -> Self
Add disallowed tools
Sourcepub fn disallow_tool(self, tool: impl Into<String>) -> Self
pub fn disallow_tool(self, tool: impl Into<String>) -> Self
Add a single disallowed tool
Sourcepub fn permission_mode(self, mode: PermissionMode) -> Self
pub fn permission_mode(self, mode: PermissionMode) -> Self
Set permission mode
Sourcepub fn add_mcp_server(
self,
name: impl Into<String>,
config: McpServerConfig,
) -> Self
pub fn add_mcp_server( self, name: impl Into<String>, config: McpServerConfig, ) -> Self
Add MCP server
Sourcepub fn mcp_servers(self, servers: HashMap<String, McpServerConfig>) -> Self
pub fn mcp_servers(self, servers: HashMap<String, McpServerConfig>) -> Self
Set all MCP servers from a map
Sourcepub fn max_thinking_tokens(self, tokens: i32) -> Self
pub fn max_thinking_tokens(self, tokens: i32) -> Self
Set max thinking tokens
Sourcepub fn max_output_tokens(self, tokens: u32) -> Self
pub fn max_output_tokens(self, tokens: u32) -> Self
Set max output tokens (1-32000, overrides CLAUDE_CODE_MAX_OUTPUT_TOKENS env var)
Sourcepub fn continue_conversation(self, enable: bool) -> Self
pub fn continue_conversation(self, enable: bool) -> Self
Enable continue conversation
Sourcepub fn permission_prompt_tool_name(self, name: impl Into<String>) -> Self
pub fn permission_prompt_tool_name(self, name: impl Into<String>) -> Self
Set permission prompt tool name
Sourcepub fn add_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn add_dir(self, dir: impl Into<PathBuf>) -> Self
Add a single directory as working directory
Sourcepub fn add_extra_arg(
self,
key: impl Into<String>,
value: Option<String>,
) -> Self
pub fn add_extra_arg( self, key: impl Into<String>, value: Option<String>, ) -> Self
Add a single extra CLI argument
Sourcepub fn control_protocol_format(self, format: ControlProtocolFormat) -> Self
pub fn control_protocol_format(self, format: ControlProtocolFormat) -> Self
Set control protocol format
Sourcepub fn include_partial_messages(self, include: bool) -> Self
pub fn include_partial_messages(self, include: bool) -> Self
Include partial assistant messages in streaming output
Sourcepub fn fork_session(self, fork: bool) -> Self
pub fn fork_session(self, fork: bool) -> Self
Enable fork_session behavior
Sourcepub fn setting_sources(self, sources: Vec<SettingSource>) -> Self
pub fn setting_sources(self, sources: Vec<SettingSource>) -> Self
Set setting sources
Sourcepub fn agents(self, agents: HashMap<String, AgentDefinition>) -> Self
pub fn agents(self, agents: HashMap<String, AgentDefinition>) -> Self
Define programmatic agents
Sourcepub fn cli_channel_buffer_size(self, size: usize) -> Self
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();Sourcepub fn build(self) -> ClaudeCodeOptions
pub fn build(self) -> ClaudeCodeOptions
Build the options
Trait Implementations§
Source§impl Debug for ClaudeCodeOptionsBuilder
impl Debug for ClaudeCodeOptionsBuilder
Source§impl Default for ClaudeCodeOptionsBuilder
impl Default for ClaudeCodeOptionsBuilder
Source§fn default() -> ClaudeCodeOptionsBuilder
fn default() -> ClaudeCodeOptionsBuilder
Auto Trait Implementations§
impl Freeze for ClaudeCodeOptionsBuilder
impl !RefUnwindSafe for ClaudeCodeOptionsBuilder
impl Send for ClaudeCodeOptionsBuilder
impl Sync for ClaudeCodeOptionsBuilder
impl Unpin for ClaudeCodeOptionsBuilder
impl !UnwindSafe for ClaudeCodeOptionsBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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