Feature Request: Expose session ID programmatically

Resolved 💬 3 comments Opened Jan 22, 2026 by jedarden-rho Closed May 5, 2026

Summary

When running multiple concurrent Claude Code sessions, there's no programmatic way to access the current session ID. This makes it difficult to reliably resume specific sessions in multi-instance environments.

Use Case

In environments where multiple Claude Code instances run concurrently (e.g., tmux sessions for parallel work), --continue is unreliable because it picks the most recent conversation across all sessions, not the one in the current terminal.

The /status command displays the session ID, but it's not exportable or accessible programmatically.

Proposed Solutions

Any of these would solve the problem:

  1. Environment variable: Expose $CLAUDE_SESSION_ID in the shell environment during a session
  2. CLI command: Add claude --print-session-id or claude session-id to output the current session ID
  3. File-based: Write session ID to a predictable location (e.g., /tmp/claude-session-$$.id)

Current Workaround

Pre-generate session IDs before starting:

SESSION_ID=$(uuidgen)
echo "$SESSION_ID" > /tmp/claude-session-alpha.id
claude --session-id "$SESSION_ID"

This works but requires external tracking and doesn't help with sessions already running.

Environment

  • Claude Code version: 2.1.15
  • Platform: Linux (GKE devpod)
  • Use case: Multiple concurrent Claude sessions in tmux

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗