Allow Claude to rename its own session (programmatic session rename API)

Open 💬 7 comments Opened Mar 11, 2026 by dokipen

Problem

When using Claude Code in VS Code with agentic workflows, it's useful to name sessions by the issue/task number being worked on. Currently this requires manual renaming via the UI.

I investigated making Claude rename its own session programmatically by appending custom-title entries to the session .jsonl file (which is what the extension's renameSession() does internally). This partially works but has two issues:

1. Session list titles lost on long sessions

The session list (listSessions) reads titles by scanning only the last 64KB of each .jsonl file for "customTitle" entries. On long sessions (common with agentic workflows), the custom-title entry gets pushed outside this 64KB tail window by subsequent conversation messages, and the title is lost from the session list.

2. No way to update the live tab title

The editor tab title is set via an internal rename_tab webview message. There's no registered VS Code command to trigger this externally. Even if the file-based title is correct, the active tab title can't be updated without going through the extension's internal message channel.

Proposed Solution

Expose a VS Code command like claude-vscode.renameSession that:

  1. Appends the custom-title entry to the .jsonl file (already implemented internally)
  2. Updates the in-memory customTitles Map
  3. Sends a rename_tab message to update the live tab title
  4. Refreshes the session list sidebar

This would allow Claude itself (or other extensions/tools) to set meaningful session names programmatically.

Alternative for #1 alone

Store custom titles in a separate lightweight index (e.g., sessions-index.json or a small sidecar file) rather than relying on scanning the tail of potentially large .jsonl files.

Use Case

Agentic workflows where each session maps to a GitHub issue. Having Claude auto-name the session (e.g., "941-fix-supabase-release") at the start of a workflow would save manual effort and improve session organization.

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗