Skip to content

Rewrite SDK to Claude Code SDK for Go with Anthropic Focus#8

Draft
ryanhill4L wants to merge 1 commit intomainfrom
terragon/rewrite-anthropic-sdk-go
Draft

Rewrite SDK to Claude Code SDK for Go with Anthropic Focus#8
ryanhill4L wants to merge 1 commit intomainfrom
terragon/rewrite-anthropic-sdk-go

Conversation

@ryanhill4L
Copy link
Copy Markdown
Owner

Summary

  • Complete rewrite of the SDK aligning with the official Python Claude Code SDK architecture
  • Focus exclusively on Anthropic Claude API, removing multi-provider support
  • Introduces dual interface pattern: simple stateless queries and interactive client for conversations
  • Replaces agents and runners with a unified client interface
  • Implements new permission system replacing guardrails
  • Adds hooks system replacing tracing for event-driven extensibility
  • Adds native streaming support and built-in session management
  • Simplifies package structure and improves type safety
  • Removes agent handoffs in favor of tool-based delegation

Changes

Core SDK

  • New claudecode package as main entry point
  • Added NewClient and Query functions for interactive and simple query usage
  • Removed old agents, providers, and runner packages
  • Introduced client package managing conversation state, tools, hooks, permissions, and transport
  • Integrated official anthropic-sdk-go for API communication
  • Added comprehensive error handling in errors package

Package Structure

  • Simplified imports to claudecode and pkg/types, pkg/tools, etc.
  • Removed multi-provider support; only Anthropic transport remains

Features

  • Dual interface: Query for simple one-off queries, Client for stateful conversations
  • Tools system enhanced with type safety and permission controls
  • Permissions replace guardrails with callback-based access control
  • Hooks replace tracing with event hooks for pre/post message and tool use
  • Session management built-in with SQLite backend
  • Streaming support for real-time response chunks

Examples

  • Removed old multi-provider and multi-agent examples
  • Added new examples demonstrating simple queries, interactive client, tools, permissions, hooks, and streaming

Documentation

  • Updated README to reflect new architecture, usage patterns, and migration guide
  • Added MIGRATION.md detailing step-by-step migration from v1 to v2

Migration Notes

  • No more multi-provider or agent handoffs; use tools and single Anthropic client
  • Replace old agent/runner code with claudecode.NewClient and client.SendMessage
  • Update imports to new package structure
  • Implement permission callbacks instead of guardrails
  • Use hooks for event handling instead of tracing

Test Plan

  • Verified all new examples run successfully
  • Manual testing of simple queries and interactive client
  • Permission and hook callbacks tested with example scenarios
  • Streaming tested with real-time output

This rewrite modernizes the SDK, focusing on Anthropic Claude with a clean, idiomatic Go interface and improved developer experience.

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/cb2fc764-f070-499f-a35c-c65607bbe0d0

- Complete rewrite following the architecture of the official Python Claude Code SDK
- Focus exclusively on Anthropic's Claude API with no multi-provider support
- Introduce dual interface pattern: simple stateless queries and interactive client
- Replace Agent/Runner with a unified Client interface
- Replace guardrails with a new permission system
- Replace tracing with an event-driven hook system
- Add native streaming support for real-time responses
- Add built-in session management with SQLite backend
- Improve tool system with type safety and permission controls
- Simplify package structure and imports
- Provide comprehensive migration guide and updated examples
- Add detailed error handling and custom error types
- Remove agent handoffs in favor of tools for delegation

This major update modernizes the SDK, improves usability, security, and aligns with Anthropic's official SDK.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant