Feature: Native auto-session-title generation on first user message

Resolved 💬 4 comments Opened Apr 13, 2026 by yupoet Closed May 24, 2026

Feature Request

Summary

Claude Code should natively generate a meaningful session title from the first user message, similar to how ChatGPT, Claude.ai, and other AI chat interfaces automatically name conversations.

Problem / Motivation

Currently, session titling in Claude Code relies entirely on:

  1. External MCP tools (e.g. mcp__happy__change_title from the Happy app) injecting a system-prompt instruction, OR
  2. Manual /rename by the user

The system-prompt approach has a fragility problem: mcp__happy__change_title is listed as a deferred tool in Claude Code (schema not pre-loaded). The model must first call ToolSearch to load the schema, then call the tool — a two-step process the LLM executes inconsistently. The result is sessions with untitled or stale titles, making /resume and session navigation difficult.

Proposed Solution

Add native session auto-titling built into Claude Code itself:

  1. Trigger: After the first user message in a new session (not --resume / --continue)
  2. Mechanism: Asynchronously (fire-and-forget, non-blocking) call an internal lightweight model to generate a ≤60-char title from the first user message
  3. Storage: Write the title to the session JSONL as a custom-title entry (the format already used by /rename)
  4. Settings opt-out: Respect a new autoTitle: false setting in settings.json for users who prefer manual control

Prior Art / Evidence

  • Happy app (largest Claude Code mobile client) already does this for Codex and Gemini by appending CHANGE_TITLE_INSTRUCTION to the first user message:

``js
// runCodex-CQJbJWfw.mjs:1964
const turnPrompt = first
? message.message + "\n\n" + CHANGE_TITLE_INSTRUCTION
: message.message;
``
For Claude Code it relies only on system-prompt injection, which is less reliable due to deferred tool loading.

  • The terminalTitleFromRename setting already exists in Claude Code's schema, showing the infrastructure for session titling is partially in place.
  • The custom-title JSONL entry format is already used and read by /resume, so no new storage schema is needed.

Workaround (for now)

A UserPromptSubmit hook injects the instruction on the first message of each session:

{
  "hooks": {
    "UserPromptSubmit": [{
      "hooks": [{
        "type": "command",
        "command": "node ~/.claude/scripts/hooks/user-prompt-auto-title.js",
        "timeout": 5
      }]
    }]
  }
}

The script outputs { "hookSpecificOutput": { "hookEventName": "UserPromptSubmit", "additionalContext": "..." } } only on the first message of each session (tracked via a CLAUDE_SESSION_ID-keyed flag file in /tmp).

This works but requires per-user setup and still relies on the model following instructions — a native solution would be deterministic.

Acceptance Criteria

  • [ ] New sessions (not resumed) automatically get a title generated from the first user message
  • [ ] Title generation is async and does not block the first response
  • [ ] Title appears in /resume list
  • [ ] autoTitle: false in settings.json disables the feature
  • [ ] Works without any external MCP server or plugin

Claude Code Version

2.1.104

Platform

Linux (Ubuntu 24.04)

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗