# Claude Code Background Agents: The Supervisor Model

> Background sessions are hosted by a per-user supervisor process that outlives your shell. That single fact explains the worktrees, the credentials, and the surprises.

URL: https://www.matthewswong.com/en/blog/claude-code-agent-view-background-sessions/

- Author: Matthews Wong (https://www.matthewswong.com/en/about/)
- Published: 2026-08-27
- Updated: 2026-08-27
- Category: AI

> **Key takeaway:** Claude Code background sessions run without a terminal attached, hosted by a per-user supervisor process that persists across auto-updates and outlives the shell that started it. Before editing files, each session moves into its own git worktree so parallel sessions do not collide. Ten parallel sessions consume roughly ten times the quota.

I dispatched four background sessions, closed the terminal, and came back to find all four still working. That was the point, and it was still slightly startling. What made it possible is a process I had not known existed: a supervisor that started on my first background dispatch, took ownership of every session, and has no relationship to the terminal I happened to launch it from.

Almost every non-obvious behaviour here follows from that architecture, including one I had already been bitten by in a completely different context. This post covers the ways to dispatch, the supervisor and what it inherits, the worktree isolation that makes parallelism safe, what survives when you move a session to the background, and the honest cost of running ten agents at once.

## Dispatch, and the difference between moving and copying

There is a management UI and there is the shell, and both reach the same thing. The distinction worth internalising early is between the two ways of pushing a live conversation into the background, because one of them leaves you with nothing in front of you.

Backgrounding moves the conversation — your terminal is free and the work continues elsewhere. Forking copies it, so the background session carries the context and you keep the conversation you were in. Fork is almost always what you want when you are mid-investigation and want a side quest run without losing your place.

## The supervisor, and what it inherits

One supervisor process per user hosts every background session, and it behaves more like a service than a shell job:

- It starts automatically on your first background dispatch and keeps one pre-warmed worker so the next dispatch is fast.
- It persists across auto-updates, restarting itself into the new version rather than dying.
- It stops idle, unpinned sessions after about an hour to free resources, and respawns a stopped process when you attach, peek or reply.
- It restarts crashed sessions with three safeguards: it does not override a stop you asked for, it respects stale input, and it tells you a restart happened.

> The supervisor inherits its environment from whichever shell first started it, which is the same structural fact that makes shell-exported proxy and certificate variables unreliable for background agents. It also means a gateway endpoint only reaches a background session under specific conditions — the supervisor must have been started from a gateway shell, and the session dispatched to that directory or backgrounded from it. Put anything that must apply universally in a settings file, not a shell profile.

## Worktrees are what make parallelism safe

This is the design decision that makes running four agents at once reasonable rather than reckless. Before touching files, a background session moves into its own git worktree, so two sessions working the same repository are not writing over each other. It is on by default and there is a setting to turn it off, which you should think about carefully before using.

> Deleting a session in agent view removes its worktree. If that session produced work you have not committed, it goes with it. The stop-and-delete key is two presses of the same chord, which is deliberate, but the habit worth building is committing from a background session's worktree before removing it — or using the remove command instead, which drops it from the list and keeps the transcript.

## Watching, attaching and detaching

The UI is a list of rows grouped by state, and the two keys worth learning first are peek and attach — peek shows the latest output or the question blocking a session without committing you to it, which is exactly what you want when scanning four rows to find the one that needs you.

| State | What it means |
| --- | --- |
| Needs input | Waiting on an approval, an answer or a permission — the only state that needs you now |
| Working | Actively processing; peek to see how far it has got |
| Idle | Ready for the next prompt. Unpinned, it will be stopped after about an hour |
| Completed or Failed | Finished. Failed means it ended with an error rather than being stopped |

## What survives being backgrounded

The carry-over list is more generous than you would guess: running shell commands, backgrounded subagents, dynamic workflows, scheduled loop tasks, added directories and most launch flags all come along. That means a session mid-workflow can be pushed to the background without losing the workflow.

Two things stop, and both for the same reason: they need a terminal. Running monitors stop, and any MCP server waiting on input stops — which includes commands that open a settings list or an install flow. If your session is doing something that needs you to answer in a picker, finish that first and background it afterwards.

> Pinning is the answer to the one-hour idle stop. A pinned session keeps its process running even while idle, which matters when the session holds expensive state you do not want rebuilt — a warmed cache, a long conversation, a loaded environment. Everything else is better left unpinned so the supervisor can reclaim it.

## The cost, stated plainly

Three limitations decide whether this fits your workflow, and the first one is arithmetic rather than opinion:

- Rate limits apply per account, not per session. Ten parallel sessions consume roughly ten times the quota, and there is no separate budget for background work.
- Sessions run on your machine and stop when it shuts down. This is local parallelism, not cloud parallelism — for work that must survive the machine going down, that is a cloud session or a routine.
- The transcript survives removal but the worktree does not, so anything uncommitted in a deleted session's worktree is gone.

## When background agents are the right tool

The pattern that has worked best for me is one investigation per independent question, dispatched and left alone. A flaky test, a documentation pass and a refactor are three things that do not need to talk to each other, and running them in parallel costs three times the tokens and roughly one third of the wall-clock time. That is a good trade when the tokens are cheaper than your attention.

It is a bad trade when the tasks are actually one task. Three sessions on the same subsystem will produce three overlapping and mutually inconsistent sets of edits in three worktrees, and merging them is worse than having done the work once. The worktrees stop them corrupting each other; they do not stop them disagreeing.

Hold the supervisor in mind and the rest of this feature stops surprising you: it is why sessions outlive your terminal, why environment variables have to live in settings rather than a shell, why a crashed session comes back, and why stopping the daemon is a real operation rather than closing a window. Dispatch things that are genuinely independent, pin only what holds expensive state, and commit before you delete — that is most of what you need.

## Sources & further reading

- Claude Code docs — Agent view and background sessions
- Claude Code docs — Run agents in parallel
- Claude Code docs — Git worktrees
- Claude Code docs — Apply network settings to background agents
- Claude Code docs — Settings reference (disableAgentView, worktree)
- Claude Code docs — Environment variables
- Claude Code docs — Cross-session messaging
- Claude Code docs — Manage costs

## Source links

- https://code.claude.com/docs/en/agent-view
- https://code.claude.com/docs/en/agents
- https://code.claude.com/docs/en/worktrees
- https://code.claude.com/docs/en/network-config
- https://code.claude.com/docs/en/settings-reference
- https://code.claude.com/docs/en/env-vars
- https://code.claude.com/docs/en/cross-session-messaging
- https://code.claude.com/docs/en/costs

## FAQ

### How do I run Claude Code sessions in the background?

Three ways: claude agents opens the management UI and dispatches from there, claude --bg with a prompt dispatches from any shell, and /bg or /fork moves or copies a live conversation into the background. Sessions persist even after you close agent view or your terminal, because a supervisor process hosts them rather than your shell.

### What is the Claude Code supervisor process?

A per-user process that hosts every background session. It starts automatically on your first background dispatch, keeps a pre-warmed worker for fast dispatch, persists across auto-updates by restarting into the new version, stops idle unpinned sessions after about an hour, and respawns stopped processes when you attach or reply.

### Do parallel Claude Code background sessions interfere with each other?

Not on files. Before editing, each background session moves into its own git worktree under .claude/worktrees/ so parallel sessions do not collide. Isolation is skipped when you are already in a linked worktree, outside a git repository, or writing outside the working directory, and it can be turned off with the worktree bgIsolation setting.

### Why do my proxy or certificate settings not reach background agents?

The supervisor inherits its environment from whichever shell first started it, and an OS-installed supervisor gets no shell environment at all. A variable exported only in your shell reaches background agents when that shell happened to cold-start the supervisor and silently does not otherwise. Put them in the env block of a settings file instead.

### How many parallel Claude Code background sessions can I afford?

Rate limits apply per account, so ten parallel sessions consume roughly ten times the quota — there is no separate budget for background work. The parallelism is also local: sessions run on your machine and stop when it shuts down. For work that must outlive the machine, use a cloud session or a routine.

---

- HTML version: https://www.matthewswong.com/en/blog/claude-code-agent-view-background-sessions/
- Bahasa Indonesia: https://www.matthewswong.com/id/blog/claude-code-agent-view-background-sessions/
- Site index for agents: https://www.matthewswong.com/llms.txt
- Sitemap: https://www.matthewswong.com/sitemap.xml
- API description (OpenAPI): https://www.matthewswong.com/openapi.json
