ClaudeAgentSDK.CLI (claude_agent_sdk v0.11.0)

Copy Markdown View Source

Centralized Claude CLI discovery and version tracking.

This module consolidates executable lookup logic and provides helpers for checking installation status, parsing the installed version, and warning when the detected version is below the supported minimum.

Summary

Functions

Attempts to find the Claude CLI executable.

Like find_executable/0 but raises when the CLI is not available.

Returns true if the Claude CLI is installed and discoverable.

Returns the minimum supported Claude CLI version.

Returns the recommended Claude CLI version for this SDK release.

Resolves the CLI executable, honoring option overrides.

Like resolve_executable/1 but raises when the CLI is not available.

Returns the installed Claude CLI version as a string.

True if the installed version meets or exceeds the minimum.

Emits a warning when the installed CLI is below the supported minimum or unknown.

Functions

find_executable()

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

Attempts to find the Claude CLI executable.

Tries candidates in order (claude-code, then claude) and returns {:ok, path} when found or {:error, :not_found} otherwise.

find_executable!()

@spec find_executable!() :: String.t()

Like find_executable/0 but raises when the CLI is not available.

installed?()

@spec installed?() :: boolean()

Returns true if the Claude CLI is installed and discoverable.

minimum_version()

@spec minimum_version() :: String.t()

Returns the minimum supported Claude CLI version.

resolve_executable(arg1)

@spec resolve_executable(ClaudeAgentSDK.Options.t() | nil) ::
  {:ok, String.t()} | {:error, :not_found}

Resolves the CLI executable, honoring option overrides.

When path_to_claude_code_executable or executable is set on the options, that value is used directly. Otherwise falls back to normal discovery.

resolve_executable!(options)

@spec resolve_executable!(ClaudeAgentSDK.Options.t() | nil) :: String.t()

Like resolve_executable/1 but raises when the CLI is not available.

version()

@spec version() :: {:ok, String.t()} | {:error, term()}

Returns the installed Claude CLI version as a string.

version_supported?()

@spec version_supported?() :: boolean()

True if the installed version meets or exceeds the minimum.

warn_if_outdated()

@spec warn_if_outdated() :: :ok

Emits a warning when the installed CLI is below the supported minimum or unknown.