[BUG] SessionStart hook `sessionTitle` silently ignored for source `clear` (only applied for startup/resume)

Open 💬 1 comment Opened Jun 11, 2026 by syd3n

Environment

  • Claude Code: 2.1.173 (native binary install)
  • Platform: macOS (Darwin 25.5.0, arm64)

Summary

A SessionStart hook returning hookSpecificOutput.sessionTitle works for sources startup and resume, but the title is silently discarded when the source is clear — even though the hook executes successfully and its output is recorded in the transcript.

This makes it impossible to use the documented hook mechanism to fix the long-standing "/clear loses the session name" problem (#36113, #35937), which is exactly the use case where re-applying a title matters most: /clear creates a new session ID, so the previous name is orphaned.

Repro

  1. ~/.claude/settings.json:
{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup|clear",
        "hooks": [
          { "type": "command", "command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"SessionStart\",\"sessionTitle\":\"my-title\"}}'" }
        ]
      }
    ]
  }
}
  1. Start claude → title "my-title" is applied. ✅ (startup works)
  2. /clear → new session is untitled. ❌

The hook did run on /clear — the new session's transcript contains a hook_success attachment for SessionStart:clear with the correct stdout — but the title is never applied to the UI, terminal title, or session metadata.

Root cause (from the 2.1.173 bundle)

In the SessionStart hook runner, the collected sessionTitle is stashed for application only for two of the four sources:

qx8 = H === "startup" || H === "resume" ? Y : void 0

(where H is the source and Y the hook-provided sessionTitle; the caller later pops the stash and applies it). For clear (and compact) the value is dropped on the floor with no warning or log.

Expected

Either:

  • apply sessionTitle for source clear the same way as startup/resume (preferred — it gives users a supported self-serve fix for #36113/#35937), or
  • document the limitation in the hooks reference (related docs gap: #62665) and emit a debug-level warning when a sessionTitle is discarded.

Workaround

A UserPromptSubmit hook returning sessionTitle (only when the input's session_title is empty, to avoid clobbering manual /rename) re-titles the post-/clear session on the first prompt. Works, but the session sits unnamed until the user types something.

Related

  • #36113, #35937, #61172 — /clear vs session-name persistence family
  • #59267 — added SessionStart sessionTitle support (startup/resume only, apparently)
  • #62665 — docs gap for SessionStart sessionTitle

View original on GitHub ↗

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