Skip to main content

ito_core/harness/
claude_code.rs

1use super::streaming_cli::CliHarness;
2use super::types::{HarnessName, HarnessRunConfig};
3
4/// Runs the `claude` CLI in non-interactive print mode (`claude -p`).
5///
6/// Selected via `ito ralph --harness claude`; requires the Claude Code CLI on PATH.
7///
8/// # Examples
9///
10/// ```
11/// use ito_core::harness::{ClaudeCodeHarness, Harness, HarnessName};
12///
13/// let h = ClaudeCodeHarness;
14/// assert_eq!(h.name(), HarnessName::Claude);
15/// assert!(h.streams_output());
16/// ```
17#[derive(Debug, Default)]
18pub struct ClaudeCodeHarness;
19
20impl CliHarness for ClaudeCodeHarness {
21    fn harness_name(&self) -> HarnessName {
22        HarnessName::Claude
23    }
24
25    fn binary(&self) -> &str {
26        "claude"
27    }
28
29    fn build_args(&self, config: &HarnessRunConfig) -> Vec<String> {
30        let mut args = Vec::new();
31        if let Some(model) = config.model.as_deref() {
32            args.push("--model".to_string());
33            args.push(model.to_string());
34        }
35        if config.allow_all {
36            args.push("--dangerously-skip-permissions".to_string());
37        }
38        args.push("-p".to_string());
39        args.push(config.prompt.clone());
40        args
41    }
42}
43
44#[cfg(test)]
45#[path = "claude_code_tests.rs"]
46mod claude_code_tests;