I run a lot of Claude Code and GitHub Copilot CLI sessions in parallel, and both tools title a session with a summary of its first prompt. That’s fine until you have three sessions called something like “improve test sharding performance” and can’t tell which project any of them is about.
So I made sessions name themselves after their project, with an emoji. I type “let’s add some emojis to our dotfiles” and get 🏠 dotfiles in either tool.
Claude Code
Claude Code hooks support this out of the box. A UserPromptSubmit hook receives the prompt, and if it prints hookSpecificOutput.sessionTitle, that becomes the session title, same as /rename. The hook also gets session_title when the session already has one, so it only renames on the first prompt and never overrides a manual /rename.
{
"hookSpecificOutput": {
"hookEventName": "UserPromptSubmit",
"sessionTitle": "🧪 testlanes"
}
}
GitHub Copilot CLI
Copilot CLI hooks can’t set a title; a userPromptSubmitted hook can only add context for the model. The agent, however, can rename its own session with rename_session once you enable the session management tools. The tool leaves user-chosen names alone.
copilot config sessionManagementTools.scope in-process
copilot config sessionManagementTools.enabled on
So the two meet halfway. On the first prompt of a session, a hook runs the same title script as Claude Code and hands the agent the exact name.
{"additionalContext": "Before anything else, call rename_session with name \"🧪 testlanes\". Do not mention the rename. If rename_session is unavailable or leaves the name unchanged, continue without it."}
The name is computed outside the model, and the model’s only job is one tool call. The hook remembers which sessions it has seen, so later prompts and resumed sessions are left alone. Starting a session with /new speed up the testlanes CI works too, which is how the third session in the video begins. It’s still best effort until Copilot lets hooks set the title directly, and non-interactive -p runs, which don’t have the tool, skip it.
Picking the Name
Both hooks call one shared bash script that prints a name, picked in this order.
- A project under
~/sourcementioned in the prompt, longest match first, so “excalc-rs” beats “excalc”. Repos inside organization folders count, whilemaster,upstream-*, anddblock-*checkouts don’t. - The project of the working directory.
- Otherwise, Haiku writes a short topic, such as
🔊 loud-laptop-fan.
Names are lowercase and hyphenated, because that’s how I name things. Haiku picks an emoji the first time a project shows up, and it’s cached, so testlanes is always 🧪. I pin the ones I care about in session-emojis.txt. The list of ~380 projects is cached too, so a cached run takes 40ms.
Asking Haiku From a Hook
The shared script doesn’t know about either tool; each hook hands it a command that asks Haiku. In Claude Code, that’s claude -p --model haiku, which starts a new Claude Code session, which runs the same hook, which calls claude -p, and so on. The --bare flag skips hooks, but it only accepts an API key and I sign in with OAuth. The fix is to disable hooks for the nested call and not save it as a session.
claude -p --model haiku --no-session-persistence --settings '{"disableAllHooks":true}' --tools ""
Copilot CLI can ask Haiku too, but it has no flag to skip hooks or saving the session, so its helper runs it in a throwaway COPILOT_HOME with no tools. The sign-in lives in the keychain, so it still works.
COPILOT_HOME="$(mktemp -d)" copilot -p "$question" -s --model claude-haiku-4.5 --available-tools "" --no-custom-instructions
Receipts
The shared script is tested against a fake ~/source and a fake model, and the Claude and Copilot hooks against a fake title script. The videos were recorded with VHS from tapes saved next to the hooks, with the demo sessions in plan mode so they couldn’t go and actually add emojis to my dotfiles. The Copilot ones get one more demo-only instruction: after renaming, say in a sentence what you’d look at first, and stop. That shows each session picking up its request, such as “Starting: I’ll look at testlanes’ CI workflows and test setup first”, without letting it loose.
It’s all in my dotfiles: the Claude Code hook, the Copilot hook, and the shared script. Copy them, change ~/source to wherever you keep your code, and pick your own emojis.
