Feature Request: Include sse_port in SessionStart hook input
Summary
The SessionStart hook currently does not include the CLAUDE_CODE_SSE_PORT in its JSON input. This makes it impossible to reliably register sessions with external integrations at session start.
Problem
At SessionStart, the CLAUDE_CODE_SSE_PORT environment variable may contain a stale value inherited from the parent shell (e.g., from a previous Claude Code session in another terminal). The fresh SSE port is only reliably available after Claude Code starts, but before hooks can access it.
Current SessionStart input:
{
"session_id": "abc123-...",
"cwd": "/path/to/project"
}
Desired SessionStart input:
{
"session_id": "abc123-...",
"cwd": "/path/to/project",
"sse_port": "54321"
}
Use Case
I'm building Colin Whisper, a voice-first terminal automation overlay that integrates with Claude Code. The overlay maintains a SessionStore that maps SSE ports to terminals for:
- Real-time session tracking across multiple terminals
- Per-terminal task visualization
- Timer management
- Voice routing to specific Claude Code sessions
Currently, session registration only happens on UserPromptSubmit (first prompt) because that's when CLAUDE_CODE_SSE_PORT becomes reliable. This means:
- User launches
claudein a terminal - Gap: Session exists but overlay doesn't know about it
- User sends first prompt → session finally registers
Including sse_port in SessionStart would allow immediate registration.
Proposed Solution
Include the SSE port in the SessionStart hook's JSON input, similar to how session_id is already included. This would be the freshly-assigned port for the current Claude Code instance, not the inherited environment variable.
Workaround Attempted
I tried reading CLAUDE_CODE_SSE_PORT from the environment in SessionStart hook, but it contains the stale port from a previous session (inherited from parent shell), not the current session's port.
Environment
- Claude Code version: latest
- OS: macOS
- Shell: zsh/bash
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗