How do I find my Claude Code session ID?
By Jake Marsh, who builds Taskhold. Updated 2026-11-19. Facts about other tools checked 2026-11-19. 5 min read.
Short answer: Ask Claude to run echo $CLAUDE_CODE_SESSION_ID: Claude Code sets that variable in every Bash command it runs. Status line scripts and hooks also get it as session_id, and each session's transcript is ~/.claude/projects/<project>/<session-id>.jsonl. Resume one from any directory with claude --resume <session-id>.
You want the ID of the Claude Code session you're in, to resume it later, log it next to a script's output, or hand it to someone. Claude Code doesn't print it in the conversation, but it puts it in several places you can read.
This guide lists them, shows how to get the ID from a script, how resuming by ID works, and what happens when you share an ID with someone else. The last section covers picking work up by task instead, with each step on a live board.
The ID of the session you're in
- Ask Claude to run echo $CLAUDE_CODE_SESSION_ID. Claude Code sets CLAUDE_CODE_SESSION_ID in its Bash and PowerShell tool commands, in hook commands and in stdio MCP servers it starts. In Bash and hooks the value changes when you run /clear.
- A status line script gets the session as session_id in the JSON on stdin, so you can keep it on screen. The status line generator builds one.
- Hook commands get session_id and transcript_path in their JSON input.
- In a skill, ${CLAUDE_SESSION_ID} is replaced with the current session ID, for example to name a log file.
# status line script: print the first 8 characters of the session ID
input=$(cat)
echo "session $(echo "$input" | jq -r '.session_id' | cut -c1-8)"IDs of earlier sessions
Claude Code saves each session as a JSONL file named after its ID in ~/.claude/projects/<project>/, where <project> is the working directory path with every character that isn't a letter or digit replaced by -. The newest file in that folder is usually the session you just used.
ls -t ~/.claude/projects/-Users-me-code-my-app/*.jsonl | head -3- Transcripts are deleted after 30 days by default. cleanupPeriodDays in settings.json changes that.
- You often don't need the ID at all. /rename auth-refactor names the session, and claude --resume auth-refactor opens it again. claude --resume with no argument opens a picker, and claude --continue reopens the newest session in the folder.
- Sessions started with claude -p or the Agent SDK aren't in the picker or claude --continue. Resume those by ID.
Get or set the ID from a script
session_id=$(claude -p "Start a review" --output-format json | jq -r '.session_id')
claude -p "Continue that review" --resume "$session_id"
# or pick the ID yourself (it must be a valid UUID)
claude --session-id "550e8400-e29b-41d4-a716-446655440000"claude --bg starts a background session and prints its session ID along with the commands to manage it.
Resume a session by ID
claude --resume <session-id> works from any directory. Claude Code looks in the current project and its git worktrees first, then in every other project on the machine. If nothing matches it says No conversation found with session ID: <session-id>. You can also pass the absolute path to a transcript's .jsonl file instead of the ID.
Add --fork-session to continue in a copy with a new ID and leave the original as it was. /branch does the same from inside a session and prints both IDs.
Can you share a Claude Code session ID?
An ID only points to a transcript file on your own machine. Sent to a teammate, it finds nothing on theirs. To share the conversation itself:
- /export copies the conversation to the clipboard or saves it as a plain-text file, with tool output rendered as readable text.
- To let someone continue it, send the .jsonl transcript; claude --resume accepts the absolute path to the file. Read it first: it holds every tool call and its output, including any secrets a command printed.
To send one question to a session from a script, claude -p --resume <session-id> "summarize what we changed" --output-format json returns the answer as JSON.
Pick work up by task instead of by session
Session IDs work for resuming a conversation on the same machine. They don't help when the next session is on a laptop, in Codex, or after the transcript has been cleaned up.
With Taskhold, a new session starts by calling taskhold_get_current, which returns the task in progress, its steps, the next step and the latest notes. Continue in another agent on a task copies a prompt with the task ID for any client that has Taskhold connected, so Codex or a second Claude Code session carries on from the open step. The live board shows which agent has which task.
Related: resuming after compaction or /clear, continuing after a usage limit, and sharing Claude Code's task list across sessions.
Answer your coding agents from anywhere.
$12/month or $120/year after the trial. Card up front. Cancel before day 7 and you pay nothing. Every agent you run is included.
Or connect your agent first, no sign-up: add https://taskhold.com/api/mcp as an MCP server. The first time it uses Taskhold, it gives you the trial link.
Questions
- How do I see the current session ID in Claude Code?
- Ask Claude to run echo $CLAUDE_CODE_SESSION_ID, or show session_id in your status line. The ID is also the name of the newest .jsonl file in ~/.claude/projects/<project>/.
- Why did my session ID change?
- /clear starts a new conversation, and CLAUDE_CODE_SESSION_ID in Bash and hooks changes with it. /branch and --fork-session also create a new ID; the original session keeps its own.
- Can I choose the session ID myself?
- Yes. claude --session-id <uuid> starts the conversation with that ID. It must be a valid UUID.
- Can someone else open my session ID?
- No. The ID points to a transcript on your machine. Share the conversation with /export, or send the .jsonl file, which claude --resume accepts as an absolute path.
- How long does Claude Code keep sessions?
- 30 days by default. Set cleanupPeriodDays in settings.json to keep transcripts longer or shorter.
Sources
- Claude Code docs: manage sessions (resume by ID, transcripts, /export), checked 2026-11-19
- Claude Code docs: environment variables (CLAUDE_CODE_SESSION_ID), checked 2026-11-19
- Claude Code docs: CLI reference (--resume, --session-id, --fork-session, --bg), checked 2026-11-19
- Claude Code docs: status line (session_id), checked 2026-11-19
- Claude Code docs: headless mode (session ID in JSON output), checked 2026-11-19
- Claude Code docs: skills (${CLAUDE_SESSION_ID}), checked 2026-11-19
Related
Updated 2026-11-19. Something wrong or out of date? Email hello@greatwork.company.