Understanding Sessions
Each interaction with Claude creates a session. Sessions store:- Conversation history (user and assistant messages)
- Tool usage and results
- File changes and checkpoints (when enabled)
- Cost and usage information
- Session metadata (title, branch, working directory)
~/.claude/projects/<project-dir>/ as JSONL files.
Continuing Conversations
You can continue previous conversations using thecontinue_conversation option or by resuming a specific session.
Continue Last Conversation
Resume a Specific Session
Session Forking
Create a new session starting from a previous session’s state:Session forking creates a new session with a new ID while preserving the conversation history from the resumed session. This is useful for exploring different approaches without modifying the original session.
Listing Sessions
List sessions for a project or across all projects:List All Sessions
Limit and Filter Sessions
Session Metadata
SDKSessionInfo provides:
Reading Session Messages
Retrieve conversation history from a session:Pagination
Search All Projects
File Checkpointing
File checkpointing tracks changes to files during a session, allowing you to rewind files to their state at any point in the conversation.Enable File Checkpointing
Rewind Files
Restore files to their state at a specific user message:Use Case: Exploring Alternatives
Session Isolation
Control which settings sources are loaded:user- User-level settings (~/.claude/)project- Project-level settings (.claude/)local- Local settings (Git-ignored configurations)
Working Directory Management
Sessions are organized by working directory:Sessions are stored in
~/.claude/projects/<sanitized-cwd>/. The working directory path is sanitized to create a valid directory name.Complete Session Management Example
Best Practices
Use descriptive first prompts
Use descriptive first prompts
The first prompt becomes the session summary. Make it clear and descriptive for easier session identification.
Enable checkpointing for exploratory work
Enable checkpointing for exploratory work
When experimenting with different approaches, enable file checkpointing to easily rewind changes.
Fork sessions for what-if scenarios
Fork sessions for what-if scenarios
Use session forking to explore alternatives without modifying the original conversation.
Clean up old sessions periodically
Clean up old sessions periodically
Sessions accumulate in ~/.claude/projects/. Periodically remove old sessions to save disk space.
Use consistent working directories
Use consistent working directories
Keep working directories organized by project for easier session management and discovery.