claude-code - 💡(How to fix) Fix Allow hooks or tools to set session title programmatically [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46880Fetched 2026-04-12 13:30:37
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
commented ×2labeled ×2closed ×1
RAW_BUFFERClick to expand / collapse

Problem

There's no way to programmatically rename a session from within a conversation. The /rename command exists for manual use, but hooks and tool calls have no access to session metadata.

Use case

When resuming work on a specific project mid-session (e.g., picking from a list of active projects), the session title should reflect what's being worked on — making it easier to find and resume later. Today this requires the user to manually type /rename <project name> every time.

What I've explored

  • Hooks: SessionStart, PostToolUse, etc. can run scripts and add additionalContext, but none can modify the session title.
  • CLI flags: claude -n "name" works at startup but isn't available in the Desktop app or mid-session.
  • SDK: renameSession() exists in the Agent SDK but isn't available from within a running session.

Proposed solution (any of these would work)

  1. A tool Claude can call (e.g., SetSessionTitle) to rename the current session from within a response.
  2. A hook output field (e.g., sessionTitle) that lets hook scripts set the session name.
  3. Expose /rename as something hooks can trigger programmatically.

Environment

  • Claude Code Desktop app (macOS)
  • Also relevant to CLI users who want automated naming via hooks

extent analysis

TL;DR

Implementing a SetSessionTitle tool or exposing the /rename command for hooks to trigger programmatically could enable renaming sessions from within conversations.

Guidance

  • Investigate the feasibility of adding a sessionTitle output field to hook scripts, allowing them to set the session name.
  • Explore modifying the existing renameSession() function in the Agent SDK to make it accessible from within a running session.
  • Consider creating a new tool, such as SetSessionTitle, that can be called by Claude to rename the current session.
  • Evaluate the potential impact of exposing the /rename command to hooks, ensuring it does not introduce security vulnerabilities or other issues.

Example

No explicit code example is provided due to the lack of specific implementation details in the issue.

Notes

The proposed solutions require careful consideration of potential security implications and the need for proper validation and error handling to prevent abuse or unintended behavior.

Recommendation

Apply a workaround by implementing a custom tool or hook output field, as upgrading to a fixed version is not mentioned in the issue. This approach allows for a more immediate solution to the problem, enabling programmatic renaming of sessions from within conversations.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING