ClaudeCode.Message.SystemMessage (ClaudeCode v0.16.0)

View Source

Represents a system initialization message from the Claude CLI.

System messages provide session setup information including available tools, MCP servers, model, and permission mode.

For conversation compaction boundaries, use ClaudeCode.Message.CompactBoundaryMessage.

Matches the official SDK schema:

{
  type: "system",
  subtype: "init",
  uuid: string,
  apiKeySource: string,
  cwd: string,
  session_id: string,
  tools: string[],
  mcp_servers: { name: string, status: string }[],
  model: string,
  permissionMode: "default" | "acceptEdits" | "bypassPermissions" | "plan",
  slash_commands: string[],
  output_style: string,
  claude_code_version: string,
  agents: string[],
  skills: string[],
  plugins: string[]
}

Summary

Functions

Creates a new SystemMessage from JSON data.

Type guard to check if a value is a SystemMessage.

Types

t()

@type t() :: %ClaudeCode.Message.SystemMessage{
  agents: [String.t()],
  api_key_source: String.t(),
  claude_code_version: String.t() | nil,
  cwd: String.t(),
  mcp_servers: [ClaudeCode.Types.mcp_server()],
  model: String.t(),
  output_style: String.t(),
  permission_mode: ClaudeCode.Types.permission_mode(),
  plugins: [String.t()],
  session_id: ClaudeCode.Types.session_id(),
  skills: [String.t()],
  slash_commands: [String.t()],
  subtype: :init,
  tools: [String.t()],
  type: :system,
  uuid: String.t()
}

Functions

new(json)

@spec new(map()) ::
  {:ok, t()} | {:error, :invalid_message_type | {:missing_fields, [atom()]}}

Creates a new SystemMessage from JSON data.

Examples

iex> SystemMessage.new(%{"type" => "system", "subtype" => "init", ...})
{:ok, %SystemMessage{...}}

iex> SystemMessage.new(%{"type" => "assistant"})
{:error, :invalid_message_type}

system_message?(arg1)

@spec system_message?(any()) :: boolean()

Type guard to check if a value is a SystemMessage.