Allow setting session name from within prompt text for background agents
Feature Request
Is your feature request related to a problem?
When spawning background agents (e.g. via Claude Agents view or programmatically), there's no way to define a custom session name from within the prompt itself. Currently the only options are:
claude --bg --name "XXX" "prompt"— requires setting it at the shell levelCtrl+Rin the agents view — manual rename after the fact
This means if you're dispatching agents from within a Claude session (or from workflows/scripts that don't have direct access to the --name flag), all sessions get auto-generated names from the prompt text, making it hard to identify them at a glance — especially when working across multiple repos/branches.
Describe the solution you'd like
Support a directive in the prompt text that sets the session name automatically, e.g.:
# name: e2emon/feature-otel-metrics
Investigate the flaky SettingsChangeDetector test and fix it.
Or alternatively a frontmatter-style header:
---
name: e2emon/feature-otel-metrics
---
Investigate the flaky SettingsChangeDetector test and fix it.
This would allow users to label background agents with meaningful identifiers (repo, branch, task) directly from the prompt — without needing shell-level access to --name.
Describe alternatives you've considered
- Using
--nameat the CLI level (not always accessible, e.g. when dispatching from within a session) - Manually renaming with
Ctrl+R(doesn't scale when running many parallel agents) - Encoding context in the first line of the prompt (relies on auto-naming heuristics, often gets truncated)
Additional context
This would be especially useful for users who:
- Run many parallel background agents across different repos/branches
- Use workflows or automation that spawns agents
- Want to quickly identify agents by project/branch in the agents overview
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗