← Claude Docs

Manage sessions - Claude Code Docs

Claude Docs · June 11, 2026
Claude Code sessions are saved conversations tied to project directories, stored locally to enable resuming conversations, branching to explore different approaches, and switching between tasks. The CLI supports multiple commands for session management, including claude --continue to resume the most recent session, claude --resume for an interactive session picker, and /branch to create conversation copies. Session transcripts are stored as JSONL files at ~/.claude/projects/ and persist for 30 days by default before automatic cleanup.

Detailed Analysis

Claude Code's session management system represents a sophisticated approach to preserving and navigating conversational state within AI-assisted software development workflows. Sessions in Claude Code are saved conversations tied to specific project directories, stored continuously as local transcript files that persist across exits and context clears. The CLI offers multiple entry points for resuming work: `claude --continue` picks up the most recently active session in the current directory, `claude --resume` opens an interactive picker, and `claude --resume <name>` allows direct resumption of named sessions. A notable integration with version control workflows is `claude --from-pr <number>`, which links sessions to specific pull requests, allowing developers to return to the exact conversational context in which a given PR was created or worked on.

The session picker is a richly featured interface that reflects the complexity of real-world development environments. By default, it scopes to the current worktree but can be expanded to all worktrees of a repository with Ctrl+W or to every project on the machine with Ctrl+A. This scoping behavior is deliberate and consequential: session IDs are resolved against the current project directory and its git worktrees, meaning sessions created in one directory cannot be found from another. From version 2.1.169, using `/cd` within a session actively relocates that session's storage to the new directory, keeping the picker organized as development context shifts. The picker supports filtering by git branch, previewing session content, and even resolving sessions by pasting pull or merge request URLs from GitHub, GitHub Enterprise, GitLab, or Bitbucket — a direct acknowledgment that development work in these tools is deeply tied to hosted repository platforms.

Branching is one of the more architecturally interesting features described, enabling developers to fork a conversation at any point to explore an alternative approach while leaving the original intact. This mirrors familiar version control concepts — branching a codebase to test a different solution — but applied to the AI conversation itself. The `/branch` command or the `--fork-session` flag creates a copy of the full conversation history, and the two resulting sessions — the new branch and the original — are independent, with permissions granted during the original session not carrying over. This design prevents unintended capability transfer between conversation branches. The session picker groups forked sessions under their root, providing visual lineage of how exploratory conversations evolved from a common starting point.

Context management within a session adds another dimension to how Claude Code handles long-running work. The `/clear` command starts a fresh context without destroying the prior conversation, which remains resumable. The `/compact` command replaces history with a summary, optionally focused on specific aspects, which is a mechanism for managing the finite size of the model's context window while retaining the benefits of continuity. These tools reflect a broader design philosophy: rather than treating context loss as an inevitable failure mode, Claude Code treats it as a manageable state that the developer can navigate deliberately.

The session management architecture described here is indicative of a broader trend in AI development tooling toward treating AI assistants not as stateless query interfaces but as persistent collaborative agents embedded in long-horizon workflows. The tight integration with git worktrees, pull requests, and branch-level filtering signals that Anthropic is positioning Claude Code as a native participant in professional software development processes rather than an external utility. The emphasis on resumability, naming, branching, and transcript export reflects user research into how developers actually work — across interrupted sessions, parallel tasks, and exploratory dead ends — and the infrastructure described aims to make AI assistance as recoverable and navigable as the codebases it helps manage.

Read original article →