//! `query()` with a custom system prompt, model selection, and `cwd`. //! //! Run: //! //! ```sh //! cargo run --example with_options //! ``` use claude_agent_sdk::{ ClaudeAgentOptions, ContentBlock, Effort, Message, PermissionMode, query, }; use tokio_stream::StreamExt; #[tokio::main] async fn main() -> anyhow::Result<()> { let opts = ClaudeAgentOptions::new() .with_system_prompt("You are a senior Rust engineer. Be terse.") .with_model("claude-sonnet-4-5") .with_max_turns(1) .with_effort(Effort::Low) .with_permission_mode(PermissionMode::Plan); let mut stream = query( "In one sentence, what does the `?` operator do in Rust?", opts, ) .await?; while let Some(item) = stream.next().await { match item? { Message::Assistant(a) => { for block in &a.message.content { if let ContentBlock::Text(t) = block { println!("{}", t.text); } } } Message::Result(_) => break, _ => {} } } Ok(()) }