Sessions, Resume, and Compaction
How Claude Code persists work across long conversations
A guide to transcript storage, session resume behavior, cross-project boundaries, and why long-lived conversations need compaction.
Sessions are file-backed, not just in-memory chat threads
Claude Code persists transcript data to project-scoped files and uses explicit path logic for transcripts, session directories, and sub-agent logs.
This lets long-running work survive beyond a single terminal view.
- Transcript paths are derived from the project/session context.
- Sub-agents can write their own transcript files beneath the session.
- The storage layer is careful about message chain integrity.
Resume is selective and project-aware
The resume flow is not a naive list of every conversation. It filters resumable sessions, supports worktree-aware lookup, and warns when a conversation belongs to a different directory.
That protects users from resuming context in the wrong project and making confusing edits.
- Same-repo worktrees are treated differently from unrelated projects.
- Cross-project resumes can produce a command instead of directly reopening the conversation.
- Lite logs can be expanded into full logs when needed.
Compaction is the price of long-lived agentic work
Transcript persistence alone is not enough. The active prompt still needs to fit within model limits, which is why compaction and budget handling sit next to session logic in the broader system.
In practice, sessions and compaction are two halves of the same durability story.
Learn next
These guides are adjacent to the current topic and make the learning path easier to follow.
How Claude Code Works
The high-level architecture behind a Claude Code turn
A code-backed explanation of how Claude Code assembles context, runs the agent loop, invokes tools, and keeps long sessions moving.
Agents and Plan Mode
How Claude Code separates planning, coordination, and delegated execution
Understand the difference between the main thread, plan mode, coordinator behavior, and constrained sub-agents.
Context and Memory
How Claude Code builds working context and persistent memory
Understand the difference between session context, CLAUDE.md instructions, MEMORY.md indexing, and relevance-based memory recall.
Related resources
These directory entries connect the concept guide to concrete tools, docs, and integrations.
Claude Code Getting Started Guide
Official getting started documentation for Claude Code
Comprehensive getting started guide for Claude Code. Covers installation, configuration, basic commands, MCP setup, and best practices for new users. The essential first read for anyone starting with Claude Code.
Claude Code Best Practices
Community-driven best practices for Claude Code
Collection of best practices learned from real-world Claude Code usage. Covers CLAUDE.md optimization, effective prompting, workflow organization, and common pitfalls to avoid. Continuously updated by the community.
TypeScript Monorepo CLAUDE.md Template
CLAUDE.md for Turborepo/Nx monorepo projects
CLAUDE.md template designed for TypeScript monorepo projects using Turborepo or Nx. Covers workspace structure, shared packages, build pipelines, dependency management, and cross-package development patterns.
VS Code Claude Extension
Integrate Claude Code directly into VS Code
Official VS Code extension bringing Claude Code capabilities into your editor. Features include inline assistance, file context awareness, and seamless integration with VS Code's interface. Perfect for developers who prefer IDE workflows.