# Background Session Commands

> How to send work to the background and keep your terminal. /background, /fork, /subtask and /stop in a session, and claude attach, logs, rm and daemon outside.

**Course:** [Claude Code Commands](https://learn.benibix.com/learn/ai-claude-code-commands)  
**Time:** 13 min

**After this lesson you can:**

- Pick /background, /fork or /subtask
- Open and stop a background session from the shell
- Restart every session after an update

## How to run a session in the background and manage it

A background session keeps working with no terminal open. One supervisor process runs them all. /background, or /bg, moves the chat you are in there and frees your terminal. claude --bg starts a new one from the shell and hands your prompt back at once. You watch them all in agent view, which claude agents opens.

Three commands send work out of a session, and they differ in what stays. /background moves the whole chat. /fork copies it to a new background session, and you keep working here. The copy gets your model, mode and effort. It is told to use its own worktree before it edits code.

/subtask hands one task to a subagent that inherits the whole chat. It works in the background while you keep going. When it is done, its result comes back into this chat. A /fork copy never reports back on its own. /subtask is only there when agent view is on.

/tasks lists the background work inside this one session: shell commands left running, and subagents, finished ones too. Open one to read its output or stop it. It is not Claude's to-do list, which Ctrl+T shows. /bashes is another name for it.

From the shell, claude attach opens a background session in your terminal, by ID or name. Press the left arrow on an empty prompt, or run /exit, to leave it running. /stop is the way to end it from inside. claude logs prints its recent output without opening it at all.

claude respawn starts a session again and keeps its chat, whether it was running or stopped. Add --all to restart every running one, so they all move to a new version after an update. claude rm takes a session off the list, and its chat stays on disk for claude --resume. It refuses while the worktree holds changes you have not committed.

claude daemon looks after the supervisor itself. claude daemon status prints its state and how many sessions it holds, and ends with code 1 if it is not running. claude daemon logs follows its log file. claude daemon stop --any shuts it down, and --keep-workers leaves the sessions running for the next one.

## Which one to pick

1. **/background.** Pick it when you are done watching and want your terminal back. The whole chat goes with it.
2. **/fork.** Pick it when you want to try something on the side and keep working here. The copy does not report back.
3. **/subtask.** Pick it when a side task should bring its answer back into this chat when it is done.

```bash
claude --bg "investigate the flaky test"
claude attach 7c5dcf5d
claude logs 7c5dcf5d
claude respawn --all
claude daemon status
```
Start a session in the background, open it and read its output. Then restart them all, and check the one process that runs them.

![One supervisor, run by claude daemon, holds three background sessions: fix bug, write tests and review. Four commands each point at one session: claude attach opens it here, claude logs reads its output, claude respawn starts a fresh process, and claude rm takes it off the list.](https://learn.benibix.com/diagrams/cli-daemon.svg)

### Example: Jack starts three jobs before a meeting

Before a 1 hour meeting, Jack starts 3 sessions with claude --bg: fix a bug, write tests, and review a branch.

Afterwards, claude logs shows two done and one waiting on a question. He runs claude attach on that one, answers it, and presses the left arrow to leave it running.

**Words in this lesson:** [Subagent](https://learn.benibix.com/term/ai/subagent), [/background Command](https://learn.benibix.com/term/ai/background-command), [--bg Flag](https://learn.benibix.com/term/ai/bg-flag), [/fork Command](https://learn.benibix.com/term/ai/fork-command), [/subtask Command](https://learn.benibix.com/term/ai/subtask-command), [/tasks Command](https://learn.benibix.com/term/ai/tasks-command), [claude attach Command](https://learn.benibix.com/term/ai/claude-attach-command), [/stop Command](https://learn.benibix.com/term/ai/stop-command), [claude logs Command](https://learn.benibix.com/term/ai/claude-logs-command), [claude respawn Command](https://learn.benibix.com/term/ai/claude-respawn-command), [claude rm Command](https://learn.benibix.com/term/ai/claude-rm-command), [claude daemon Command](https://learn.benibix.com/term/ai/claude-daemon-command)

> **Which chat keeps going.** /background moves this chat away. /fork copies it and never reports back. /subtask sends a helper whose answer comes back here.

**Question:** You want a helper to take a side task and bring its answer back into this chat. Which command fits?

**Answer:** /subtask. /subtask starts a subagent with the whole chat, and its result comes back here when it is done. A /fork copy works on its own and never reports back.

---

Source: https://learn.benibix.com/learn/ai-claude-code-commands/background-session-commands
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
