Feature request: Allow Claude to programmatically rename sessions

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

Summary

Allow Claude to automatically rename the current session when a user mentions or shares a ticket ID (e.g., TICKET-123). Today, session naming is manual-only via /rename, and there's no tool or hook that can trigger a rename programmatically.

Use Case

When working on a Linear ticket, I often mention or paste the ticket ID in conversation. I'd like Claude to automatically set the session name to that ticket ID so I can easily find and resume it later.

Currently, I have to manually run /rename TICKET-123 every time, which breaks flow.

Proposed Solution

One of:

  1. A built-in tool (e.g., SessionRename) that Claude can call to rename the current session when contextually appropriate (e.g., when a ticket ID is mentioned).
  2. A hook event that fires when a session name could be inferred, allowing custom logic to set it.
  3. A --name CLI flag for setting the session name at launch, combined with an in-session tool for dynamic renaming.

The ideal behavior: when I say "I'm working on TICKET-123" or paste a ticket URL, Claude detects the ticket ID and renames the session automatically — no manual /rename needed.

Current Workarounds

  • Manual /rename after every session start
  • Shell wrapper functions that inject context via --append-system-prompt, but still can't rename
  • Worktree naming provides some discoverability but isn't a session name

View original on GitHub ↗

12 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/25045
  2. https://github.com/anthropics/claude-code/issues/27591
  3. https://github.com/anthropics/claude-code/issues/28725

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

DT209 · 6 months ago

Those interested in this should upvote https://github.com/anthropics/claude-code/issues/25045**

senaiworks · 6 months ago

Since remote sessions landed, I've been accessing Claude Code from my phone regularly. The problem is session names are often meaningless when browsing from a small screen — I can't tell what each session is about without opening it.

My ideal workflow would be using a hook (e.g. on Stop or a periodic trigger) to automatically rename the session based on the current development context. Something like renaming to the active branch + task summary every ~10 minutes.

A sessionName field in hook output (as proposed in #24872) or a dedicated CLI command like claude session rename would both solve this. Either way, programmatic access to session renaming is the missing piece for making remote sessions truly usable.

estesbreninc · 5 months ago

Additional use case: AI-initiated session naming at startup

I have a workflow where a SessionStart hook injects a timestamp and CLAUDE.md instructions tell Claude to ask "What would you like to name this session?" at the start of every new conversation. The user provides a name, Claude constructs the full title (e.g., 2026-03-27_1229-auth-refactor) — and then hits a wall.

Claude can't invoke /rename. The only option is to output the command as text and ask the user to copy/paste it:

Run this to name your session: /rename 2026-03-27_1229-auth-refactor

This adds friction to every single session start.

Workaround attempted: I built a Stop/PostCompact hook that writes custom-title entries directly to the session JSONL file and maintains a sidecar .title file next to it (to survive the 64KB tail window compaction — same issue documented in #33165). This persists the name for /resume and session lists, but does not update the live prompt line or terminal tab title, since those are controlled by Claude Code's internal UI state. Only /rename or a session resume triggers those UI updates.

A SessionRename tool callable by the AI would completely solve this — Claude already has the name, it just needs a way to apply it that updates the live UI.

yichao-figma · 5 months ago

Another useful feature would be auto suggest renaming, potentially after session grows beyond certain length so we don't need it for trivial session.

GravyaDev · 4 months ago

+1 — and a prerequisite for this to be useful: a lock mechanism on session names.

Today, even manually renamed sessions get auto-overwritten by task-generated titles during the conversation. A programmatic rename API would suffer the same problem — the auto-rename would silently overwrite it.

Proposal: a locked flag (set automatically on any manual or programmatic rename) that prevents auto-rename from overwriting the name. This makes both the current /rename and any future programmatic rename actually stick.

---

Disclaimer: this comment and the proposal it contains were drafted by Kloud AI assistant (kloud@gravya.it) under human review and approval. Human in the loop: GravyaDev.

NightMean · 4 months ago

+1 Would be really useful in combination with skills

punkhop · 3 months ago

+1 — adding a real-world ergonomic case that I haven't seen articulated in this thread:

I run 6-10 concurrent Claude Code sessions across a tabbed terminal (one per task / branch / worktree). My primary way to find old work is the /resume picker. When sessions don't have a clear name, the picker shows the first line of the conversation, which is usually noise like "ok let's look at this" or system context. Result: prior conversations become unfindable within a day.

Manual /rename is unreliable because I'm thinking about the work I'm doing, not the session metadata. By the time I remember to rename, I've already lost track of which tab was which. Sessions that took hours to build up get effectively orphaned because I can't find them in the picker the next morning.

The interim workaround (/rename with no args — Haiku auto-generates a name from current context) helps when I remember to use it, but the whole point of the friction is that I forget. A programmatic path — even just a hook that fires after the first substantive exchange and auto-names via Haiku — would close the gap.

Workflow pattern that would benefit: heavy multi-session users where /resume is the primary navigation surface.

lilrkt · 2 months ago

This would be fantastic. Looking to take advantage of tooling that would be nice to have standardized.

RaphaelMaschinsen · 2 months ago

This would be really useful! When working with parallel sessions on a related problem it can get confusing to have to remember which one is working exactly on what issue at the moment, seeing it in the GUI would be very helpful.

Donutellko · 1 month ago

The workaround that I'm currently using:

A UserPromptSubmit hook (in ~/.claude/settings.json) runs a script that reads transcript_path from stdin, extracts your last assistant turn, and greps for a marker like <!--rename: TITLE -->, emitting {"hookSpecificOutput":{"hookEventName":"UserPromptSubmit","sessionTitle":"TITLE"}} — because only SessionStart/UserPromptSubmit (not Stop) can set the title, so the rename lands on your next message. A CLAUDE.md rule instructs Claude to end replies with that marker when the session name is stale, so naming happens automatically with no /rename copy-pasting — just a one-message delay.
0xneelo · 27 days ago

bump

Showing cached comments. Read the full discussion on GitHub ↗