[FEATURE] Non-interactive attach to a background agent: `claude agents attach <id|name>`

Open 💬 1 comment Opened Jun 10, 2026 by chriswithers-fuse

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

When running several background agents (dispatched via claude agents or as background jobs), jumping into a specific one currently requires opening the interactive agent view (claude agents), scanning the list, and selecting the session by hand. There is no way to attach to a known background agent directly from the shell.

This makes it awkward to:

  • script "jump back into agent X" workflows (shell aliases, tmux/wezterm keybindings, fuzzy-finder pickers built on claude agents --json)
  • attach quickly when you already know exactly which agent you want (by name, ID, or worktree path)

The closest thing today is claude --resume <sessionId>, but per the sessions docs that reopens the transcript rather than attaching to the live managed session the way the agent view does, and resuming a session that's actively running in another process interleaves two writers into one transcript.

Proposed Solution

A non-interactive attach entry point, e.g.:

claude agents attach <id|name>
# or
claude attach <id|name>

that does exactly what selecting the session in the claude agents view does (attach to the live session, to detach), but skips the picker. Matching by the short agent id, name, or sessionId from claude agents --json would all be useful; a --cwd <path> matcher would also fit nicely with the existing claude agents --cwd filter.

Alternative Solutions

  • claude agents --json | jq ... to find the sessionId, then claude -r <sessionId> — works, but it's transcript resume rather than a true attach to the live managed session, with the dual-writer interleaving caveat.
  • tmux-style tools solve this with tmux attach -t <name>; same ergonomics would be great here.

Priority

Medium - Would be very helpful

Feature Category

CLI commands and flags

Use Case Example

  1. I have 4 background agents working on separate worktrees of a monorepo.
  2. One of them reports needs input: (visible in the job list / notifications).
  3. Today: run claude agents, find it in the list, select it.
  4. With this feature: claude agents attach dataset-filtering (or a keybinding that runs claude agents attach $(... | fzf)) and I'm in the live session immediately.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗