ClaudeCode.CLI (ClaudeCode v0.1.0)

View Source

Handles CLI subprocess management for Claude Code.

This module is responsible for:

  • Finding the claude binary
  • Building command arguments from validated options
  • Managing the subprocess lifecycle

Summary

Functions

Builds the command and arguments for running the Claude CLI.

Finds the claude binary in the system PATH.

Validates that the Claude CLI is properly installed and accessible.

Functions

build_command(prompt, api_key, opts, session_id \\ nil)

@spec build_command(String.t(), String.t(), keyword(), String.t() | nil) ::
  {:ok, {String.t(), [String.t()]}} | {:error, term()}

Builds the command and arguments for running the Claude CLI.

Accepts validated options from the Options module and converts them to CLI flags. If a session_id is provided, automatically adds --resume flag for session continuity.

Returns {:ok, {executable, args}} or {:error, reason}.

find_binary()

@spec find_binary() :: {:ok, String.t()} | {:error, :not_found}

Finds the claude binary in the system PATH.

Returns {:ok, path} if found, {:error, :not_found} otherwise.

validate_installation()

@spec validate_installation() :: :ok | {:error, term()}

Validates that the Claude CLI is properly installed and accessible.