In Claude Code, Claude started a dev server that holds the turn open: what does Ctrl+B do, and what happens to that process afterwards?
answer
- the turn stops waiting
- task ID and an output file
- tmux eats the first press
- /tasks to list and stop
- cleaned up when Claude Code exits
basics
~20 sCtrl+B moves the running Bash command or agent to the background: it keeps running with a task ID, output goes to a file Claude can read, /tasks lists it, and it stops when Claude Code exits.
solid answer
~40 s`Ctrl+B` (the `task:background` action) moves the running Bash command or agent to the background, so the turn stops waiting and Claude can take new prompts. The process keeps running under a background task ID, its output is written to a file Claude reads with its Read tool, and `/tasks` (alias `/bashes`) lists and stops it. Background tasks are cleaned up automatically when Claude Code exits. Inside tmux, press `Ctrl+B` twice or use `Ctrl+X Ctrl+B`, because `Ctrl+B` is tmux's prefix. A foreground command that reaches its timeout is also moved to the background automatically, unless it starts with `sleep` or background tasks are disabled with `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1`.
go deeper
Recall that Ctrl+B sends a long-running command to the background so you and Claude can keep working, and that /tasks shows what is running.
Explain the mechanics: a task ID, output written to a file Claude reads, automatic backgrounding at timeout, cleanup at exit, and the tmux double press or Ctrl+X Ctrl+B.
Show operational judgement: check /tasks before leaving, stop what you no longer need, and never count on a backgrounded process outliving the Claude Code session.
Distinguish backgrounding one command from detaching a whole session, and decide when a team should disable background tasks entirely for predictability.
## The problem Ctrl+B solves When Claude Code runs a **Bash tool** call in the foreground, the turn waits for it. That is fine for `git diff`, and useless for a dev server, a file watcher or a twenty-minute test suite: the command never "finishes", so Claude cannot do anything else, and you cannot get its attention without interrupting. `Ctrl+B` is the `task:background` action, active in the **`Task` context** (a task is running in the foreground). Pressing it **moves the running Bash command, or a running agent, to the background**. The command keeps executing; Claude Code returns a **background task ID** right away, and Claude can respond to new prompts while it runs. ## What happens to a backgrounded command - **Output goes to a file.** Claude retrieves it with its Read tool, so it can check the dev server's log or the test results later in the conversation. - **It has a unique ID** for tracking and retrieving output. - **`/tasks`** (also available as `/bashes`) lists and manages the session's background work, including subagents that have finished, and lets you stop a task. - **It ends with Claude Code.** Background tasks are cleaned up automatically when Claude Code exits; on macOS and Linux, processes that detached from the task's shell (for example under `setsid` or `timeout`) are stopped too. - **Very large output is cut off:** a task whose output exceeds 5GB is terminated with a note in stderr. - **Subagent scope:** a background command started by a foreground subagent ends when that subagent's run ends. ## The tmux trap `Ctrl+B` is tmux's default **prefix key**, so inside tmux the first press goes to tmux. Press it **twice** to send it through, or use the chord `Ctrl+X Ctrl+B`, which is bound to the same action precisely to avoid that conflict. ## Backgrounding without the key Not every long command needs you at the keyboard: 1. You can simply **ask** Claude to run a command in the background. 2. A foreground command that reaches its **timeout** is moved to the background automatically instead of being stopped, unless it starts with `sleep`. The result says so and gives the task ID and output file. 3. Setting `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1`, or starting in bare mode, turns all of this off: there is no backgrounding, and a command that hits its timeout stops. The same `Ctrl+B` works for a long command **you** started with the `!` shell-mode prefix. ## Similar-looking keys and commands | Input | What it does | Not to be confused with | | :- | :- | :- | | `Ctrl+B` | Background the running Bash command or agent | Detaching the whole session | | `/tasks` | List and stop background shells and subagents | `Ctrl+T`, Claude's to-do checklist | | `Ctrl+T` | Show or hide Claude's task checklist | The background-task view | | `Ctrl+X Ctrl+K` | Stop all running background subagents (press twice to confirm) | Stopping one shell | | `Ctrl+Z` | Suspend Claude Code itself to your shell (Unix) | Backgrounding a command inside Claude Code | Detaching an **entire session** so it keeps working after you leave the terminal is a different feature (`/background` and agent view), handled with parallel work; `Ctrl+B` moves one command, inside a session that is still yours. ## Practical guidance - Start dev servers and watchers, then `Ctrl+B` them, and keep working with Claude in the same session. - Use `/tasks` before you leave to see what is still running, and stop what you no longer need. - Do not rely on a backgrounded process outliving Claude Code: when you exit, it stops.
- A command Claude started hits its timeout. Is it killed?Normally no: Claude Code moves a foreground command that reaches its timeout to the background instead of stopping it, and the result reports the task ID and the output file. It stops instead if the command starts with `sleep`, or if background tasks are off through `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1` or bare mode.
- Does pressing Ctrl+T show the commands you backgrounded?No. `Ctrl+T` toggles Claude's to-do checklist, the task list it writes to plan multi-step work. Running shells and subagents are in `/tasks`, which also lets you stop them.
Ctrl+B moves a simmering pot to the back burner: it keeps cooking, you can lift the lid (the output file) whenever you like, and you can cook something else meanwhile, but the stove goes off when you leave the kitchen.
- Ctrl+B detaches the whole session so you can close the terminal.
- A backgrounded dev server keeps running after you exit Claude Code.
- Once a command is backgrounded, Claude can no longer see its output.
- Inside tmux, a single Ctrl+B press backgrounds Claude's command.
- Ctrl+T is the view that lists background shells.