Skip to main content

devflow_core/agents/
claude.rs

1//! Claude Code agent adapter.
2//!
3//! Launches `claude -p "<prompt>"` in non-interactive mode with structured
4//! JSON output. Claude runs headless — no trust dialogs, no user prompts.
5
6use super::AgentAdapter;
7
8pub struct ClaudeAgent;
9
10impl AgentAdapter for ClaudeAgent {
11    fn name(&self) -> &'static str {
12        "Claude Code"
13    }
14
15    fn exec_command(
16        &self,
17        _phase: u32,
18        prompt: &str,
19        _extra_writable_roots: &[std::path::PathBuf],
20    ) -> (&'static str, Vec<String>) {
21        (
22            "claude",
23            vec![
24                "-p".into(),
25                prompt.to_string(),
26                "--output-format".into(),
27                "json".into(),
28                "--dangerously-skip-permissions".into(),
29            ],
30        )
31    }
32
33    fn completion_signal_detected(&self, _output: &str) -> bool {
34        // Claude exits cleanly when done; monitor detects exit via kill -0.
35        false
36    }
37}