Expose session name to hooks and/or environment variable
Summary
Claude Code now generates human-readable session titles (e.g., "project-in-progress") and supports naming sessions via claude -n or /rename. However, this session name is not accessible to hooks or the shell environment, which prevents useful integrations like setting terminal tab titles.
Request
Expose the session name in one or both of:
SessionStarthook payload — add asession_namefield alongside the existingsession_id,cwd,model, andsource- Environment variable — e.g.,
CLAUDE_SESSION_NAME, set in the shell environment so hooks and child processes can read it
Use case
Terminal emulators like iTerm2 support setting tab titles via escape sequences. With the session name available, a simple SessionStart hook could sync the Claude Code session title to the terminal tab:
#!/bin/bash
echo -ne "\033]1;${CLAUDE_SESSION_NAME}\007"
This would make it easy to identify which Claude session is running in which tab, especially when working across multiple sessions.
Current behavior
SessionStarthook receivessession_id(UUID),cwd,model,source— no session name- No environment variable is set with the session name
- The session name is only visible inside the Claude Code UI
Expected behavior
The session name (whether AI-generated, set via -n, or via /rename) is accessible to hooks and/or the environment so it can be used for terminal integrations.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗