Skip to content

Sessions, persistence, and remote

This chapter treats sessions as the durable spine of Claude Code. A session is not only a chat transcript: it is a local JSONL event stream, a resume/continue target, a fork/rewind boundary, a possible remote-control handoff point, and—when attached by its host—a view into durable claude.ai Project knowledge.

Read this chapter when the question is: where did the agent’s state come from, where was it saved, and how can it be resumed, forked, rewound, or controlled remotely?

Source-anchor policy

This page is a chapter guide. Linked implementation pages carry concrete cli.renamed.js anchors.

Semantic aliasMinified anchorScope
Sessions/persistence/remote chapterN/A — navigation pageGroups local JSONL transcripts, resume/continue/fork/rewind, hosted sessions, teleport, Remote Control, and remote-runner egress/file staging.
Session implementation pagesSee linked source-anchor tablesConcrete bundle anchors live in destination pages.

Session spine

flowchart TD
Startup[CLI mode selection] --> NewOrResume{new / continue / resume?}
NewOrResume --> New[Fresh session]
NewOrResume --> Continue[Continue latest]
NewOrResume --> Resume[Resume by id/search]
Continue --> Restore[Restore transcript]
Resume --> Restore
Restore --> Loop[Interactive or headless loop]
New --> Loop
Loop --> Jsonl[local-jsonl transcript]
Loop --> Remote[cloud / teleport / Remote Control]
Remote --> DataPlane[agent proxy / working sync / file staging]

Primary reading order

This chapter uses four documentation layers so one session fact does not acquire several competing owners:

LayerCanonical pagesReader contract
ArchitectureSession and remote-control architectureDefines identities, layers, collaborators, and invariants; it does not repeat queue/hydration algorithms.
LifecycleSession resume and transcripts, Remote control and teleport, Remote-environment egress and file stagingOwns setup, state transitions, retries, persistence ordering, remote-runner data planes, cleanup, and failures.
Inventory/referenceSession API, events, and storageLists endpoint, event, frame-family, and storage surfaces without becoming their implementation tutorial.
Shape/referenceData models and frame schemasDefines observable record/frame fields and ordering constraints without duplicating lifecycle algorithms.
OrderPageSession question answered
1Session resume and transcriptsHow do JSONL roots, --continue/--resume/fork/no-persistence/rewind and /clear//branch//rename//recap connect, and how do discovery/restore rehydrate live state?
2Hosted Projects and knowledgeHow does CLAUDE_PROJECT_UUID bind one session to one shared knowledge container, and how do project context, read/search/write/delete, OAuth scopes, and upload guards work?
3Team onboarding and share flowsHow does /team-onboarding scan local session usage, draft ONBOARDING.md, and optionally create/update an organization share link?
4Remote control and teleportHow do --cloud/deprecated --remote, --teleport, Remote Control, bridge tokens, /remote-env, /web-setup, and /session connect to sessions?
5Remote-environment egress and file stagingHow do hosted runners provide policy-enforced HTTPS egress, working-file synchronization, /uploads, and staged MCP file lanes?
6Session API, events, and storageWhich API endpoints, event families, bridge frames, and internal storage areas are visible around sessions and remote control?
7SDK query, session API, and subagent surfaceWhat programmatic SDK surface does Claude Code expose for query, session management, subagent inspection, in-process MCP, and direct-connect transport?
8Session recording (asciicast)How are session recordings represented, retained, and bounded when the source-visible asciicast path is active?
9Data models and frame schemasWhich observable transcript records, session layers, stream/control frames, and storage record families shape sessions?
10Session and remote-control architectureHow is a session decomposed into a durable JSONL layer + live envelope, and how do resume/fork/rewind/remote reuse the same address?

Handoffs

Created and maintained by Yingting Huang.