Claude Code Background Sessions and Agent View

Remote Control needs the session to stay running, which is why closing your terminal ends it. Background sessions sidestep that. They run under a supervisor process on your machine and keep going after you close agent view or the terminal entirely, which makes them the closest thing Claude Code has to leaving work running locally.

Open the screen with claude agents. Start a background session from anywhere with claude --bg "task description". Requires Claude Code v2.1.139 or later.

What agent view shows

Sessions grouped by state, with a one-line summary of each generated from its output. The icon tells you the state at a glance:

IconStateMeaning
Animated WorkingRunning tools or generating
Yellow Needs inputWaiting on a permission, answer, or question
Dimmed IdleReady for the next prompt
Green CompletedFinished successfully
Red FailedEnded with an error
SleepingA /loop session between iterations

The shape carries information too. A round dot means the process has exited but the session can still reply, restarting from saved state. That distinction matters when you are deciding whether something is stuck or simply idle.

Three ways to background something

From the shell

claude --bg "investigate the flaky auth test"
claude --bg --name "auth-fix" "task"
claude --bg --agent code-reviewer "review PR 412"
claude --bg --exec 'pytest -x'

From inside a session

/bg backgrounds the session you are in, optionally with a new instruction. /background is an alias. Pressing the left arrow on an empty prompt does the same thing and opens agent view. From v2.1.212, /fork copies the conversation into a new session instead of moving it.

From agent view

Type a prompt and press Enter to dispatch. The input accepts prefixes: @agent-name to pick a subagent, @repo to target a repository, /command for skills, ! to run a shell command as a job, or a PR number. Shift+Enter dispatches and attaches immediately.

What survives the transition

This is the part that decides whether backgrounding is safe for the work you have in flight.

Carries overDoes not
Conversation transcriptRunning monitors, which are stopped
Running background shell commandsCommands needing an attached terminal
Subagents and their work
Dynamic workflows
Scheduled /loop tasks
Model, permission mode, effort level
--mcp-config, --settings, --add-dir, --plugin-dir
Name set with /rename

That /loop row is the useful one. A polling loop carries into the background session and keeps firing, which is the documented way to keep one running without a terminal. See scheduled tasks.

Set CLAUDE_DISABLE_ADOPT=1 if you would rather in-flight work stopped than carried over.

Working with a session you cannot see

Peeking is the feature worth learning. Press Space in agent view to see a session’s latest output or question, type a reply, press Enter, and you have answered it without attaching. For a multiple-choice question, press the number key. Tab offers a suggested reply.

To go further in, press the right arrow or Enter to attach. Inside an attached session, the left arrow detaches, Ctrl+Z returns you to where you came from, and /stop ends it.

From the shell instead

claude attach <id>
claude logs <id>
claude stop <id>
claude respawn <id>
claude respawn --all
claude rm <id>
claude daemon status

claude respawn restarts a session and picks up updates, and --all does the lot. For scripting, claude agents --json lists active sessions with id, state, pid, status, waitingFor and cwd; add --all to include completed ones.

File isolation, and the trap in it

Background sessions edit inside isolated git worktrees under .claude/worktrees/ by default, which is what lets several run at once without fighting over the same files. You can turn that off:

{
  "worktree": {
    "bgIsolation": "none"
  }
}

Commit before you delete a session in agent view. Agent view removes the worktree along with the session, including uncommitted changes. The shell command claude rm behaves differently and keeps worktrees that have uncommitted or unpushed work. Worktrees you created yourself are always kept.

How this compares to Remote Control

Background sessionsRemote Control
Survives closing the terminalYesNo
Reachable from your phoneNoYes
Runs onYour machineYour machine
You interact throughAgent view or claude attachclaude.ai or the Claude app

They answer different questions. Background sessions solve “I want to close this terminal”. Remote Control solves “I want to watch this from elsewhere”. Neither survives the machine shutting down, so for that you want an always-on machine or a cloud session.

Limits

  • Quota is consumed per session. Ten parallel background sessions use roughly ten times the quota.
  • Local only. They stop when the machine shuts down.
  • Research preview. Behaviour may change.

Related: Remote Control sessions, and permission modes, because a background session that hits a prompt sits in the yellow needs-input state until you answer it.