# Practical ways to use the Claude Agent SDK
๐ฌ Continue, resume, and fork agent conversations to tackle complex tasks across multiple turns.
Session Management uses `continue`, `resume`, and `fork` to maintain context across multi-turn conversations.
๐ Title: Working with Sessions
๐ URL:
๐งฉ Overview
Sessions preserve conversation context. Python uses `ClaudeSDKClient` (auto session ID management), TypeScript uses `continue: true`. `resume` restarts interrupted sessions, and `fork_session` branches history to explore alternatives.
๐ How to use it
```python
options = ClaudeAgentOptions(resume=session_id) # Resume
options = ClaudeAgentOptions(fork_session=True) # Fork
```
๐ Practical usage
- Build multi-turn conversations: "Analyze the auth module" โ "Refactor it to use JWT" with full context preserved.
- Resume sessions that ended with `error_max_turns` using `resume` with higher limits.
- Use `fork_session=True` to explore an OAuth2 approach without destroying the original JWT approach. Two independent histories are maintained.
- Build session picker UIs with `list_sessions` / `get_session_messages` / `rename_session`.
๐ก Use cases
๐ Resuming sessions after hitting limits
๐ฟ Parallel exploration of alternative approaches via fork
๐ Building session management UIs
โ ๏ธ Watch out
Sessions are saved at `~/.claude/projects/
/.jsonl`. Cross-host resume requires matching `cwd`. Sub-agent transcripts persist independently from the main conversation.
#ClaudeAgentSDK# #AI#