claude.nagdy.me

Use claude agents --json from scripts

Consume the Agent view from a shell script via --json. Useful for tmux-resurrect-style boot scripts, custom status bars, and session pickers. Filter on `status` and use `waitingFor` to distinguish a permission prompt from a session that needs your input.

bash
# Count sessions waiting on user input
claude agents --json | jq '[.[] | select(.status == "waiting")] | length'

# Print a one-line status: <name> <status> for every working session
claude agents --json \
  | jq -r '.[] | select(.status == "working") | "\(.name)\t\(.status)"'

# Wake only the sessions blocked on a permission prompt
claude agents --json \
  | jq -r '.[] | select(.status == "waiting" and .waitingFor == "permission prompt") | .sessionId' \
  | xargs -I {} claude respawn {}
View Full Module