Feature Request: Include session_name in hook input JSON
Summary
When using hooks (e.g., Stop, PermissionRequest) to send desktop notifications, there is no way to identify which session triggered the notification. The hook input JSON currently includes session_id (a random identifier) but not the human-readable session name set via /rename or claude -n.
Use Case
When running multiple Claude Code sessions in parallel, I use macOS notifications (via osascript) to know when a task completes or needs approval. However, all notifications look the same — I can only distinguish them by project directory, not by session.
Adding session_name to the hook input JSON would allow users to include meaningful context in notifications, logs, or any other hook-based automation.
Current Hook Input (example)
{
"session_id": "abc123...",
"transcript_path": "/path/to/transcript.jsonl",
"cwd": "/current/working/directory",
...
}
Proposed Addition
{
"session_id": "abc123...",
"session_name": "auth-refactor",
"transcript_path": "/path/to/transcript.jsonl",
"cwd": "/current/working/directory",
...
}
session_name should be the name set by the user via /rename or --name flag. If no name is set, it could be null or omitted.
Example Notification Hook Using session_name
JSON=$(cat)
SESSION=$(echo "$JSON" | jq -r '.session_name // .session_id[:8]')
PROJECT=$(echo "$JSON" | jq -r '.cwd // empty' | xargs basename 2>/dev/null)
MSG="${PROJECT} [${SESSION}] でタスクを完了しました"
osascript -e "display notification \"${MSG}\" with title \"Claude Code\""This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗