Expose session name as a variable (e.g. $session_name) for use in shell/loop commands

Status Open
Maintainer reply None cached
Activity 0 comments · opened Aug 19, 2026

User story

As a Claude Code user, I use /rename to store useful context in the session name — e.g. the working directory of an implementation plan I'm executing against. Right now that name is only a display label; there's no way for me or the agent to retrieve it programmatically.

I'd like the current session name to be exposed as a variable (e.g. $session_name or similar) that:

  • I can reference in prompts to the agent
  • The agent can parse and use directly to run shell commands or drive loops (e.g. /loop), without me having to re-type or re-paste the path/context every time

Why

/rename already lets me stash a short, meaningful string per session. Making it retrievable turns it from a passive label into something the agent can act on — saving repeated context-setting at the start of every turn.

Suggested shape

  • A read-only variable/env-style reference (e.g. $session_name) resolvable in the agent's context
  • Optionally, a small builtin or tool the agent can call to fetch the current session's name at any point in the conversation

View original on GitHub ↗