Feature Request: Expose session_name in hook payloads and add Command hook event
Summary
Hook payloads currently include session_id but not the human-readable session_name that can be set via /rename. For registry/monitoring use cases, having the session name would be valuable.
Additionally, there's no hook event for slash commands (like /rename), which would enable workflows that need to intercept or respond to user commands.
Use Case
I'm building a session registry that tracks active Claude Code instances. Currently it can only display the cwd path, which isn't very descriptive. If session_name were available in hook payloads (particularly SessionStart), the registry could display meaningful names.
Even better, if there were a Command hook event (or PreCommand/PostCommand), I could:
- Intercept
/rename <name>commands - Sync the name to my external registry
- Keep both systems in sync without manual duplication
Requested Changes
1. Add session_name to hook payloads
Include the session name (if set) in relevant hook payloads:
{
"session_id": "abc123",
"session_name": "auth-refactor", // NEW - null if not set
"transcript_path": "...",
...
}
At minimum in SessionStart, but ideally in all hooks.
2. (Optional) Add Command hook event
A hook that fires when slash commands are executed:
{
"hooks": {
"Command": [
{
"matcher": "rename",
"hooks": [{ "type": "command", "command": "./on-rename.sh" }]
}
]
}
}
Input:
{
"session_id": "abc123",
"hook_event_name": "Command",
"command_name": "rename",
"command_args": "auth-refactor"
}
This would enable intercepting/extending built-in commands for custom workflows.
Current Workaround
Without these features, session registries must either:
- Display only paths (less descriptive)
- Maintain a separate naming system (risk of desync)
- Parse transcript files directly (fragile, not a stable API)
---
Thank you for considering this feature request!
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗