claude agents --json: List Live Sessions as JSON for Scripts and Status Bars
Claude Code v2.1.145 adds a --json flag to the claude agents command, enabling developers to programmatically query all live Claude sessions as structured JSON output. This makes it straightforward to build custom integrations β from tmux-resurrect session persistence to status bar widgets and session picker UIs. Additionally, terminal tab titles for claude agents windows now display a count of sessions awaiting input, so developers with multiple parallel agents can see at a glance which ones need attention without switching windows.
Sources & Mentions
3 external resources covering this update
claude agents --json: Machine-Readable Live Session Listing
Claude Code v2.1.145 introduces claude agents --json, a new flag that outputs the full list of currently running Claude sessions as structured JSON. This capability is aimed squarely at developers who want to build tooling on top of Claude Code's multi-agent workflows β integrating session state into tmux-resurrect configurations, populating custom session pickers, or populating status bars and dashboard widgets with real-time agent state.
What It Enables
Before this flag, introspecting which agents were running required either reading terminal output manually or parsing Claude Code's internal process state. The --json output gives tooling authors a clean, stable interface: a machine-readable list of live sessions with the metadata needed to route commands, restart sessions, or surface agent status in external UIs.
Common use cases cited by Anthropic include:
- tmux-resurrect integrations that can save and restore active Claude sessions alongside the rest of your terminal layout
- Status bar widgets (e.g., i3blocks, Polybar, tmux status line) that show how many agents are running or waiting for input
- Session pickers that let you jump between agents from a launcher or fuzzy-finder
Tab Title Awaiting-Input Count
Alongside the JSON flag, v2.1.145 also adds the awaiting-input count to the terminal tab title for claude agents windows. When you have an agent view open in a background window or tab, the title now shows how many sessions are sitting and waiting for a response. This means you can spot a blocking agent without switching focus β the window title tells you.
OTEL Tracing Improvements
For teams using OpenTelemetry to monitor their Claude Code workflows, v2.1.145 adds agent_id and parent_agent_id attributes to claude_code.tool OTEL spans. Crucially, trace parenting is now fixed so that background subagent spans correctly nest under the dispatching Agent tool span β making distributed traces readable and hierarchical rather than flat.
Other Notable Fixes in v2.1.145
- Mouse hover and click now work in the slash command and @-mention suggestion list in fullscreen mode
- Stop and SubagentStop hook input now includes
background_tasksandsession_cronsfields, giving hooks richer context about the agent's state at termination - The Read tool now returns a truncated first page with a "PARTIAL view" notice instead of a hard error when a whole-file read exceeds the token limit
- Fixed a security issue where bare variable assignments to non-allowlisted environment variables in Bash commands were being auto-approved, bypassing permission prompts