pub struct ClaudeCliBuilder { /* private fields */ }Expand description
Builder for creating Claude CLI commands in JSON streaming mode
This builder automatically configures Claude to use:
--printmode for non-interactive operation--output-format stream-jsonfor streaming JSON responses--input-format stream-jsonfor JSON input--replay-user-messagesto echo back user messages
Implementations§
Source§impl ClaudeCliBuilder
impl ClaudeCliBuilder
Sourcepub fn debug<S: Into<String>>(self, filter: Option<S>) -> Self
pub fn debug<S: Into<String>>(self, filter: Option<S>) -> Self
Enable debug mode with optional filter
Sourcepub fn dangerously_skip_permissions(self, skip: bool) -> Self
pub fn dangerously_skip_permissions(self, skip: bool) -> Self
Skip all permission checks (dangerous!)
Sourcepub fn allowed_tools<I, S>(self, tools: I) -> Self
pub fn allowed_tools<I, S>(self, tools: I) -> Self
Add allowed tools
Sourcepub fn disallowed_tools<I, S>(self, tools: I) -> Self
pub fn disallowed_tools<I, S>(self, tools: I) -> Self
Add disallowed tools
Sourcepub fn mcp_config<I, S>(self, configs: I) -> Self
pub fn mcp_config<I, S>(self, configs: I) -> Self
Add MCP configuration
Sourcepub fn append_system_prompt<S: Into<String>>(self, prompt: S) -> Self
pub fn append_system_prompt<S: Into<String>>(self, prompt: S) -> Self
Append a system prompt
Sourcepub fn permission_mode(self, mode: PermissionMode) -> Self
pub fn permission_mode(self, mode: PermissionMode) -> Self
Set permission mode
Sourcepub fn continue_conversation(self, continue_conv: bool) -> Self
pub fn continue_conversation(self, continue_conv: bool) -> Self
Continue the most recent conversation
Sourcepub fn resume<S: Into<String>>(self, session_id: Option<S>) -> Self
pub fn resume<S: Into<String>>(self, session_id: Option<S>) -> Self
Resume a specific conversation
Sourcepub fn fallback_model<S: Into<String>>(self, model: S) -> Self
pub fn fallback_model<S: Into<String>>(self, model: S) -> Self
Set fallback model for overload situations
Sourcepub fn add_directories<I, P>(self, dirs: I) -> Self
pub fn add_directories<I, P>(self, dirs: I) -> Self
Add directories for tool access
Sourcepub fn strict_mcp_config(self, strict: bool) -> Self
pub fn strict_mcp_config(self, strict: bool) -> Self
Use only MCP servers from config
Sourcepub fn session_id(self, id: Uuid) -> Self
pub fn session_id(self, id: Uuid) -> Self
Set a specific session ID (must be a UUID)
Sourcepub fn oauth_token<S: Into<String>>(self, token: S) -> Self
pub fn oauth_token<S: Into<String>>(self, token: S) -> Self
Set OAuth token for authentication (must start with “sk-ant-oat”)
Sourcepub fn api_key<S: Into<String>>(self, key: S) -> Self
pub fn api_key<S: Into<String>>(self, key: S) -> Self
Set API key for authentication (must start with “sk-ant-api”)
Sourcepub fn permission_prompt_tool<S: Into<String>>(self, tool: S) -> Self
pub fn permission_prompt_tool<S: Into<String>>(self, tool: S) -> Self
Enable bidirectional tool permission protocol via stdio
When enabled, Claude CLI will send permission requests via stdout and expect responses via stdin. Use “stdio” for standard I/O based permission handling.
§Example
use claude_codes::ClaudeCliBuilder;
let builder = ClaudeCliBuilder::new()
.permission_prompt_tool("stdio")
.model("sonnet");Sourcepub fn build_command(self) -> Command
pub fn build_command(self) -> Command
Build a Command without spawning (for testing or manual execution)
Sourcepub fn spawn_sync(self) -> Result<Child>
pub fn spawn_sync(self) -> Result<Child>
Spawn the Claude process using synchronous std::process
Trait Implementations§
Source§impl Clone for ClaudeCliBuilder
impl Clone for ClaudeCliBuilder
Source§fn clone(&self) -> ClaudeCliBuilder
fn clone(&self) -> ClaudeCliBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more