Skip to content
Automation
Command

/role

Set this Claude session's agent-bus role so other sessions can address it (e.g. /role frontend, /role backend, /role tester)

From plugin
claudectl
1997 skills1 agent7 commands1 MCP
Install
$ npx -y skills add mercurialsolo/claudectl --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/role

Context preview

What this command does when you run it.

Set this Claude session's agent-bus role so other sessions can address it (e.g. /role frontend, /role backend, /role tester)

Command definition

role.md
name: role
description: Set this Claude session's agent-bus role so other sessions can address it (e.g. /role frontend, /role backend, /role tester)
args: "<role-name>"

Set this session's agent-bus role so peers can send it directed messages with `claudectl bus send <role> …`. The binding is **PID-keyed** — it follows this exact Claude Code process, so re-runs in the same project don't get confused by other sessions sharing the cwd.

Common role names: `spec`, `frontend`, `backend`, `data-analyst`, `tester`, `infra`, `reviewer`, `planner`. Pick whatever maps to what this session will actually own.

What to do

1. The user supplied a role name as `{{args}}`. If it's empty, run `claudectl bus role suggest --json --top 3` to fetch transcript-derived candidates and propose them; if even that comes back empty, ask the user what to name the role and stop until they reply.

2. Run:

   claudectl bus role bind --self {{args}}

The `--self` flag tells the CLI to walk the ancestor process chain, find this Claude Code process, and bind the role to that pid + the current working directory. No need to look up the pid yourself.

3. On success the command prints `bound role <name> -> <cwd> (pid=<pid>)`. Echo that confirmation back to the user.

4. If the command errors with "could not find a Claude Code process in the ancestor chain", the plugin was invoked outside the normal `claude` execution context. Tell the user to try again from inside a Claude session, or pass an explicit pid via `claudectl bus role bind <name> <cwd> --pid <pid>`.

5. If the user wants to verify the binding, suggest `claudectl bus role list` or `claudectl bus whoami --json`.

Why pid-binding

Cwd-only bindings get ambiguous when two Claude sessions run in the same folder (e.g. worktrees, or one session in `/repo` and another in `/repo/sub`). The pid binding picks the specific session you ran `/role` from, so directed messages land where you expect.

See issues #307 (pid binding) and #310 (this slash command).

Read more
Ships withclaudectl

Swarm orchestration for claude code agents with a local brain that steers based on your preferences

Get the whole plugin
Stats
199
Stars
22
Forks
Maintained
Maintenance
Rust
Language
MIT
License
2mo ago
Last commit
5mo ago
Created

Repo: mercurialsolo/claudectl

Other commands on claudectl.