Skip to content

[BUG] CLAUDE_SESSION_ID not found in env #24371

Description

@BowTiedRadone

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

CLAUDE_SESSION_ID seems to be no longer available in the main agent context.

❯ What is CLAUDE_SESSION_ID?                                                                                                                                                        
                                               
⏺ CLAUDE_SESSION_ID is a built-in environment variable provided by Claude Code that contains a unique identifier for the current conversation/session. It's a UUID that stays       
  constant throughout a single conversation but changes when a new conversation starts.                                                                                                                                                                                
                                                                                                                                                                                  
  You can see its current value:                                                                                                                                                    

⏺ Bash(echo $CLAUDE_SESSION_ID)
  ⎿  (No content)
                                                                                                                                                                                    
⏺ Interesting — it's empty in this shell context. Let me check how it's typically available:                                                                                        
                                                                                                                                                                                    
⏺ Bash(env | grep -i claude)                                                                                                                                                        
  ⎿  CLAUDE_CODE_SSE_PORT=32421
     CLAUDE_CODE_ENTRYPOINT=cli                                                                                                                                                     
     CLAUDECODE=1 

What Should Happen?

CLAUDE_SESSION_ID should be exported and available.

Error Messages/Logs

Steps to Reproduce

  1. start claude: claude
  2. ask for CLAUDE_SESSION_ID

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.37

Platform

Other

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corearea:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions