Skip to main content

Task Management

How Claude Code manages background work — task types, lifecycle, persistence, and notifications.

Live Task Board

Watch how tasks progress through their lifecycle. Background tasks run independently while the main agent continues working:

Background Tasks0 running, 0 done
npm test
Run test suite in watch mode
bashpending
Explore("Find API endpoints")
Research task running in parallel
agentpending
lint --fix
Auto-fix lint errors
bashpending

Task Types

Claude Code supports 7 task types, covering shell commands, agent work, remote execution, and more:

User-Facing
local_bash
local_agent
local_workflow
Infrastructure
remote_agent
in_process_teammate
monitor_mcp
dream
TypeWhat It DoesExample
local_bashRun a shell command in the backgroundnpm test running while you continue working
local_agentSpawn a sub-agent that works independentlyResearch task running in parallel
remote_agentExecute on a remote Claude Code RunnerCloud-based execution
in_process_teammateAn in-memory agent (coordinator/swarm)Multi-agent collaboration
local_workflowRun a predefined workflowScripted task sequences
monitor_mcpWatch an MCP serverEvent monitoring
dreamBackground speculative workMemory tidying

Workflow Tasks (local_workflow)

Workflow execution is not just a command-registry concern. The task system also models it as its own background task type:

SourceWhat It Shows
src/Task.tslocal_workflow is a first-class task type
src/tasks/pillLabel.tsWorkflow runs get their own pill labels: 1 background workflow / background workflows
src/commands.ts + src/tools.tsWorkflow commands and the WorkflowTool are both feature-gated integration points

That split matters architecturally: workflow scripts can surface as slash commands, but once started they are tracked by the same task board and notification system as other background work.

Recovered surface

The workflow implementation itself is only partially recovered in this source dump, so this page stops at the task-system integration points that are directly visible in source.

Task Lifecycle

📋
TaskCreate
pending
⚙️
running
completed
failed
killed (TaskStop / timeout)

Task Creation

src/tools/TaskCreateTool/TaskCreateTool.ts
TaskCreate({
subject: 'Run tests in watch mode',
description: 'Execute npm test with --watch flag',
activeForm: 'running tests', // spinner text
metadata: { command: 'npm test -- --watch' },
})
// Returns: task_id for tracking

Task Notifications

When a background task completes, a notification is injected into the conversation. The model sees it and can report results or take follow-up actions:

<task-notification>
<task-id>abc123</task-id>
<status>completed</status>
<summary>Background command "npm test" completed (exit code 0)</summary>
</task-notification>

Persistence

Tasks persist to disk at ~/.claude/tasks/:

FileContents
{task-id}.jsonMetadata: ID, type, status, timestamps, command/prompt
{task-id}.outputOutput streamed to file as produced (stdout/stderr)

Task Management Tools

ToolPurpose
TaskCreateCreate a new background task
TaskUpdateUpdate task status or details
TaskListList all active tasks
TaskGetGet details of a specific task
TaskOutputRetrieve output (blocking or non-blocking)
TaskStopStop a running task
TodoWriteManage the session task checklist

Framework Comparison

Background task management is handled very differently across frameworks. Claude Code has the most comprehensive built-in task system:

src/tools/TaskCreateTool/TaskCreateTool.ts
// 7 task types, disk persistence, notifications
TaskCreate({
subject: 'Run tests',
description: 'npm test -- --watch',
})
// → task_id returned immediately
// → output streamed to ~/.claude/tasks/{id}.output
// → <task-notification> injected on completion
// → TaskOutput(task_id) to retrieve results

// Also: TodoWrite for session checklists
TodoWrite({ todos: [
{ status: 'completed', content: 'Fix auth bug' },
{ status: 'in_progress', content: 'Write tests' },
]})

7 task types with disk persistence, streaming output, completion notifications, and a separate todo/checklist system. Tasks survive conversation restarts.

Comparison Matrix

FeatureClaude CodeGoogle ADKOpenAI AgentsLangGraph
Background shell commandslocal_bashNoneNoneNone
Background agentslocal_agentis_long_runningasyncio.TaskSubgraph nodes
Task types71 (long-running)NoneNone
Disk persistenceJSON + output filesNoneRunState serializationCheckpointer backends
Completion notifications<task-notification>A2A eventsQueue sentinelsInterrupt/resume
Cross-session survivalYes (disk)NoNoYes (checkpointer)
Task listing/management6 tools (CRUD + output)NoneNoneCheckpoint history
Interruption modelTaskStop + timeoutinput_required statecancel() methodinterrupt() + Command
Session checklistTodoWriteNoneNoneNone
Remote executionremote_agent (CCR)NoneNoneLangGraph Cloud
Key difference

Claude Code is the only framework with a dedicated background task system that supports multiple task types, disk persistence, streaming output, and completion notifications injected into conversation context. Other frameworks handle concurrency within a single run (asyncio tasks) or persist state at the graph level (checkpointing), but none offer a general-purpose task queue that the model can create, monitor, and retrieve results from.

Key Source Files

FilePurpose
src/Task.tsTask type definitions
src/tasks/Task implementations (8 types)
src/tasks/pillLabel.tsUser-facing labels for task types, including local_workflow
src/tools/TaskCreateTool/Task creation
src/tools/TaskOutputTool/Output retrieval
src/tools/TodoWriteTool/Session checklist