For Claude Code session names, let a hook name the session before a person types /rename. When a SessionStart hook puts sessionTitle in its output JSON, it has the same effect as /rename, so the terminal tab title does not wobble with the conversation topic and is fixed from the start in the [major][role]-minor format. If you put a role tag such as “analysis” or “development” in the middle of the name, other hooks can read that name and even stop the mistake of trying to edit code in an analysis session.
This post is the first in a series that covers, one per day, the devices I built while turning my solo development environment around AI agents (AX, AI transformation).
Why did the tab titles keep changing?
I keep several Claude Code sessions open in a terminal app called Orca. A tab for writing blog posts, a tab for fixing the site and a tab for tuning automation are open at the same time. But for a session with no name, Claude Code makes up a new terminal title from the conversation topic on every prompt. A tab where I asked for one simple calculation ended up titled 1+1 calculation. Once there were several tabs, I had to click each one to find out what it was for.
What did I try first?
The first thing I tried was to set the title when creating the tab. I opened it with a title using orca terminal create --title, but as soon as Claude Code started, it overwrote the title with Claude Code. The second thing was to turn off title changes altogether with the environment variable CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1. The wobbling stopped, but now the session name did not appear in the title either, so every tab looked the same. I tried both myself on 2026-10-07 and dropped them.
Where did I get stuck?
After trying, I learned the rule. If a session has a name, the title is fixed to that name, and it changes with the topic only when there is no name. The answer in the end was “always give it a name,” but the problem was that I often forget /rename. A rule that a person has to remember is the first to be dropped when I am busy. So I decided to hand the remembering over to a hook.
How did I change it with a hook?
A SessionStart hook runs when a session is opened new, resumed or forked. If you put sessionTitle in hookSpecificOutput of the output, that name is attached to the session. Here is the real hook, shortened.
APPLY_SOURCES = ("startup", "resume", "fork") # not applied to clear or compact
def auto_title(payload):
if payload.get("session_title") or payload.get("source") not in APPLY_SOURCES:
return None # leave it alone if it already has a name
return "[%s][analysis]-default" % major_of(payload["cwd"])
out = {"hookEventName": "SessionStart", "sessionTitle": auto_title(payload)}
print(json.dumps({"hookSpecificOutput": out}))
For the leading major category, it picks the most frequently used one among the recent session names in the same folder. At first I looked only at the single most recent one, but a typo made once carried straight over to the next session name, so I switched to “the most used.” The default role is “analysis.” If you try to edit a file or commit in an analysis session, another hook (PreToolUse) reads the name and stops it, so I chose the safest side as the default.
The last slot, the “minor” part, changes with the work. If the first input is a slash command, the hook changes the minor part to that command name right away; otherwise it leaves -default, and when the first task ends the agent looks at the content and makes up a name. The small script that renames writes the new name to a file, and on the next prompt the UserPromptSubmit hook reads that file and applies it as sessionTitle. At the same moment it also renames the Orca tab with orca terminal rename.
For unattended runs (claude -p), where no person can answer, I do not add the prompt that asks for a name. In an unattended-run test, that prompt once intercepted the final answer and ended with an irrelevant question.
How has my day changed?
When I scan the tabs, I can see at once what each session is doing. Major category, role and topic appear on one line, as in [blog][development]-robots and [site][analysis]-search-stats. As measured on 2026-10-19, 206 of the 211 session records written since 2026-10-12 had a name. There have been 10 commits so far that edited the two hook files that attach names. Naming is no longer something I have to remember; it is something the hook does.
Frequently asked questions
Can the name a hook attaches overwrite a name I chose?
It does not touch a session that already has a name. If the value passed to the hook includes a session name, the hook exits immediately, and it attaches the default name only when it opens a session without a name, either new or resumed.
Is a name attached after /clear or compact too?
A name returned by the SessionStart hook on clear or compact is not applied, so I excluded them from the start.
Do I need a terminal app like Orca?
No. The session name is a Claude Code feature, so the tab title is fixed in any terminal. Only the part that renames the Orca tab at the same time is specific to Orca.