Skip to main content

Claude Session Manager

Python Version License: MIT

Advanced session management system for Claude CLI that preserves conversation context across sessions.

Features

  • Automatic Context Preservation: Conversations are automatically captured and saved every 2 seconds
  • Session Management: Create, resume, and delete sessions for different projects
  • Auto-start Sessions: New sessions start automatically after creation
  • CLAUDE.md Integration: Context is loaded via CLAUDE.md without disrupting existing content
  • Working Directory Memory: Each session remembers and returns to its working directory
  • Export Functionality: Export conversations to Markdown or JSON format
  • Real-time Capture: Conversations are saved even if terminal is forcefully closed

Installation

From PyPI

pip install claude-session-manager

From source

git clone https://github.com/ahmetkumass/claude-session-manager
cd claude-session-manager
pip install -e .

Quick Start

Basic Commands

# Quick start - creates and starts a session immediately
cs quick

# Create named session - automatically starts
cs create --name "api_project"

# Create without starting
cs create --name "api_project" --no-start

# List all sessions
cs list

# Resume existing session
cs resume <session_id>

# Delete session
cs delete <session_id>

# Delete all sessions
cs delete --all

# Export session
cs export <session_id>

Usage Guide

Starting a New Project

# Navigate to project directory
cd ~/projects/my-api

# Create and start session
cs create --name "my_api"

# Work with Claude - context is automatically saved
> Create a FastAPI application structure
> Add user authentication endpoints

# Exit anytime - context is preserved
# Use Ctrl+C, /exit, or close terminal

Resuming Work

# List available sessions
cs list

# Output:
# ID         Name           Created              Context    Description
# --------------------------------------------------------------------------------
# abc123     my_api         2024-01-15 10:30     25         
# def456     frontend       2024-01-14 15:45     42         React dashboard

# Resume session - previous context is automatically loaded
cs resume abc123

# Claude remembers your previous conversation
> Continue with the authentication endpoints we discussed

Project Switching

# Working on API
cs resume api_session_id
> Implement rate limiting

# Switch to frontend project
cs resume frontend_session_id
> Debug the login component

# Each session maintains its own context

Command Reference

Command Description Alias
create --name <name> Create and start new session new
create --name <name> --no-start Create without starting
quick Create quick session with timestamp name q
list List all sessions ls
resume <id> Resume session with context
resume <id> --full Resume with full history
delete <id> Delete specific session rm
delete --all Delete all sessions
export <id> Export to Markdown
export <id> --format json Export to JSON
save <id> <message> Manually save message
current Show current session

Short Aliases

The cs command is the primary alias. Additional shortcuts:

cs q              # Quick start
cs ls             # List sessions
cs rm <id>        # Delete session

How It Works

Context Loading

When resuming a session, the system:

  1. Reads existing CLAUDE.md if present
  2. Appends session context to CLAUDE.md
  3. Claude automatically reads the context
  4. On exit, restores original CLAUDE.md content

Automatic Capture

Conversations are captured through:

  1. Background monitoring every 2 seconds
  2. Signal handlers for clean exits
  3. Parsing Claude's JSONL log files
  4. Automatic save even on terminal force-close

File Structure

~/.claude-sessions/
├── current_session.json       # Active session tracker
├── <session_id>.json          # Session data and context
└── context_<session_id>.md    # Formatted context file

Advanced Usage

Full History Loading

# Load complete conversation history
cs resume <session_id> --full

Manual Context Addition

# Add custom context to session
cs save <session_id> "Important: API key is in .env file" --role user
cs save <session_id> "Understood, I'll read from .env" --role assistant

Session Information

# View current active session
cs current

# List sessions with context count
cs list

Best Practices

  1. One session per project - Keep contexts separate and organized
  2. Descriptive names - Use meaningful session names for easy identification
  3. Regular exports - Export important sessions for backup
  4. Clean up regularly - Delete old sessions with cs delete --all

Technical Details

Context Preservation

  • Monitors ~/.claude/projects/ for JSONL changes
  • Parses conversation data from Claude's native format
  • Updates session context in real-time
  • Preserves working directory per session

CLAUDE.md Integration

  • Preserves existing CLAUDE.md content
  • Adds session context under ## Session Context section
  • Restores original content on exit
  • No permanent modifications to project files

Contributing

Contributions are welcome. Please submit pull requests with:

  • Clear commit messages
  • Updated documentation
  • Test coverage for new features

License

MIT License - see LICENSE file for details.

Support

For issues and feature requests, please use the GitHub issue tracker.


This is an independent project and is not affiliated with Anthropic or Claude.

Metadata

Release files for claude-session-manager 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-session-manager 1.0.0
File Size Uploaded
claude_session_manager-1.0.0.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-session-manager 1.0.0
File Interpreter ABI Platform
claude_session_manager-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / claude_session_manager-1.0.0.tar.gz

Download URL claude_session_manager-1.0.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d88c607c45f665c8d3d14d3475eccd555b72639e7bd91deb2589a0615bea0c22
BLAKE2b-256 checksum
How to use checksums
7378f9d74e1d17c7acf05f9249bd2bd08790c2217758d00244eaefc57993a6a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / claude_session_manager-1.0.0-py3-none-any.whl

Download URL claude_session_manager-1.0.0-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77ec83f550e6a7e79cba1f674844cd66dda4b6044528dc6e341515a5c3e6fd55
BLAKE2b-256 checksum
How to use checksums
dfff091849dd8b962a7e9ca7b29ae18c3056475208714103c7d2d5a65d4c866d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page