Feature Request: Allow hooks to control terminal/tab title

Resolved 💬 3 comments Opened Mar 16, 2026 by derekrprice Closed Mar 20, 2026

Problem

Claude Code sets the terminal title to a static label with an activity spinner, but there's no way for hooks to influence this. Users with custom hook systems (like PAI) want dynamic titles that reflect the current task context (e.g., "Fixing auth bug" instead of "Claude Code").

Current Limitations

  • Hooks run as external subprocesses with no API back into Claude Code
  • Writing OSC escape sequences from hooks conflicts with Claude Code's own title management
  • /rename works manually but cannot be invoked programmatically from hooks
  • The sessions-index.json summary field is not watched by the running process

Proposed Solution (any of these would work)

  1. Hook output field — Allow hooks (especially UserPromptSubmit and Stop) to return a terminalTitle or sessionName field in their JSON output that Claude Code picks up and uses for the terminal title, prepended to or replacing "Claude Code" — while preserving the activity status indicator (the animated asterisk/dot spinner is valuable feedback).
  1. Programmatic /rename API — Expose a way for hooks to trigger a rename, e.g. writing to a watched file like ~/.claude/session-title or a local socket.
  1. Title template in settings — A terminalTitle setting in settings.json that supports a shell command (like statusline-command), whose output is used as the terminal title alongside the existing activity indicator.

Use Case

PAI (Personal AI Infrastructure) already generates 3-4 word task summaries via Haiku inference on every UserPromptSubmit. It just has no way to deliver them to the terminal title without conflicting with Claude Code's built-in title management.

Ideal result: ✳ Fixing auth bug instead of ✳ Claude Code

Environment

  • WSL2 (Windows Terminal)
  • Claude Code latest

View original on GitHub ↗

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