[FEATURE] Surface short session IDs — shell `claude agents list` + show IDs in agent view
Open 💬 2 comments Opened May 12, 2026 by nitsanavni
The shell commands documented at Manage sessions from the shell — claude attach <id>, claude logs <id>, claude stop <id>, claude respawn <id>, claude rm <id> — all take a short ID, but the ID is hard to obtain:
- No shell-side list command.
claude agentsonly opens the TUI.claude agents --help(v2.1.139) shows nolist/lssubcommand. The only path today is parsing~/.claude/daemon/roster.jsonand~/.claude/jobs/<id>/state.jsonby hand. - TUI rows don't show the short ID. Each row shows name + activity + age, but not the 8-char hash you'd type into
claude attach. So even after spotting the right session visually, you have to background, jq the roster, or peek at the worktree path to find its ID.
Proposal
- Shell:
claude agents list(aliasls) — one row per session: short id, state, agent, cwd, age, one-line summary.--jsonfor scripting. Filters mirroring the TUI grammar would be a bonus (--state working|blocked|done|stopped|failed,--agent <name>). - TUI: show the short ID on each row (or as a togglable column / dimmed prefix). A keybinding to copy the selected session's ID to the clipboard would be the cherry.
Use cases
- Scripting cleanup of stopped sessions.
- Attaching to a session by ID from a second terminal without first backgrounding the current one to open agent view.
- Finding a session by its prompt/cwd before
attach. - Dashboards/automation over many sessions across repos.
Workaround today
jq -r '.workers | to_entries[] | "\(.key)\t\(.value.cwd)\t\(.value.dispatch.seed.intent // "")"' ~/.claude/daemon/roster.json
Works for running sessions; stopped ones need a glob over ~/.claude/jobs/*/state.json. Both depend on undocumented on-disk layout.
Environment
- Claude Code v2.1.139
- Linux (devcontainer)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗