Claude Code /rename Explained: Give Your Sessions Meaningful Names
Why /rename exists
After using Claude Code for a while, your session history grows long. By default, sessions are only identified by timestamps — to find the debugging context from three days ago, you’re left guessing or scrolling through entries one by one.
/rename solves this: give the current session a meaningful name so your history becomes searchable and traceable.
Basic usage
/rename works two ways:
Manual naming:
/rename fix-auth-token-expiry
Specify a name directly — it takes effect immediately:
Session renamed to: fix-auth-token-expiry
AI auto-naming:
/rename
With no arguments, Claude Code calls the Haiku model to analyze the current session and generate a name automatically. If there isn’t enough content yet, you’ll see:
Could not generate a name: no conversation context yet. Usage: /rename <name>
How AI auto-naming works
When you run /rename without arguments, here’s what happens under the hood:
Step 1: Extract conversation text
Claude Code scans the session’s message history and keeps only actual text from user and assistant messages — skipping tool call results, system messages, and meta messages.
If the conversation text exceeds 1,000 characters, only the last 1,000 are used — a tail-slice so that recent context takes priority, since what you’ve been doing most recently best represents the session.
Step 2: Call Haiku to generate a kebab-case name
The extracted text is sent to Haiku with this system prompt:
“Generate a short kebab-case name (2-4 words) that captures the main topic of this conversation. Use lowercase words separated by hyphens.”
With examples like: fix-login-bug, add-auth-feature, refactor-api-client, debug-test-failures.
Haiku returns a JSON response; Claude Code parses the name field as the final name.
Step 3: Apply the name
The generated name and a manually specified name go through exactly the same save flow.
Why Haiku instead of a more capable model? Naming is a simple summarization task — Haiku is faster and cheaper, and more than adequate.
Naming at startup: the -n flag
Beyond using /rename mid-session, you can name a session right from the start:
claude -n fix-login-bug
# or
claude --name fix-login-bug
The session has a name from the very first message — no need to rename later. The name is immediately written to the session title cache and shows up in /resume listings.
Auto-naming when exiting Plan mode
This is a detail most people never notice.
When you finish drafting a plan in Plan mode (/plan) and are about to move into execution, Claude Code automatically tries to name the session — as long as it doesn’t already have a name.
When it triggers: the moment you confirm exit from Plan mode (Accept Plan).
At that point, Claude Code calls generateSessionName on your plan content (taking the first 1,000 characters, head-slice rather than tail-slice — because the goal is usually stated at the beginning of a plan), generates a kebab-case name, saves it automatically with source set to 'auto' (distinct from /rename’s 'user').
The auto-naming has a guard:
- If the session already has a name (manual or previously auto-named), it won’t be overwritten
- If it’s a “clear-context” operation, the guard is skipped so the new execution session can be named
The dual-title system
Claude Code maintains two separate titles, both stored in the same session .jsonl file:
| Type | Field | Entry type | Source | Priority |
|---|---|---|---|---|
| User-defined title | customTitle | custom-title | /rename, -n flag, Plan mode auto-naming | High |
| AI auto title | aiTitle | ai-title | System background generation | Low |
When reading, customTitle always wins over aiTitle — whatever you explicitly named takes precedence; the system-generated title is just a fallback.
Why two separate entry types instead of one field?
This is intentional design, spelled out in the source comments:
- Prevent AI titles from overwriting user titles:
/resumerestores the title only fromcustom-titleentries, never treating anai-titleentry as a user-defined name - Prevent re-append bugs: When the session file’s tail is rewritten, only
custom-titleentries are re-appended — neverai-title— so a stale AI title can’t overwrite a name the user set mid-session - Separate write semantics: An AI title can overwrite a previous AI title, but it can never overwrite a user title
Two different AI naming formats
Claude Code has two distinct AI naming generators with completely different output formats:
| Source | Format | Example |
|---|---|---|
/rename (no args) | kebab-case, 2–4 words | fix-auth-token-expiry |
| System auto-naming (background) | Sentence case, 3–7 words | Fix login button on mobile |
/rename produces machine-friendly short tags, suited for terminal display and scripting. System auto-naming produces more natural short phrases, suited for UI list display.
Their Haiku calls also differ: /rename uses a name JSON field; the system generator uses a title field. They are entirely independent generators.
Where it’s saved
The name is written as two entries in the session file (~/.claude/projects/<project-hash>/<session-id>.jsonl):
custom-titleentry: stores the name for display in/resumeand other list commandsagent-nameentry: simultaneously updates the agent name shown in the terminal prompt bar, so you can see the current session name while the session is active
Both are appended to the same .jsonl file — no extra files created.
Sync with claude.ai
If you use Claude Code through Claude Desktop or claude.ai/code, /rename also syncs the new name to the cloud Bridge session:
- Checks whether the current session is associated with a Bridge session ID (
replBridgeSessionId) - If so, asynchronously calls
updateBridgeSessionTitleto update the cloud-side title - The sync is non-blocking (fire-and-forget) — failures are silently swallowed and don’t affect local naming
This means a /rename in your terminal also updates the session list on claude.ai.
Can’t rename in Swarm mode
If the current session is a Swarm (multi-agent parallel) Teammate sub-session, /rename refuses:
Cannot rename: This session is a swarm teammate. Teammate names are set by the team leader.
Teammate names are managed by the Team Leader — individual teammates can’t rename themselves, preventing coordination confusion.
Using /rename with /resume
The value of /rename is most visible in /resume:
1. fix-auth-token-expiry 2 hours ago
2. add-payment-webhook yesterday
3. debug-memory-leak-prod 3 days ago
4. 1745123456789 4 days ago ← unnamed, just a timestamp
Named sessions are instantly recognizable. Unnamed ones are just timestamps.
Make it a habit: name the session when you start a new task, or let Plan mode auto-name it for you. Your future self will thank you.
Practical tips
Name early: Once you know what you’re working on, run /rename fix-xxx before diving in.
Use -n at startup: Launch with claude -n refactor-api-client and skip the in-session rename entirely.
When unsure, just /rename (no args): Let AI decide — it’s usually more accurate than whatever you’d improvise, because it’s based on actual conversation content rather than your initial expectations.
Pair with Plan mode: When using /plan, accepting the plan auto-names the session for you — no manual step needed.
Closing thoughts
/rename is a small command, but it solves a real problem: context management for AI-assisted development.
Code commits live in git with full history. But conversations with Claude are nameless and hard to search by default. /rename gives each valuable session a recognizable label — and the dual-title system, Bridge sync, and Plan mode auto-naming together form a session management experience that’s been carefully thought through.
The best filing system is the one you actually use — /rename is how you file your AI conversations.
More Articles
- Why AI-First Startups Only Need One Programming Language
- cc-ping: Ping All Your Claude Code Configs in One Command
- Shocking! This Tool Lets Programmers Finish 95 Minutes of Work in 4 Minutes! 24x Efficiency Boost
- CCBot - 24x Development Efficiency Boost
- Claude Code /add-dir: The Monorepo Command You Miss
- Claude Code Token-Saving Tip: The Power of the Exclamation Mark
- I Built a Bot That Runs Claude Code From Chat
- Claude Code /btw Command Explained: Quick Side Questions Without Breaking Flow
- Claude Code /compact: Free Up Context, Keep Progress
- Claude Code /config: Every Setting Explained
- Claude Code /context: What's Eating Your Context Window?
- Claude Code /diff: See Exactly What Changed, Turn by Turn
- Claude Code /fast: Same Opus, 2x Speed — Worth It?
- Best Practice for External Knowledge in Claude Code: GitHub MCP + Context7
- Claude Code /hooks: Make AI Follow Your Rules
- Claude Code /init: Generate CLAUDE.md in 10 Seconds
- Claude Code MCP: Give Your AI Access to Any Tool
- Claude Code /memory Explained: Make AI Truly Remember Your Project
- Claude Code /model: Opus vs Sonnet vs Haiku Guide
- Claude Code /permissions: Fine-Grained Control Over What AI Can Do
- Claude Code /plan Explained: Think Before You Code
- Claude Code + Playwright MCP: AI Can Finally "See" the Page
- Claude Code /resume Command Explained: Don't Let Your Conversations Go to Waste
- Claude Code /review: Let AI Do Your Code Review
- Claude Code Skills Explained: Build Your Custom Command Library
- Claude Code /stats: See How Much AI Does For You
- Claude Code /status Command Explained: Your Session Dashboard
- Claude Code /tasks Command Explained: Master Your Background Tasks
- Claude Code /usage Command Explained: Know Your Remaining Quota
- Claude Code /vim: Vim Keybindings in Your AI Coding Assistant
- Claude Code in 2026: The Only Setup Guide You Need
- The Complete Guide to Claude: From Chat to Code to Automation
- Claude Code /agents Explained: Custom AI Sub-Agents, Each with Their Own Role
- Claude Code /doctor Explained: One-Click Diagnostics for Your Dev Environment
- Claude Code /effort Explained: Control How Hard Your AI Thinks
- Claude Code /cost Explained: How Much Is Your AI Coding Really Costing?
- Claude Code /export Explained: Take Your AI Conversations With You
- Claude Code /rewind Explained: AI Made a Mistake? Undo It Instantly
- Claude Code /plugin Explained: Install Plugins for Your AI Coding Assistant
- Claude Code /theme Explained: Give Your Terminal a New Look
- Claude Code /insights: Using AI to Analyze How You Use AI
- Claude Code settings.json Explained (1): Where Config Files Live and Who Wins
- Claude Code settings.json Deep Dive (Part 2): The Permissions System
- Claude Code settings.json Deep Dive (Part 3): The Hooks System
- Claude Code settings.json Deep Dive (4): env, Models, Auth, and Other Useful Fields