Skip to main content

Session-persistent client for Claude Code SDK

Project description

Claude Code Session Client

A session-persistent client wrapper for the Claude Code SDK Python that provides automatic conversation persistence and session resumption capabilities.

Features

  • Automatic Session Persistence: Conversations are automatically saved to local storage
  • Session Resumption: Resume previous conversations using session IDs
  • Context Retention: Maintain conversation context across client restarts
  • Multi-turn Conversations: Seamlessly handle complex multi-turn interactions
  • Storage Management: Organized session storage with metadata tracking

Installation

pip install claude-code-session-client

Quick Start

import trio
from pathlib import Path
from claude_code_session_client import SessionPersistentClient
from claude_code_sdk import ClaudeCodeOptions

async def main():
    storage_path = Path("./sessions")
    
    async with SessionPersistentClient(
        options=ClaudeCodeOptions(),
        storage_path=storage_path
    ) as client:
        # Start conversation
        await client.query("Hello! What can you help me with?")
        
        async for message in client.receive_response():
            # Handle responses
            print(message)

if __name__ == "__main__":
    trio.run(main)

Session Resumption

# Resume a previous session
session_id = "your-session-id"
await client.start_or_resume_session(session_id)

Requirements

  • Python 3.10+
  • claude-code-sdk-python
  • trio

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_code_session_client-0.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_code_session_client-0.0.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file claude_code_session_client-0.0.1.tar.gz.

File metadata

File hashes

Hashes for claude_code_session_client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 79b40d110d7828b2e58a4321efc49c63dae1e25e0b47b11e7981688c612eb53c
MD5 0640afd7c385a03a9e657710c5acdf5b
BLAKE2b-256 8557dfb355aae06d57e5f45879c9fe688d0b37d116681c2b37299ffdc8fcec1b

See more details on using hashes here.

File details

Details for the file claude_code_session_client-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_code_session_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad2aba3ffcd3d5d5efd9e2c048c2e442957daee1c8c8cf7fc75329f2f7a61fab
MD5 711f675afd77159cfe06c84883097033
BLAKE2b-256 73c66008ba63c36f7aabccf84aa27efe4efdfda9712a1d9084d1a44c0b939992

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page