Approach B: SessionEnd hook (automatic, AI-generated)
A SessionEnd hook reads the session's JSONL file directly from ~/.claude/projects/, extracts the first few user messages as context, and calls claude -p --model claude-haiku-4-5-20251001 to generate a 4-6 word descriptive title. If Haiku is unavailable, it falls back to a sanitized version of the first message.
The hook updates both sessions-index.jsonl (for custom session browsers) and the slug field in the JSONL file (for native /resume compatibility).
json
// .claude/settings.json
{
"hooks": {
"SessionEnd": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/auto-rename-session.sh"
}
]
}
]
}
}Requirements: claude CLI on PATH, python3 for JSON parsing. Set SESSION_AUTORENAME=0 to disable for a specific session.
After the session ends, the /resume picker shows "fix auth middleware" instead of "2026-03-04T14:23...".