Claude Code See Background Tasks: View, Check, Kill Jobs
Key takeaways
- Press Ctrl+B or run /tasks in Claude Code to list every running background task with its ID, command, and status.
- Background tasks stream output to a file, so you can reattach with BashOutput or tail -f and read the full transcript after completion.
- Ctrl+C only kills the foreground command; stop a background task via /tasks or by asking Claude to kill it by task ID.
- Background tasks die with their session, so check /tasks before exiting and hunt orphans with ps aux or lsof afterward.
- If a task ignores stop commands, kill the parent launcher first, then escalate to kill -9 or taskkill /F on Windows.
To see background tasks in Claude Code, press Ctrl+B (or run /tasks) to list everything running, check a specific task's output with its task ID, and kill it with /tasks then selecting stop. This guide walks through the full lifecycle: spawning, monitoring, terminating, and what to do when a task refuses to die.
How do I see running background tasks in Claude Code?
Claude Code keeps every background task in a single registry, and the /tasks command is the fastest way to see it. Type /tasks in the prompt and you get a live list of everything running: bash commands launched with run_in_background, dev servers, watchers, and long builds. The Anthropic Claude Code documentation covers the bash tool's background behaviour, including how task output is retrieved and stopped.
The /tasks view
The /tasks view shows each task with an ID, the command line, its current state, and how long it has been running. From here you can jump to a specific task's output or terminate it without leaving the session. If you launch a command and keep working, a notification appears when it finishes so you don't have to poll.
Reading the task list output
Each entry maps to a task ID you reuse in follow-up commands like TaskOutput or TaskStop. States matter: running means still active, completed means output is buffered and readable. When you're steering multiple agents across projects, this list is also the quickest sanity check before handing a card to the next agent, and it pairs well with a board that tracks what each agent claims (we use this pattern on KanbanMCP).
How do I check the status or output of a specific background task?
Listing tasks tells you what's running. Inspecting one tells you whether it's actually doing what you asked.
Checking output while it runs
Every background task streams its output to a file instead of the terminal, so you never lose a line. When Claude Code spawns a task it reports the shell ID and the output path; Ctrl+B while the task is in the foreground detaches it and returns you to the prompt, and the stream keeps writing in the background. To reattach or tail it, use BashOutput with the task's ID (or read the output file directly with tail -f) to see the latest lines and the current status: running, completed, or failed. If an agent seems stuck, the streamed output is how you tell "still compiling" from "no idea what it's actually doing" before you decide to kill it. This matters more when several agents share one project, because each one leaves a trail the next can pick up; that is the same principle behind a shared board like KanbanMCP, where a card carries the working notes forward instead of burying them in a disposable chat session.
Reading output after the task finishes
Once a task exits, its output stays in the buffer and BashOutput returns the full transcript plus the exit status, so you can retrieve results long after completion. Claude Code's own agent will often read this automatically when a later step depends on the result. If you closed the session or the buffer is gone, fall back to the output file path you noted at spawn time.
How do I kill or stop a background task in Claude Code?
You stop a background task with the kill command in the REPL, or by selecting it from the task list. The task's process is terminated immediately; anything it was writing mid-run may be left half-done, so check the output before moving on.
Stopping a task by ID
Every background task gets an ID when it spawns. To stop one, ask Claude directly: "kill background task b2f3". Claude runs the kill against that task's process and confirms when it's gone. If you're not sure of the ID, ask Claude to list running background tasks first, then kill by name.
Stopping from the task list
Press Ctrl+B twice to open the background task list, which shows every running task with its ID, command, and status. From there you can select a task and kill it without typing a command. The Anthropic Claude Code interactive mode docs cover the full shortcut set for the task list UI.
One gap worth knowing: killing a task kills the process, but nothing records why it died or what it left half-finished. If the next agent picks up that card, it inherits a mess with no note. That's the problem we built Muse Code around — a killed task leaves a handoff note on the card, not just a dead PID.
How do background tasks differ from foreground bash commands in Claude Code?
A foreground bash command blocks the session: Claude runs it, waits for it to finish, reads the full output, and reasons over it before doing anything else. A background task runs non-blocking, so Claude can keep working while the task churns, but it only sees the output when it explicitly checks the task's status.
| Foreground bash | Background task | |
|---|---|---|
| Blocking | Yes, session waits | No, session continues |
| Output | Returned in full automatically | Fetched on demand via task ID |
| Claude can act on it | Immediately, in the same turn | Only when it polls or the task completes |
| Killable | By timeout or interruption | Via an explicit kill command |
The practical difference: foreground output is guaranteed to reach the model, background output is not. If you spawn a dev server or a long build in the background and never check its task ID, that output effectively vanishes. This matters most when you run several agents in parallel, where one agent's background task is invisible to another working the same repo. We cover cross-agent task handoff in the guide to Qwen Code.
What happens to background tasks when a Claude Code session ends?
Background tasks are tied to the session that spawned them. When you exit Claude Code, the shell processes behind those tasks are orphaned: they may keep running under your OS, but Claude Code no longer tracks them, and their output is gone. Anthropic's docs on background tasks note that session state does not persist across sessions (Claude Code docs). So a task that survives exit is a process you own but cannot see from the CLI.
Orphaned processes and how to spot them
Before quitting a session, check /tasks and kill anything you don't want running headless. After exit, spot orphans the normal way: ps aux | grep <command> or lsof -i :<port> for dev servers, then kill <pid>. This is exactly the "system of record vs working memory" split: the session is working memory, so anything you need later has to live outside it.
That is the gap KanbanMCP fills. A card on KanbanMCP for Claude Desktop records what an agent claimed and what it left behind, so the next session picks up state the process can't carry. Where it falls short: it tracks work, not live processes, so a runaway orphan still needs kill.
Why won't my background task terminate, and how do I force-kill it?
Task ignores the stop command
A task usually ignores the stop command for one of three reasons: it spawned child processes that the stop signal never reached, it's blocked in a state where it can't handle signals, or the shell command you launched wrapped the real process so the PID Claude Code tracks isn't the one doing the work. Check the task output first. If you see a server or watcher still printing after a stop attempt, you're dealing with a process group, not a single process.
Escalating to an OS-level kill
When the in-app stop fails, kill the process directly. Find the PID with lsof -i :PORT for servers or ps aux | grep <command> for anything else, then run kill <PID>. If it survives a plain SIGTERM, escalate with kill -9 <PID>. On macOS and Linux, pkill -f <pattern> wipes the whole matching set in one shot. On Windows, use taskkill /F /PID <PID>.
Grep-style processes that respawn
Some supervisors restart their children automatically, so killing the child leaves the parent to spawn a fresh one. Kill the parent first: ps -o ppid= -p <PID> gives you the parent, then kill -9 that. If a task keeps respawning after every kill, the launcher itself is still running as a separate background task, so stop that one too before retrying.
What's the safest workflow for running, monitoring, and cleaning up background tasks?
The full sequence
Spawn with purpose: only background long-running commands like dev servers, watchers, or test suites. Note the shell ID Claude returns, then check output with BashOutput before assuming anything about state.
Kill in escalating order. First send a normal terminate request; if the process ignores it, escalate to SIGKILL, which the kernel cannot be asked politely to defer, per the POSIX/Linux kill signal reference. After a kill, run ps aux | grep <pattern> to confirm nothing orphaned survived, since detached children don't always die with their parent.
Reconciling finished tasks with your task tracker
When a task finishes, close the loop in your system of record the same session: move the card, paste the final output or a one-line note, and let the chat session stay disposable. If an agent died mid-task, write what it was doing onto the card before killing anything, so the next agent picks up state instead of repeating work.
How do you keep background task state across multiple agents and sessions?
A background task in Claude Code dies with its session. If the only record of what an agent did lives in that chat, you're back to scrolling hundreds of cli and app chats to recover the context of the project a week later. Treat the session as disposable working memory and keep the system of record somewhere both you and every agent can reach.
What belongs in the session vs the system of record
The session keeps raw output, intermediate commands, and the task process itself. The system of record keeps the card: what was asked, what the agent did, what's still blocked, and the note for whoever picks it up next. Tasks live in one place, chat stays disposable.
That's the gap KanbanMCP fills. An agent claims a card over MCP, does the work, and leaves a note on the board before the session ends. The next agent, in a fresh session, reads the card instead of repeating finished work. You watch and steer from the same board.
Where it falls short: it doesn't capture the session's raw transcript, so if a note is thin, the working memory is gone. The note has to be good enough on its own.
FAQ
Can I run multiple background tasks at the same time in Claude Code?
Yes. Each command launched with run_in_background gets its own task ID and output stream, and /tasks lists all of them in one registry: dev servers, watchers, and builds can churn simultaneously while Claude keeps working. The tradeoff is that each task's output is only fetched on demand, so poll each ID or you'll miss results.
Does Ctrl+C kill a background task or only the foreground command?
Ctrl+C interrupts the foreground command, the one currently blocking your session. A background task isn't attached to the terminal, so Ctrl+C doesn't reach it. To stop one, use the task list via /tasks and select stop, or ask Claude to kill it by task ID. Ctrl+B detaches a foreground task to the background rather than killing it.
Can Claude Code restart a background task automatically if it crashes?
No. Claude Code tracks the task but has no built-in supervisor that respawns a crashed process. If a task exits or fails, you or Claude must relaunch it explicitly. Some shell commands bring their own supervisor that restarts children automatically, which is a different problem: killing the respawned child is pointless until you kill the parent launcher first.
How do I find a background task's process ID so I can kill it outside Claude Code?
Claude Code tracks tasks by its own task ID, not always the PID doing the work, so match on the command instead. Run ps aux | grep <command> for general processes, or lsof -i :<port> for a dev server holding a port. Then kill <PID>, escalating to kill -9 if a plain SIGTERM is ignored. On Windows, use taskkill /F /PID.