[FEATURE] Allow /rename and /color to be set programmatically at session start
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
note: related issues #35378, #40393, #44245 exist but are stale or partial — this consolidates the use case
I run 10+ Claude Code sessions in parallel, each launched from its own Windows Terminal profile in WSL2. Every profile runs claude '/start-session' and opens a fresh, unnamed, uncoloured session. To make the sessions distinguishable I have to manually type /rename <project> and /color <colour> in every tab, every time.
The tab-title side of this is already a known WSL2 limitation — escape sequences from Claude Code subprocesses don't reach Windows Terminal, so the in-Claude session name is the only reliable identifier I can rely on. And I can't automate it.
There is currently no way to set the session name or colour from:
- project config (.claude/settings.json)
- a CLI flag
- a SessionStart hook
- a skill
- the initial prompt (claude '<prompt>' only dispatches one slash command — chaining /rename and /color after /start-session doesn't work; the second command gets consumed as text)
Proposed Solution
Any one of these would solve it. Listed in order of preference:
- Project config in .claude/settings.json:
{ "session": { "name": "manager", "color": "grey" } }
Cleanest, because the name and colour travel with the repo.
- CLI flags:
claude --session-name manager --session-color grey '/start-session'
- SessionStart hook output — let a hook emit a JSON directive that Claude Code applies (similar to how some hooks inject context).
Alternative Solutions
Tried and ruled out:
- SessionStart hook running shell commands — can't drive client-side UI commands like /rename.
- Custom skill (/start-session) — skills produce model tool calls; no tool can invoke /rename or /color.
- Chained slash commands in initial prompt — claude '/rename foo /color grey' treats everything after the first command as text. Confirmed by direct test.
- Manual /rename + /color after launch — current workflow, doesn't scale to 10+ tabs.
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
- I have Windows Terminal profiles for each of my projects: manager, oksitmgt, phoenix, flexilife, salesending, etc.
- Each profile launches claude '/start-session' in the project directory.
- I open 5–10 tabs at once at the start of the day.
- With this feature, each tab would already be named after its project and colour-coded by category (work = grey, personal = green, etc.) the moment it opens.
- Today I have to manually /rename and /color in every tab — ~30 seconds of friction per tab, every launch.
Additional Context
Related existing issues (mostly stale or partial — none cover the combined name + colour + project-config angle):
- #35378 — /rename settable via --name flag or hooks (stale)
- #40393 — --color CLI flag for session color
- #44245 — statusline scripts setting color and name via JSON control messages
- #47332, #44618, #36928 — project-level session colour config (duplicate / stale)
Environment: Claude Code CLI on WSL2 (Ubuntu 24.04) inside Windows Terminal, multi-project workflow.
Showing cached comments. Read the full discussion on GitHub ↗
14 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
+1 on this — adding a use case the current proposal doesn't quite cover.
I also run multiple Claude Code sessions on the same repo concurrently (different worktrees, parallel agents, etc.). Solution 1 as written (
{ "session": { "color": "grey" } }) gives every tab on that repo the same colour, which puts me back where I started.Two small extensions that would close this gap:
"color": "random:grey"or"color": ["grey-1", "grey-2", "grey-3"]— Claude Code picks a different one per concurrent session.hookSpecificOutput(alongsideadditionalContext). That lets users implement any policy — random shade, hash of worktree path, hash of session ID — without Claude Code having to bake it in.Bare
/color(2.1.128) already does the random pick inside the session; the only missing piece is automating it at start.Author here.
Keeping this open - the 3 flagged "duplicates" each cover one slice; this issue is the consolidation, and the slices don't overlap enough to fold into any single one.
Coverage gap:
This issue asks for all three surfaces (project config + CLI flags + SessionStart hook output) so users can pick whichever fits their workflow.
+1 to @agsonsmith's worktree extensions - same problem here (10+ concurrent sessions, some on the same repo via worktrees).
Concretely:
concurrent sessions on one repo don't all collide on the same shade.
implement any policy (random, hash of worktree path, hash of session id) without Claude Code baking it in.
Happy to close in favour of a single consolidated issue if maintainers prefer - just flagging that the 3 currently flagged don't add up to the full ask.
@SueSingh You can try:
claude -n "test" "/color yellow"+1 on this. Concrete use case: I'm an IC running multiple businesses (an MSP, an
AI automation lab, my wife's e-commerce shop, a 3D-printing side line) plus a job
search, all from the same workstation. At any moment I have 5-10 Claude Code
sessions open across as many repos.
Visual disambiguation between sessions matters a lot when context-switching.
I currently /color each session manually after launch, but I forget about
half the time, and the muscle-memory taxes the very switch the color is meant
to ease.
What would actually help: a single field in .claude/settings.json read at session
start, e.g.
{ "sessionColor": "hexcode" }
Project-level overrides global, the UI honors it without a prompt. No new
slash-command-from-hook plumbing required if the setting is read directly.
Bonus value if cloud Claude Code sessions can render the same color hint, since
I bounce between local + web frequently and the disorientation cost is identical.
Happy to test a prerelease if it helps.
Author here, reporting back.
@zbrkic thanks - tried the -n + /color approach. What worked and what didn't, for the thread:
Worked: the -n / --name flag. It reliably sets the session name, and - notably - the Windows Terminal tab title under WSL2 as well. My original post assumed that was impossible (escape sequences not reaching Windows Terminal); it isn't. This flag also wasn't available when I filed - it shows up in the changelog around v2.1.144 - so it's a recent addition that now fully covers the name/title half of this request.
Didn't work for my setup: /color as the launch command. claude -n 'name' '/color yellow' only colours the session if /color is the one command you launch with. My profiles already launch /start-session, and the initial prompt accepts a single slash command - the second is treated as text (the limitation in the original post). So it's /start-session or /color, never both. zbrkic's one-liner works only for launches that don't already dispatch a command.
How I got colour working anyway - outside Claude Code. Each project has its own Windows Terminal profile with "tabColor" set in settings.json. The OS tab is colour-coded on launch. Caveats: it colours the Windows Terminal tab, not the in-Claude /color accent; and being per-profile it does nothing for @agsonsmith's and @Mfrostbutter's same-repo / worktree case - every session on that profile gets the same colour.
Net: -n covers the name half. The colour half still has no in-Claude answer that survives an existing launch command. The ask stands: color in .claude/settings.json (palette-aware, per @agsonsmith), or a --color flag that doesn't compete with the initial-prompt slot.
+1 — running into the same gap in a different workflow.
Concrete asymmetry worth highlighting: the
SessionStarthook already supportssessionTitleviahookSpecificOutput, so the auto-naming half of this request works today:Adding an analogous
sessionColorfield tohookSpecificOutputwould be the minimal change that closes the loop for everyone using per-project hooks. Thesettings.jsonand CLI-flag variants would still be nicer, but the hook field alone would already unblock auto-color-coding per repo.+1. Use case: launching multiple parallel sessions from shell functions/terminal profiles, each needing a distinct color and name for visual identification.
--name <name>already exists for the rename half; a matching--color <color>flag (or env var / settings key) would complete it. Currently the only path is manually typing/colorin every session, which doesn't work for scripted launches.+1 for
--color {color}shell argI would just add a small enhancement: If I
/renamea session to a colour that is also available via/color, update the TUI with that colour. If I start up a session with a name like 'red', then also color that terminal red; iff there's a colour param also provided with the name, then respect that more-specific colour choice.+1 for --color or something in json
Typing /rename in ten tabs every morning got me too. magent (https://magent.now) opens each project in its own Windows Terminal window running
claude --continueand sets the window title from outside the process, so the WSL2 escape-sequence limit doesn't bite. It won't touch the in-Claude session name or the color, so it only fixes the tab-identity half of this. I work on it.+1 — same need: auto-name and auto-color each session from the first prompt (e.g. open Claude Code, ask for a code review, and the session names itself "Code review — <project>").
Some findings from digging into how
/renameand/colorpersist (v2.1.220, Windows 11):.jsonltranscript:{"type":"custom-title","customTitle":"...","sessionId":"..."}and{"type":"agent-color","agentColor":"purple","sessionId":"..."}. The live session registry~/.claude/sessions/<pid>.jsonalso carriesname+nameSource(derivedvsuser).UserPromptSubmithook could do) partially works: the Windows Terminal tab title and the/resumelist pick up the new name, and the title/color are replayed on resume.So the persistence layer is already there — what's missing is just a supported write path that the TUI applies live. Either of these would solve it:
{"hookSpecificOutput": {"sessionName": "...", "sessionColor": "..."}}onSessionStart/UserPromptSubmit, orclaude session rename <name> --color <color>) targeting a running session.Option 1 on
UserPromptSubmitwould be ideal: the hook sees the first prompt, so it can derive a meaningful title from the actual task.Two things worth adding here, one on the hook side and one on the colour side.
The hook side. A
UserPromptSubmithook can run arbitrary code from a typed token with no model turn, by returningdecision: "block"together withhookSpecificOutput.suppressOriginalPrompt: true, and exiting 2. That is not/colorbecoming programmable, but it does mean "type,web, something happens, no turn burned, nothing added to the transcript" is available today without waiting on a CLI flag.Two details that are easy to lose an hour to:
asyncflag's own schema says the hook runs in the background without blocking, so an async hook returns after the prompt already reached the model and cannot gate anything. Nothing warns you.It only fires at an idle input box. Typed mid-turn the message goes straight to the model, so it is not a general-purpose RPC.
The colour side. My own approach paints the terminal window rather than the Claude Code prompt bar, which sidesteps the escape-sequence problem in the original post entirely, because it never goes through the terminal in the first place. It drives macOS Terminal.app through AppleScript.
That means it is no help at all on WSL2, and I would rather say that plainly here than have someone install it and find out. The Windows Terminal equivalent is driving the profile from outside the process, which is roughly what magent does in the comment above. Worth noting that Terminal.app is the one terminal with no native per-tab colour at all: iTerm2, kitty and Ghostty already have it, so on those the whole problem is a config line rather than a tool.
https://github.com/dotcomjack/claude-session-tint if the hook pattern is useful to lift. MIT.