claude-code - 💡(How to fix) Fix Add --init-commands flag to execute slash commands at session startup [1 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#48357Fetched 2026-04-16 07:02:30
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Root Cause

  • Scripted/templated launches (wrapper shell functions, project-specific aliases)
  • tmux/iTerm session layouts that launch multiple pre-configured Claude instances
  • Reproducible session setup across team members

Fix Action

Fix / Workaround

The existing -n / --name flag sets the session's internal name but doesn't trigger the visual prompt-bar tag and colour that /rename produces — so even that partial workaround isn't equivalent.

Code Example

claude --init-commands "/rename auth-refactor" "/color blue"
RAW_BUFFERClick to expand / collapse

Problem

When launching an interactive session, there's no way to pre-execute slash commands like /rename, /color, /model, etc. Users who want a named/coloured session have to launch claude, wait for the TUI, then manually type the commands.

The existing -n / --name flag sets the session's internal name but doesn't trigger the visual prompt-bar tag and colour that /rename produces — so even that partial workaround isn't equivalent.

Proposed solution

Add an --init-commands (or similar) flag that accepts one or more slash commands to run before the first user turn:

claude --init-commands "/rename auth-refactor" "/color blue"

Alternatively/additionally, make -n/--name also trigger the visual tag/colour behaviour that /rename does, for parity.

Why this matters

  • Scripted/templated launches (wrapper shell functions, project-specific aliases)
  • tmux/iTerm session layouts that launch multiple pre-configured Claude instances
  • Reproducible session setup across team members

Related

  • #47679 — requests programmatic access to /rename and /color from tools/skills (runtime angle; this issue covers the CLI launch angle)

extent analysis

TL;DR

Adding an --init-commands flag to execute slash commands before the first user turn is the most likely fix.

Guidance

  • Consider implementing the proposed --init-commands flag to accept one or more slash commands, allowing users to pre-execute commands like /rename and /color.
  • Evaluate modifying the existing -n / --name flag to trigger the visual prompt-bar tag and color, providing parity with the /rename command.
  • Review related issue #47679 for potential insights into programmatic access to /rename and /color commands.
  • Assess the feasibility of adding support for multiple commands to the --init-commands flag, as demonstrated in the example: claude --init-commands "/rename auth-refactor" "/color blue".

Example

claude --init-commands "/rename auth-refactor" "/color blue"

Notes

The proposed solution focuses on adding a new flag, but it's essential to consider potential conflicts or interactions with existing flags and commands.

Recommendation

Apply workaround: Implement the proposed --init-commands flag to provide users with a way to pre-execute slash commands, addressing the current limitation.

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

claude-code - 💡(How to fix) Fix Add --init-commands flag to execute slash commands at session startup [1 comments, 2 participants]