Preserve --name session name across /clear
Problem
When launching Claude Code with --name, the terminal tab title is set correctly to the provided name. However, running /clear resets the session name to the default "Claude Code", which overwrites the terminal tab title.
Current behavior
- Launch with
claude --name "my-branch"→ tab title shows "my-branch" ✓ - Chat normally → tab title persists ✓
- Run
/clear→ tab title resets to "Claude Code" ✗ - Subsequent prompts → title stays "Claude Code" ✗
Expected behavior
/clear should preserve the --name value from the CLI invocation and continue using it as the session name (and terminal title).
Why it matters
For workflows where the terminal tab title is set to the git branch name (via a shell wrapper around claude), /clear breaks the tab identification. Since Claude Code's TUI actively manages the terminal title on render cycles, external hooks cannot override it — only the internal session name controls the title.
Workaround
Manually running /rename branchname after every /clear, which is tedious.
Environment
- Claude Code v2.1.76
- macOS (Ghostty terminal)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗