In Claude Code, what is the difference between `/background` and `/fork`, and where does each resulting background session edit files?
answer
- move the conversation versus copy it
- one frees the terminal, one keeps you here
- rows in claude agents
- the copy makes its own worktree
- the old /fork is now /subtask
basics
~20 sIn Claude Code 2.1.286, /background (alias /bg) moves this conversation into a background session that keeps editing in place; /fork copies it into a new background session told to use its own worktree, while you keep working.
solid answer
~50 s`/background`, alias `/bg`, detaches the session you are in: it keeps running under the background supervisor, your terminal is freed, and you monitor it from agent view with `claude agents` (a research preview). It goes on editing files where it already was; it does not move into a worktree. `/fork` copies the conversation so far into a **new** background session while the original stays in front of you; the copy carries the model, permission mode, effort and added directories or "don't ask again" grants, and unless it edits in place Claude Code instructs it to create a worktree of its own before changing code. Pass a prompt to either to give one more instruction. Since 2.1.212 `/fork` means this copy; on 2.1.161 to 2.1.211, or with agent view turned off, it starts a forked subagent, which is now `/subtask`.
go deeper
Remember that /background (or /bg) detaches this conversation and /fork copies it, and that claude agents shows both as rows.
Explain where each edits: a backgrounded session in place, a fork or dispatched session in its own worktree, and what the fork inherits.
Show you know the release history of /fork, the bgIsolation switch, the commit-and-push instructions for worktree sessions, and that deleting a row in agent view discards uncommitted work.
Treat background sessions as local, quota-sharing workers: decide how many to run, who reviews their branches and how unpushed work is protected before scaling up.
## Two ways to send work to the background A **background session** is a full Claude Code conversation that keeps running without a terminal attached. A local service called the **supervisor** hosts each one as its own process, and **agent view**, opened with `claude agents`, lists them as rows showing which are working, which need input and which are done. Agent view is a **research preview**, so its interface and shortcuts may still change. From inside an interactive session there are two commands that feed it: | | `/background` (alias `/bg`) | `/fork` | |---|---|---| | What moves | this conversation itself | a copy of this conversation | | Your terminal | freed; you are back at the shell or in agent view | stays in the original session | | Afterwards | one conversation, now in the background | two independent conversations | | Where edits go | in place, where the session was already working | its own worktree, unless it edits in place | | With a prompt | one more instruction before detaching | the copy starts on it immediately | ## `/background`: detach and keep going `/background` sends the current conversation to the background. If Claude is mid-response, the response continues there. In-flight work moves with it: background shell commands, backgrounded subagents and `/loop` tasks carry over, while work that cannot move, such as a running monitor, is stopped after a confirmation dialog. Exiting a session that still has background work running offers the same move as "Move to background and exit". A backgrounded session **keeps editing where it was**. Neither `/background` nor pressing `←` moves it into a worktree, and the `worktree.bgIsolation` setting does not change that. It also keeps its permission mode, so a session you switched to `acceptEdits` stays there. ## `/fork`: copy and carry on `/fork` starts a new background session from everything in the conversation so far. The copy inherits: - the **model**, **permission mode** and **effort level**; - directories added during the session and "don't ask again" permission grants; - for a session dispatched from agent view, the same agent definition and appended instructions. After the fork the two conversations are independent; nothing the copy does flows back into the original. Without a prompt the copy waits in agent view for its first instruction. Except when it edits in place, Claude Code instructs the copy to **create a worktree of its own** before changing code, so it does not trample the checkout you are still working in. A session launched with flags the copy would not inherit, such as a replaced system prompt or a `--tools` allowlist, cannot be forked; Claude Code refuses rather than making a partial copy. ## A renamed command: the release that matters The name changed meaning. From **2.1.212**, `/fork` copies the session into a background session. On 2.1.161 through 2.1.211 it spawned a **forked subagent**, which inherits the conversation and reports back into it; that behaviour is now `/subtask`. When agent view is turned off (`disableAgentView` or `CLAUDE_CODE_DISABLE_AGENT_VIEW`), `/fork` keeps the forked-subagent behaviour and `/subtask` is unavailable. Someone who learned the old meaning expects a result in the current conversation and gets a separate session instead. ## Where dispatched sessions edit Sessions you start from agent view's input or with `claude --bg "<prompt>"` are different from a backgrounded one: they start in your working directory, and before editing Claude moves them into an isolated worktree under `.claude/worktrees/`, with the same isolation checks as a `--worktree` session. Set `worktree.bgIsolation` to `"none"` for a repository where worktrees are impractical. When such a session has made changes in its worktree, Claude is instructed to preserve them: commit, push when there is a remote, open a draft pull request when the task calls for it, and never push to `main` or `master`, force-push or merge, unless your own instructions say you handle git. ## Operating notes 1. Background sessions run **on your machine**: they survive sleep but stop when it shuts down. 2. Each one consumes subscription usage like an interactive session, so ten in parallel burn quota roughly ten times as fast. 3. A finished session left unattached for about an hour has its process stopped; the conversation stays on disk and resumes when you attach or reply. 4. Deleting a row in agent view usually removes the worktree Claude created for it, uncommitted changes included, so commit first; unpushed commits or a lock held by another session make Claude Code keep it instead. 5. To see where a dispatched session is editing, peek its row or attach and check its working directory.
- You backgrounded a session with `/bg` and then started two more from `claude agents`. Which of the three are isolated in worktrees?Only the two you dispatched. Sessions started from agent view or with `claude --bg` move into their own worktree under `.claude/worktrees/` before editing. The session you moved with `/bg` keeps editing the checkout it was already in, whatever `worktree.bgIsolation` says.
- A colleague runs `/fork` expecting the result to come back into their conversation. What do you tell them?That was `/fork` on 2.1.161 to 2.1.211, or with agent view turned off. Since 2.1.212 it makes an independent background session whose work never flows back on its own; for a side task whose result returns into the conversation, use `/subtask`.
- /background moves the session into a new worktree before it continues.
- /fork returns the copy's result into the current conversation when it finishes.
- Background sessions run in the cloud, so they keep going after the laptop shuts down.
- Deleting a session in agent view keeps its worktree's uncommitted changes safe.
- Background sessions do not count against subscription usage.
Assumes Claude Code 2.1.286: /fork copies the session into a background session since 2.1.212; on 2.1.161 to 2.1.211 it spawned a forked subagent, now /subtask.