Tasks System Architecture
Overview
The Tasks System manages background work in Claude Code. When you run a long command or spawn a sub-agent, it runs as a task - isolated, trackable, and controllable.
┌─────────────────────────────────────────────────────────────────────────────┐
│ TASKS SYSTEM │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ TASK LIFECYCLE │ │
│ │ │ │
│ │ PENDING ──► RUNNING ──► COMPLETED/FAILED/KILLED │ │
│ │ │ │ │ │ │
│ │ │ ▼ ▼ │ │
│ │ │ Output File Terminal │ │
│ │ │ (on disk) State │ │
│ │ │ │ │
│ │ ▼ │ │
│ │ Can be killed │ │
│ │ at any time │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ TASK TYPES │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ LocalShell │ │ LocalAgent │ │ RemoteAgent│ │ Dream │ │ │
│ │ │ Task │ │ Task │ │ Task │ │ Task │ │ │
│ │ │ (bash) │ │ (sub-agent)│ │ (remote) │ │ (compact) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘