Feature: Allow programmatic session rename from skills/commands

Status Fixed / completed
Maintainer reply None cached
Activity 13 comments · opened Mar 14, 2026 · closed Aug 17, 2026

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)

  1. AI-accessible tool — A SessionRename tool that the AI can call from within skills/commands, similar to how TaskCreate/TaskUpdate work for task management.
  1. Hook capability — Allow hooks to rename the session. Hooks already receive session_id in their input JSON; adding a rename capability via stdout or a response field would be natural.
  1. CLI subcommandclaude 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.

View original on GitHub ↗

10 Comments

tobias-f · 5 months ago

👍 for this one... naming sessions programmatically would be fantastic

yurukusa · 5 months ago

A hook can set the terminal/tmux title as a proxy for session renaming:

SKILL=$(cat | jq -r '.tool_input.skill // empty' 2>/dev/null)
if [ -n "$SKILL" ]; then
    printf '\033]2;CC: /%s\033\\' "$SKILL" 2>/dev/null
    tmux rename-window "/%s" 2>/dev/null
fi
exit 0

Or skills can write their desired name:

echo "deploy-v2" > /tmp/cc-session-name
Raymondhou0917 · 4 months ago

+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 Stop hook (auto-title.sh) that uses Haiku to generate a Chinese summary from the last 5 user messages, then writes it as custom-title to the session JSONL. This works perfectly for the CLI /resume picker — titles are in Chinese and update dynamically as the conversation progresses.

The problem: The Desktop App sidebar completely ignores custom-title from 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:

  1. Language control — Let hooks or settings specify the title language (e.g., titleLanguage: "zh-TW")
  2. Dynamic updates — Titles should reflect the current topic, not just the first message (like ChatGPT does)
  3. Hook integration — Let Stop hooks set sessionName via hookSpecificOutput, so the Desktop App, CLI, and terminal tabs all show the same title

My 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-title entry to the JSONL.

pacaplan · 4 months ago

Please please. Stop making us hunt down sessions unnecessarily. I will build a hook to auto-rename in a heartbeat.

Baswouelle · 4 months ago

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.

jkgeekJack · 4 months ago

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 UserPromptSubmit hook 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:

curl -fsSL https://raw.githubusercontent.com/jkgeekJack/cc-session-title/main/install.sh | bash

Hope it helps until this is supported natively!

cameron-bales-telus-health · 4 months ago

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.

Mathias-Xuviate · 3 months ago

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.

Usefz89 · 3 months ago

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

dotcomjack · 23 days ago

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 UserPromptSubmit hook 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:

{
  "decision": "block",
  "reason": "text shown to the user, verbatim",
  "hookSpecificOutput": {
    "hookEventName": "UserPromptSubmit",
    "suppressOriginalPrompt": true
  }
}

Three things about it are easy to get wrong, and each one cost me a session to find:

  • The hook must be synchronous. The async flag'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.
  • Exit 2 as well as printing the JSON. With exit 0 you land in a branch that reports the outcome as success and appends a spurious "completed" line to your output. Exit 2 skips it, and since decision: "block" has already set the blocking error, the [<command>]: <stderr> wrapper never replaces your text either.
  • suppressOriginalPrompt is what stops the blocked line being echoed back into the transcript as Original 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.

Showing cached comments. Read the full discussion on GitHub ↗