Feature: Allow programmatic session rename from skills/commands
Problem
The /rename command (added in v2.1.76) is a great feature for naming sessions, but it cannot be automated within custom workflows. This creates friction for users who have slash commands that already have the perfect session name available programmatically.
Concrete use case: I have a /start TICKET-XXX command that fetches a Linear ticket title, creates a feature branch, and begins work. At Step 4, it already has the ticket ID and title (e.g., "IOS-21: Build new platform app command"). This is the ideal session name — but there is no way to set it automatically.
Current limitations
| Method | Limitation |
|--------|-----------|
| /rename "name" | Interactive only — AI cannot invoke built-in commands |
| claude -n "name" | Requires knowing the name before session start |
| Hooks | Receive session_id but explicitly cannot rename sessions |
| Bash tool | No claude session rename CLI subcommand exists |
Proposed solution (any of these would work)
- AI-accessible tool — A
SessionRenametool that the AI can call from within skills/commands, similar to howTaskCreate/TaskUpdatework for task management.
- Hook capability — Allow hooks to rename the session. Hooks already receive
session_idin their input JSON; adding a rename capability via stdout or a response field would be natural.
- CLI subcommand —
claude session rename <session-id> <name>callable from Bash, with the session ID available via environment variable (e.g.,$CLAUDE_SESSION_ID).
Option 1 is the most ergonomic — it would let any custom command set a meaningful session name as part of its workflow.
Impact
This would make /resume significantly more useful for power users who work across many tickets/sessions. Currently, sessions show up as unnamed entries; with automation, every /start session would be instantly identifiable by ticket ID and title.
Showing cached comments. Read the full discussion on GitHub ↗
10 Comments
👍 for this one... naming sessions programmatically would be fantastic
A hook can set the terminal/tmux title as a proxy for session renaming:
Or skills can write their desired name:
+1 for this feature. I'm a power user running Claude Code on macOS with cmux (multiple sessions) and the Desktop App.
My current workaround: I built a
Stophook (auto-title.sh) that uses Haiku to generate a Chinese summary from the last 5 user messages, then writes it ascustom-titleto the session JSONL. This works perfectly for the CLI/resumepicker — titles are in Chinese and update dynamically as the conversation progresses.The problem: The Desktop App sidebar completely ignores
custom-titlefrom JSONL and generates its own English titles. This means I have two separate title systems that don't talk to each other.What I need:
titleLanguage: "zh-TW")Stophooks setsessionNameviahookSpecificOutput, so the Desktop App, CLI, and terminal tabs all show the same titleMy hook script is open source if anyone wants to reference it: it reads the transcript, extracts recent user messages, calls Haiku for a 10-20 character Chinese summary, and appends a
custom-titleentry to the JSONL.Please please. Stop making us hunt down sessions unnecessarily. I will build a hook to auto-rename in a heartbeat.
adding the ios app angle since nobody mentioned it. running 5 parallel sessions with remote control on, the iphone session list shows auto generated titles frozen at the first turn. by turn 50 i can't tell them apart on a 6" screen.
shell wrapper with
--name "$(basename $PWD)/$(git branch --show-current)"at startup helps but goes stale the moment the session evolves. need a programatic rename callable from a hook so titles can stay fresh across cli, desktop, and ios.I've implemented this feature as a small open-source hook: cc-session-title
It disables Claude Code's built-in English-only title generator and replaces it with a
UserPromptSubmithook that calls Claude Haiku with a system prompt that forces the output language to match your input language. Works with tmux#{pane_title}, iTerm2, Terminal.app, and any terminal that honors OSC 0/2.Install with one line:
Hope it helps until this is supported natively!
Running a 10-step guided setup in Cowork where each step is a new chat. They all get named 'Continue Setup Process' and the sidebar becomes unnavigable.
I run 10+ scheduled tasks via Claude Code Desktop. Each one creates a Remote Control bridge session visible on the Android app.
The bridge title always falls back to <hostname>-<adjective>-<scientist> Because these are scheduled tasks with no interactive turn, there is no opportunity for the user to issue /rename manually
Impact: With "Enable Remote Control for all sessions" on, the Android session list fills up with unreadable codenames for every heartbeat run, including silent no-op runs that find nothing.
What would fix it: A way for a non-interactive session (scheduled task, hook, automated script) to set its own Remote Control bridge title programmatically — either via a --name flag at session creation time, a SKILL.md frontmatter field like remote_control_name:, or a tool call that works in bypassPermissions mode.
Withh new claude agents. yes renaminig session with the app/repo name at start for example will be handy. claude should make it possible that user add hook or config settings to configure the naming process for the session
The table in the issue is right that hooks cannot rename a session. One adjacent primitive is worth writing down though, because it is undocumented and it covers part of what people are reaching for in this thread: a
UserPromptSubmithook can intercept a typed token and run arbitrary code without invoking the model. No turn, no tokens, no assistant message in the transcript.The hook prints this and exits 2:
Three things about it are easy to get wrong, and each one cost me a session to find:
asyncflag's own schema says it 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 just silently stops working.decision: "block"has already set the blocking error, the[<command>]: <stderr>wrapper never replaces your text either.suppressOriginalPromptis what stops the blocked line being echoed back into the transcript asOriginal prompt: <what you typed>. A bare exit 2 cannot set it, which is why the hook emits JSON rather than just exiting.Known limit, in the same breath: this only fires on a prompt submitted at an idle input box. Typed mid-turn, the message is delivered to the model directly, never reaches
UserPromptSubmit, and costs a turn.This does not rename the session, so it is not the feature being asked for here. But if what you actually want is "type a short token, have something happen, no turn burned", that primitive exists today. Measured against 2.1.224.
I used it for per-project terminal tinting, which is a different problem but the same hook: https://github.com/dotcomjack/claude-session-tint. MIT, and the hook file is about a hundred lines if it is easier to read than to describe.