[FEATURE] Expose the auto-generated session title to hooks/templates so it can be wrapped with a prefix and suffix

Open 💬 1 comment Opened Jun 18, 2026 by amin-lakhani

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

I work across several machines — a WSL box, a remote VPS, and Claude Code on
the web — often with sessions open on more than one at the same time. When I
glance at the /resume picker or the terminal title, I can't tell which
machine a session belongs to, and I frequently resume the wrong one.

The natural fix is to put a short machine tag (e.g. WSL / VPS / RCC) at
the front of every session title. But the moment I set a title myself, I lose
the thing that actually makes sessions distinguishable: Claude's auto-generated
descriptive title. Today it's all-or-nothing — I can have either my own
machine/folder/branch tag or Claude's auto-title, never both.

The reason is timing: the only place a title can be set programmatically is the
SessionStart hook (hookSpecificOutput.sessionTitle), and that runs before
my first message — before the auto-title exists. Setting a title there is
treated like /rename, which turns auto-generation off. The auto-generated
title is never exposed to any hook, and there's no CLI to rename a live
session, so there is no point at which I can read the generated title and wrap
it with my own prefix/suffix. The result is that the single most useful piece
of context (which machine am I on?) can't coexist with the auto-title I rely
on.

Proposed Solution

Let the final session title be composed around Claude's auto-generated title,
rather than replacing it. Any one of these would solve my problem:

  1. A title-format setting with a variable for the generated title, e.g.:

"sessionTitleFormat": "{machine} {ai_title} | {folder} {branch}"

where {ai_title} is the model-generated title, {folder}/{branch} are
existing startup-known values, and a custom var like {machine} resolves
from an env var or a small command.

  1. Prefix/suffix wrappers — "sessionTitlePrefix" / "sessionTitleSuffix"

(literal string or a command whose stdout is used) that Claude concatenates
around the auto-title instead of overwriting it.

  1. Hook access plus a post-generation rename point: include the generated

title in hook input (a new SessionTitleGenerated event, or a title field
on the existing Stop input) and allow that hook to emit sessionTitle.
This is the most general — the prefix/suffix can then be arbitrary logic.

Importantly, this needs to work for Claude Code on the web too, where titles
are stored server-side and a local hook can't reach them — so options (1) and
(2), handled inside Claude Code itself, are what cover the web case. Please
don't make it hook-only.

Alternative Solutions

  • A SessionStart hook that sets sessionTitle to a deterministic

WSL <folder> | <branch>. Works, but throws away the auto-generated title
entirely, so sessions on the same machine/folder are hard to tell apart.

  • Putting the machine tag in the statusline instead. The tag is then visible

inside a session but not in the /resume picker or terminal title, which
is exactly where I need it for picking the right session.

  • The -n/--name flag — only sets a name at launch (again, no auto-title) and

can't be updated once the session is running.

None of these let the machine tag and Claude's auto-title appear together.

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

  1. I have three sessions open: one on my WSL machine, one SSH'd into my VPS,

and one in Claude Code on the web.

  1. Each is in a different repo on a different branch, doing different work.
  2. I switch context and open the /resume picker. Today every entry is just

Claude's auto-title with no machine info, so I can't tell the WSL "fix auth"
session from the VPS one without opening them.

  1. With this feature, the titles read:

WSL Fix auth refresh bug | myproject main
VPS Refactor deploy pipeline | api-server deploy
RCC Update session naming | dotfiles claude/session-naming
I pick the right one instantly.

  1. This saves me from repeatedly resuming the wrong session and losing my place.

Additional Context

Technical constraints I ran into while trying to build this myself:

  • hookSpecificOutput.sessionTitle is only honored by SessionStart, and only

for source startup/resume.

  • SessionStart fires before the first user message, so the auto-title isn't

generated yet; setting any title there suppresses auto-generation.

  • The auto-generated title isn't present in SessionStart, UserPromptSubmit,

or Stop hook input, nor in the on-disk transcript/session metadata in a
documented, writable form.

  • There's no claude subcommand to rename an existing session.

Related issues (similar area, but none expose the generated title for
composition):

  • #45522 — customize session title format / project-name prefix
  • #32548 — session title template via settings/CLAUDE.md
  • #24119 — auto-title from CWD / project metadata

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗