claude

package module
v0.1.59-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 6 Imported by: 0

README

Claude Agent SDK for Golang

Go Reference Go Report Card

中文文档

A Go SDK for building AI agents with Claude Code. Provides a high-level API for querying Claude, managing interactive sessions, defining custom tools, intercepting agent behavior with hooks, and managing conversation sessions.

Table of Contents

Installation

go get github.com/next-bin/claude-agent-sdk-golang

Requirements:

Requirement Details
Go 1.26 or later
Claude Code CLI Installed and authenticated (install guide)

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    claude "github.com/next-bin/claude-agent-sdk-golang"
)

func main() {
    ctx := context.Background()

    msgChan, err := claude.Query(ctx, "What is 2 + 2?", nil)
    if err != nil {
        log.Fatal(err)
    }

    for msg := range msgChan {
        fmt.Printf("%v\n", msg)
    }
}

Basic Usage

Simple Query
ctx := context.Background()

// With default options
msgChan, err := claude.Query(ctx, "Hello Claude", nil)
With Configuration
import "github.com/next-bin/claude-agent-sdk-golang/types"

opts := &types.ClaudeAgentOptions{
    SystemPrompt: types.String("You are a helpful assistant"),
    MaxTurns:     types.Int(1),
}

msgChan, err := claude.Query(ctx, "Tell me a joke", opts)
Working Directory
opts := &types.ClaudeAgentOptions{
    CWD: "/path/to/project",
}
Tool Permissions

By default, Claude has access to the full Claude Code toolset. AllowedTools is an allowlist — listed tools are auto-approved, unlisted tools fall through to PermissionMode and CanUseTool. Use DisallowedTools to remove tools entirely.

opts := &types.ClaudeAgentOptions{
    AllowedTools:   []string{"Read", "Write", "Bash"},
    PermissionMode: types.PermissionModePtr(types.PermissionModeAcceptEdits),
}

Interactive Sessions

For bidirectional conversations with follow-up messages, use client.Client:

import "github.com/next-bin/claude-agent-sdk-golang/client"

c := client.NewWithOptions(&types.ClaudeAgentOptions{
    PermissionMode: types.PermissionModePtr(types.PermissionModeAcceptEdits),
})
defer c.Close()

// Connect with initial prompt
err := c.Connect(ctx, "Hello Claude")

// Read response
for msg := range c.ReceiveResponse(ctx) {
    fmt.Printf("%T: %v\n", msg, msg)
}

// Send follow-up
err = c.Query(ctx, "Can you explain more?")
Connect Without Initial Prompt
// Connect for interactive use
err := c.Connect(ctx)

// Send messages as needed
err = c.Query(ctx, "First question")
err = c.Query(ctx, "Follow-up question")

Custom Tools

Define custom tools as in-process MCP servers — no subprocess management needed.

import "github.com/next-bin/claude-agent-sdk-golang/sdkmcp"

// Define a tool
greetTool := sdkmcp.Tool(
    "greet",
    "Greet a user",
    sdkmcp.SimpleSchema(map[string]string{"name": "string"}),
    func(ctx context.Context, args map[string]interface{}) (*sdkmcp.ToolResult, error) {
        name := args["name"].(string)
        return sdkmcp.TextResult(fmt.Sprintf("Hello, %s!", name)), nil
    },
)

// Create an SDK MCP server
server := sdkmcp.CreateSdkMcpServer("my-tools", []*sdkmcp.SdkMcpTool{greetTool})

// Use with Claude
opts := &types.ClaudeAgentOptions{
    MCPServers:   map[string]types.McpServerConfig{"tools": server},
    AllowedTools: []string{"mcp__tools__greet"},
}
Mixed Server

Combine SDK MCP servers with external MCP servers:

opts := &types.ClaudeAgentOptions{
    MCPServers: map[string]types.McpServerConfig{
        "internal": sdkServer, // In-process
        "external": types.McpStdioServerConfig{
            Type:    "stdio",
            Command: "my-external-server",
        },
    },
}

Hooks

Hooks are functions invoked by the Claude Code application at specific points in the agent loop.

type bashHook struct{}

func (h *bashHook) Execute(input types.HookInput, toolUseID *string, ctx types.HookContext) (types.HookJSONOutput, error) {
    hookInput, ok := input.(types.PreToolUseHookInput)
    if !ok {
        return types.SyncHookJSONOutput{Continue_: types.Bool(true)}, nil
    }

    command, _ := hookInput.ToolInput["command"].(string)
    if strings.Contains(command, "rm -rf") {
        reason := "Dangerous command blocked by hook"
        return types.SyncHookJSONOutput{
            Continue_: types.Bool(true),
            HookSpecificOutput: types.PreToolUseHookSpecificOutput{
                HookEventName:            "PreToolUse",
                PermissionDecision:       types.String("deny"),
                PermissionDecisionReason: &reason,
            },
        }, nil
    }

    return types.SyncHookJSONOutput{Continue_: types.Bool(true)}, nil
}

opts := &types.ClaudeAgentOptions{
    AllowedTools: []string{"Bash"},
    Hooks: map[types.HookEvent][]types.HookMatcher{
        types.HookEventPreToolUse: {
            {Matcher: "Bash", Hooks: []types.HookCallback{&bashHook{}}},
        },
    },
}
Available Hook Events
Event Description
PreToolUse Before a tool is executed
PostToolUse After a tool executes
PostToolUseFailure When a tool fails
UserPromptSubmit When user submits a prompt
Stop When agent stops
SubagentStart When a sub-agent starts
SubagentStop When a sub-agent stops
PreCompact Before context compaction
Notification For notifications
PermissionRequest When permission is requested

Sessions API

Manage conversation sessions programmatically.

import claude "github.com/next-bin/claude-agent-sdk-golang"

// List sessions
sessions, err := claude.ListSessions("/path/to/project", 10, true)

// Get session messages
messages, err := claude.GetSessionMessages(sessionID, "/path/to/project", 0, 0)

// Get single session metadata
info := claude.GetSessionInfo(sessionID, "/path/to/project")

// Session mutations
err = claude.RenameSession(sessionID, "New Title", "/path/to/project")
err = claude.TagSession(sessionID, "experiment", "/path/to/project")
err = claude.DeleteSession(sessionID, "/path/to/project")
result, err := claude.ForkSession(sessionID, "/path/to/project", nil, nil)

Dynamic Control

Control an active session at runtime.

// Connect
err := c.Connect(ctx)

// Switch permission mode
err = c.SetPermissionMode(ctx, "acceptEdits")

// Switch model
err = c.SetModel(ctx, "claude-sonnet-4-6")

// Get context usage
usage, err := c.GetContextUsage(ctx)
fmt.Printf("Using %.1f%% of context\n", usage.Percentage)

// Get MCP server status
status, err := c.GetMCPStatus(ctx)

// Interrupt running conversation
err = c.Interrupt(ctx)

Transport Middleware

Middleware allows intercepting transport operations for logging, debugging, metrics collection, or message transformation.

import "github.com/next-bin/claude-agent-sdk-golang/transport"

// Create logging middleware
loggingMiddleware := transport.NewLoggingMiddleware(
    func(ctx context.Context, data string) {
        log.Printf("[WRITE] %s", data)
    },
    func(ctx context.Context, msg map[string]interface{}) {
        log.Printf("[READ] type=%s", msg["type"])
    },
)

// Create metrics middleware
metricsMiddleware := transport.NewMetricsMiddleware()

// Wrap transport with middleware
wrappedTransport := transport.NewMiddlewareTransport(
    baseTransport,
    loggingMiddleware,
    metricsMiddleware,
)

// Use wrapped transport with client
c := client.NewWithOptions(&types.ClaudeAgentOptions{})
c.Connect(ctx)
Custom Middleware
type myMiddleware struct{}

func (m *myMiddleware) InterceptWrite(ctx context.Context, data string) (string, error) {
    // Modify or log write data
    return data, nil
}

func (m *myMiddleware) InterceptRead(ctx context.Context, msg map[string]interface{}) (map[string]interface{}, error) {
    // Filter or transform read messages
    if msg["type"] == "filtered_type" {
        return nil, nil // Filter out this message
    }
    return msg, nil
}

Functional Options

Functional options provide a flexible way to configure SDK operations without large parameter structs.

import "github.com/next-bin/claude-agent-sdk-golang/option"

// Create configuration with functional options
config, err := option.NewRequestConfig(
    option.WithSystemPrompt("You are a helpful assistant"),
    option.WithModel(types.ModelSonnet),
    option.WithMaxTurns(5),
    option.WithPermissionMode(types.PermissionModeAcceptEdits),
)

// Compose options
baseOptions := []option.RequestOption{
    option.WithSystemPrompt("Base prompt"),
    option.WithMaxTurns(10),
}

extraOptions := []option.RequestOption{
    option.WithModel(types.ModelOpus),
}

allOptions := append(baseOptions, extraOptions...)
config, err := option.NewRequestConfig(allOptions...)
Available Options
Option Description
WithSystemPrompt(prompt) Set system prompt
WithModel(model) Set AI model
WithMaxTurns(turns) Set max conversation turns
WithPermissionMode(mode) Set permission mode
WithTools(tools) Set allowed tools
WithHooks(hooks) Set hook configurations
WithMCPServers(servers) Set MCP server configs
WithCWD(dir) Set working directory
WithEffort(level) Set effort level (low/medium/high/max)

Error Handling

import claude "github.com/next-bin/claude-agent-sdk-golang"

msgChan, err := claude.Query(ctx, "Hello", nil)
if err != nil {
    switch {
    case claude.ErrNotInstalled:
        fmt.Println("Please install Claude Code")
    case claude.ErrConnectionFailed:
        fmt.Println("Failed to connect")
    case claude.ErrTimeout:
        fmt.Println("Query timed out")
    default:
        fmt.Printf("Error: %v\n", err)
    }
}

Examples

Example Description
quick_start Basic query
streaming_mode Interactive client
mcp_sdk_server Custom tools
hooks Hook system
tool_permission Permission callbacks
agents Custom agents
middleware Transport middleware
options Functional options

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Add tests for new functionality
  4. Submit a pull request
Development
git clone https://github.com/next-bin/claude-agent-sdk-golang.git
cd claude-agent-sdk-golang
go mod download
go test ./...
go vet ./...

Documentation

Overview

Package claude provides the Claude Agent SDK for Go.

This SDK enables building AI agents with Claude Code. It provides both one-shot query functionality and interactive session management with support for tools, hooks, MCP servers, and session management.

Quick Start

For simple one-shot queries, use the Query function:

msgChan, err := claude.Query(ctx, "What is 2+2?", nil)
if err != nil {
    log.Fatal(err)
}
for msg := range msgChan {
    fmt.Printf("%v\n", msg)
}

Interactive Sessions

For bidirectional, interactive conversations, create a Client:

c := client.NewWithOptions(&types.ClaudeAgentOptions{
    SystemPrompt: types.String("You are a helpful assistant"),
})
defer c.Close()

err := c.Connect(ctx, "Hello, Claude!")
if err != nil {
    log.Fatal(err)
}

for msg := range c.ReceiveResponse(ctx) {
    fmt.Printf("%T: %v\n", msg, msg)
}

Configuration

Use ClaudeAgentOptions to configure behavior:

opts := &types.ClaudeAgentOptions{
    SystemPrompt:   types.String("You are a helpful assistant"),
    MaxTurns:       types.Int(5),
    AllowedTools:   []string{"Read", "Write", "Bash"},
    PermissionMode: types.PermissionModePtr(types.PermissionModeAcceptEdits),
}

See types.ClaudeAgentOptions for all available options.

Sessions API

Manage conversation sessions:

sessions, err := claude.ListSessions("/path/to/project", 10, true)
messages, err := claude.GetSessionMessages(sessionID, "", 0, 0)
err = claude.RenameSession(sessionID, "New Title", "")
err = claude.ForkSession(sessionID, "", nil, nil)

See the examples directory for more usage examples.

Index

Constants

View Source
const CLIVersion = "2.1.109"

CLIVersion is the bundled Claude Code CLI version.

Variables

View Source
var (
	// ErrNoAPIKey is returned when no API key is provided.
	ErrNoAPIKey = sdkerrors.ErrNoAPIKey

	// ErrNotInstalled is returned when the Claude CLI is not installed.
	ErrNotInstalled = sdkerrors.ErrNotInstalled

	// ErrConnectionFailed is returned when connection to Claude CLI fails.
	ErrConnectionFailed = sdkerrors.ErrConnectionFailed

	// ErrTimeout is returned when an operation times out.
	ErrTimeout = sdkerrors.ErrTimeout

	// ErrInterrupted is returned when an operation is interrupted.
	ErrInterrupted = sdkerrors.ErrInterrupted
)

Re-export errors for convenience.

Functions

func DeleteSession

func DeleteSession(sessionID, directory string) error

DeleteSession deletes a session file from the project directory.

Example:

err := claude.DeleteSession("550e8400-e29b-41d4-a716-446655440000", "/path/to/project")

func GetSessionInfo

func GetSessionInfo(sessionID, directory string) *types.SDKSessionInfo

GetSessionInfo reads metadata for a single session by ID.

Wraps readSessionLite for one file — no O(n) directory scan. Directory resolution matches GetSessionMessages: directory is the project path; when omitted, all project directories are searched for the session file.

Returns SDKSessionInfo for the session, or nil if the session file is not found, is a sidechain session, or has no extractable summary.

Example:

// Look up a session in a specific project
info := claude.GetSessionInfo("550e8400-e29b-41d4-a716-446655440000", "/path/to/project")
if info != nil {
    fmt.Println(info.Summary)
}

// Search all projects for a session
info := claude.GetSessionInfo("550e8400-e29b-41d4-a716-446655440000", "")

func GetSessionMessages

func GetSessionMessages(sessionID, directory string, limit, offset int) ([]types.SessionMessage, error)

GetSessionMessages reads a session's conversation messages from its JSONL transcript file.

Parses the full JSONL, builds the conversation chain via parentUuid links, and returns user/assistant messages in chronological order.

The limit parameter limits the number of messages returned (0 means no limit). The offset parameter skips the first N messages.

Example:

messages, err := claude.GetSessionMessages("550e8400-e29b-41d4-a716-446655440000", "/path/to/project", 10, 0)

func ListSessions

func ListSessions(directory string, limit int, includeWorktrees bool) ([]types.SDKSessionInfo, error)

ListSessions lists sessions with metadata extracted from stat + head/tail reads.

When directory is provided, returns sessions for that project directory and its git worktrees. When empty, returns sessions across all projects.

The limit parameter limits the number of sessions returned (0 means no limit). The includeWorktrees parameter controls whether to include git worktree sessions.

Example:

// List sessions for current directory
sessions, err := claude.ListSessions("/path/to/project", 10, true)

// List all sessions
sessions, err := claude.ListSessions("", 0, false)

func NewClient

func NewClient() *client.Client

NewClient creates a new Claude client with default options.

Example:

client := claude.NewClient()
defer client.Close()
result, err := client.Query(ctx, "Hello, Claude!")

func NewClientWithOptions

func NewClientWithOptions(opts *types.Options) *client.Client

NewClientWithOptions creates a new Claude client with custom options.

Example:

client := claude.NewClientWithOptions(&types.Options{
    Model:       types.ModelSonnet,
    MaxTokens:   4096,
    Temperature: 0.7,
})

func Query

func Query(ctx context.Context, prompt string, opts *types.ClaudeAgentOptions) (<-chan types.Message, error)

Query sends a one-shot query to Claude and returns messages through a channel.

This is the simplest way to interact with Claude. Pass a prompt and optional configuration, and receive messages through a channel. The channel is automatically closed when the query completes.

For interactive conversations with follow-up messages, dynamic control, or custom tools/hooks, use client.Client instead.

Parameters:

  • ctx: context for cancellation
  • prompt: the user prompt to send
  • opts: optional configuration (nil for defaults)

Returns a channel of Message types and an error if the query fails to start.

Example:

msgChan, err := claude.Query(ctx, "What is 2+2?", nil)
if err != nil {
    log.Fatal(err)
}
for msg := range msgChan {
    fmt.Printf("%v\n", msg)
}

With options:

opts := &types.ClaudeAgentOptions{
    SystemPrompt: types.String("You are a helpful assistant"),
    MaxTurns:     types.Int(1),
}
msgChan, err := claude.Query(ctx, "Tell me a joke", opts)

func QueryWithClient

func QueryWithClient(ctx context.Context, c *client.Client, prompt string) (<-chan types.Message, error)

QueryWithClient sends a query using an existing client.

Use this when you have a pre-configured client with custom options.

Example:

c := claude.NewClientWithOptions(&types.ClaudeAgentOptions{
    Model: types.String(types.ModelSonnet),
})
msgChan, err := claude.QueryWithClient(ctx, c, "Hello!")

func RenameSession

func RenameSession(sessionID, title, directory string) error

RenameSession renames a session by appending a custom-title entry. list_sessions reads the LAST custom-title from the file tail, so repeated calls are safe.

Example:

err := claude.RenameSession("550e8400-e29b-41d4-a716-446655440000", "My refactoring session", "/path/to/project")

func TagSession

func TagSession(sessionID, tag, directory string) error

TagSession tags a session. Pass empty string to clear the tag. list_sessions reads the LAST tag from the file tail, so repeated calls are safe.

Tags are Unicode-sanitized before storing for CLI filter compatibility.

Example:

err := claude.TagSession("550e8400-e29b-41d4-a716-446655440000", "experiment", "/path/to/project")

Types

type AgentDefinition

type AgentDefinition = types.AgentDefinition

Agent types

type AssistantMessage

type AssistantMessage = types.AssistantMessage

AssistantMessage represents a message from the assistant.

type CLIError

type CLIError = sdkerrors.CLIError

CLIError represents an error from the Claude CLI.

type Client

type Client = client.Client

Client is an alias for the client type.

type ContentBlock

type ContentBlock = types.ContentBlock

ContentBlock represents a content block in a message.

type ContextUsageCategory

type ContextUsageCategory = types.ContextUsageCategory

Context usage types (v0.1.50)

type ContextUsageResponse

type ContextUsageResponse = types.ContextUsageResponse

Re-export types for convenience.

type ForkSessionResult

type ForkSessionResult = sessions.ForkSessionResult

ForkSessionResult represents the result of a fork_session operation.

func ForkSession

func ForkSession(sessionID, directory string, upToMessageID *string, title *string) (*ForkSessionResult, error)

ForkSession creates a fork (copy) of a session with remapped UUIDs.

The fork preserves the conversation structure but assigns new UUIDs to all messages. Use upToMessageID to slice the fork at a specific message (inclusive). Use title to set a custom title; default is original title + " (fork)".

Example:

// Simple fork
result, err := claude.ForkSession("550e8400-e29b-41d4-a716-446655440000", "/path/to/project", nil, nil)

// Fork with custom title
title := "My Forked Session"
result, err := claude.ForkSession(sessionID, directory, nil, &title)

// Fork up to a specific message
msgID := "previous-message-uuid"
result, err := claude.ForkSession(sessionID, directory, &msgID, nil)

type HookCallback

type HookCallback = types.HookCallback

Re-export types for convenience.

type HookContext

type HookContext = types.HookContext

Re-export types for convenience.

type HookEvent

type HookEvent = types.HookEvent

Hook types

type HookInput

type HookInput = types.HookInput

Re-export types for convenience.

type HookMatcher

type HookMatcher = types.HookMatcher

Re-export types for convenience.

type McpHttpServerConfig

type McpHttpServerConfig = types.McpHttpServerConfig

Re-export types for convenience.

type McpSSEServerConfig

type McpSSEServerConfig = types.McpSSEServerConfig

Re-export types for convenience.

type McpServerConfig

type McpServerConfig = types.McpServerConfig

MCP types

type McpStdioServerConfig

type McpStdioServerConfig = types.McpStdioServerConfig

Re-export types for convenience.

type Message

type Message = types.Message

Message represents a message in a conversation.

type Options

type Options = types.Options

Options represents configuration options for the SDK.

type PermissionResult

type PermissionResult = types.PermissionResult

Permission types

type PermissionResultAllow

type PermissionResultAllow = types.PermissionResultAllow

Re-export types for convenience.

type PermissionResultDeny

type PermissionResultDeny = types.PermissionResultDeny

Re-export types for convenience.

type PermissionUpdate

type PermissionUpdate = types.PermissionUpdate

Re-export types for convenience.

type QueryResult

type QueryResult = types.QueryResult

QueryResult represents the result of a query operation.

type ResultMessage

type ResultMessage = types.ResultMessage

ResultMessage represents the final result of a conversation.

type SDKError

type SDKError = sdkerrors.SDKError

SDKError represents an error from the SDK.

type SDKSessionInfo

type SDKSessionInfo = types.SDKSessionInfo

Session types (v0.1.46)

type SessionMessage

type SessionMessage = types.SessionMessage

Re-export types for convenience.

type StreamEvent

type StreamEvent = types.StreamEvent

StreamEvent represents a streaming event.

type SystemMessage

type SystemMessage = types.SystemMessage

SystemMessage represents a system message.

type SystemPromptFile

type SystemPromptFile = types.SystemPromptFile

Configuration types

type TaskBudget

type TaskBudget = types.TaskBudget

Re-export types for convenience.

type TextBlock

type TextBlock = types.TextBlock

TextBlock represents a text content block.

type ThinkingBlock

type ThinkingBlock = types.ThinkingBlock

ThinkingBlock represents a thinking content block.

type ToolExecutionError

type ToolExecutionError = sdkerrors.ToolExecutionError

ToolExecutionError represents an error during tool execution.

type ToolPermissionContext

type ToolPermissionContext = types.ToolPermissionContext

Re-export types for convenience.

type ToolResultBlock

type ToolResultBlock = types.ToolResultBlock

ToolResultBlock represents a tool result content block.

type ToolUseBlock

type ToolUseBlock = types.ToolUseBlock

ToolUseBlock represents a tool use content block.

type UserMessage

type UserMessage = types.UserMessage

UserMessage represents a message from the user.

Directories

Path Synopsis
Package client provides the Claude SDK client for interactive sessions.
Package client provides the Claude SDK client for interactive sessions.
Package config provides configuration detection for the Claude Agent SDK.
Package config provides configuration detection for the Claude Agent SDK.
Package e2e_tests contains end-to-end tests for the Claude Agent SDK.
Package e2e_tests contains end-to-end tests for the Claude Agent SDK.
Package errors defines error types for the Claude Agent SDK.
Package errors defines error types for the Claude Agent SDK.
examples
agents command
Example agents demonstrates how to configure and use custom agents with the Claude Agent SDK for Go.
Example agents demonstrates how to configure and use custom agents with the Claude Agent SDK for Go.
budget command
Example budget demonstrates using MaxBudgetUSD and MaxTurns options with cost tracking.
Example budget demonstrates using MaxBudgetUSD and MaxTurns options with cost tracking.
complete command
Example complete demonstrates a comprehensive integration of Claude Agent SDK features.
Example complete demonstrates a comprehensive integration of Claude Agent SDK features.
filesystem_agents command
Example filesystem_agents demonstrates filesystem-focused agent configurations in the Claude Agent SDK for Go.
Example filesystem_agents demonstrates filesystem-focused agent configurations in the Claude Agent SDK for Go.
hooks command
Example hooks demonstrates hook registration and usage in the Claude Agent SDK for Go.
Example hooks demonstrates hook registration and usage in the Claude Agent SDK for Go.
include_partial_messages command
Example include_partial_messages demonstrates handling partial/streaming messages in the Claude Agent SDK for Go.
Example include_partial_messages demonstrates handling partial/streaming messages in the Claude Agent SDK for Go.
internal
Package internal provides shared utilities for SDK examples.
Package internal provides shared utilities for SDK examples.
mcp_calculator command
Example mcp_calculator demonstrates how to create an in-process MCP server with calculator tools using the Claude Agent SDK for Go.
Example mcp_calculator demonstrates how to create an in-process MCP server with calculator tools using the Claude Agent SDK for Go.
mcp_control command
Example: MCP Control Operations
Example: MCP Control Operations
mcp_sdk_server command
Example mcp_sdk_server demonstrates creating an in-process MCP server with custom tools.
Example mcp_sdk_server demonstrates creating an in-process MCP server with custom tools.
mcp_sdk_simple command
Example mcp_sdk_simple demonstrates using the sdkmcp convenience package.
Example mcp_sdk_simple demonstrates using the sdkmcp convenience package.
middleware command
Package main demonstrates transport middleware usage.
Package main demonstrates transport middleware usage.
options command
Package main demonstrates functional options usage.
Package main demonstrates functional options usage.
plugin_example command
Example plugin_example demonstrates SDK plugin configuration in the Claude Agent SDK for Go.
Example plugin_example demonstrates SDK plugin configuration in the Claude Agent SDK for Go.
quick_start command
Example quick_start demonstrates basic usage of the Claude Agent SDK for Go.
Example quick_start demonstrates basic usage of the Claude Agent SDK for Go.
setting_sources command
Example setting_sources demonstrates how to control which settings are loaded.
Example setting_sources demonstrates how to control which settings are loaded.
stderr_callback command
Example stderr_callback demonstrates handling stderr output in the Claude Agent SDK for Go.
Example stderr_callback demonstrates handling stderr output in the Claude Agent SDK for Go.
streaming_goroutines command
Example goroutines demonstrates concurrent patterns using goroutines and channels with the Claude Agent SDK for Go.
Example goroutines demonstrates concurrent patterns using goroutines and channels with the Claude Agent SDK for Go.
streaming_interactive command
Example streaming_interactive demonstrates interactive streaming patterns with the Claude Agent SDK for Go.
Example streaming_interactive demonstrates interactive streaming patterns with the Claude Agent SDK for Go.
streaming_mode command
Example streaming_mode demonstrates using the Claude SDK Client with Connect() for streaming conversations.
Example streaming_mode demonstrates using the Claude SDK Client with Connect() for streaming conversations.
system_prompt command
Example system_prompt demonstrates system prompt configuration in the Claude Agent SDK for Go.
Example system_prompt demonstrates system prompt configuration in the Claude Agent SDK for Go.
task_messages command
Example: Task Messages Handling
Example: Task Messages Handling
tool_permission command
Example tool_permission demonstrates tool permission handling in the Claude Agent SDK for Go.
Example tool_permission demonstrates tool permission handling in the Claude Agent SDK for Go.
tools_option command
Example tools_option demonstrates using Tools, AllowedTools, and DisallowedTools options with the Claude Agent SDK for Go.
Example tools_option demonstrates using Tools, AllowedTools, and DisallowedTools options with the Claude Agent SDK for Go.
internal
messageparser
Package messageparser provides functionality to parse raw JSON messages from the Claude CLI into typed Message objects.
Package messageparser provides functionality to parse raw JSON messages from the Claude CLI into typed Message objects.
queryimpl
Package query provides internal query implementation for the Claude Agent SDK.
Package query provides internal query implementation for the Claude Agent SDK.
sessions
Package sessions provides functions for listing and reading Claude Code sessions.
Package sessions provides functions for listing and reading Claude Code sessions.
transportimpl
Package transport provides transport layer implementations for the Claude Agent SDK.
Package transport provides transport layer implementations for the Claude Agent SDK.
Package option provides functional options for the Claude Agent SDK.
Package option provides functional options for the Claude Agent SDK.
Package query provides a one-shot query function for Claude.
Package query provides a one-shot query function for Claude.
Package sdkmcp provides convenience functions for creating in-process MCP servers.
Package sdkmcp provides convenience functions for creating in-process MCP servers.
Package transport provides the transport interface for Claude SDK.
Package transport provides the transport interface for Claude SDK.
Package types defines the core types used throughout the Claude Agent SDK.
Package types defines the core types used throughout the Claude Agent SDK.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL