Expose session name to hooks and/or environment variable

Resolved 💬 2 comments Opened Mar 27, 2026 by tomoliveri Closed Mar 27, 2026

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:

  1. SessionStart hook payload — add a session_name field alongside the existing session_id, cwd, model, and source
  2. 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

  • SessionStart hook receives session_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.

View original on GitHub ↗

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