Skip to content

Agents and automation

This chapter documents the agent/task automation layer: custom agents, background-by-default subagents, worktree isolation, cross-agent messaging, experimental Agent Teams and observer agents, background sessions, deterministic dynamic workflows, task tools, lifecycle hooks, slash-command automation, ultrareview, and auto-mode.

Read this chapter when the question is: how does Claude Code delegate work, run subagents, or automate runtime behavior?

Source-anchor policy

This page is a chapter guide. Linked implementation pages carry concrete cli.renamed.js anchors.

Semantic aliasMinified anchorScope
Agents/automation chapterN/A — navigation pageGroups custom agents, background agents, task tools, subagent hooks, slash commands, and automation commands.
Agent implementation pagesSee linked source-anchor tablesConcrete bundle anchors live in destination pages.

Automation map

flowchart TD
Root[Root command] --> AgentsCmd[agents command]
Root --> AgentsFlag[--agents JSON]
Runtime[Session runtime] --> TaskTools[TaskCreate / TaskGet / TaskList / TaskUpdate]
Runtime --> Slash[slash commands]
Runtime --> Hooks[Subagent and task hooks]
AgentsFlag --> Custom[Custom agents]
AgentsCmd --> Background[Background agents]
TaskTools --> Subagents[Subagents / tasks]
Subagents --> Messages[SendMessage routing and receive queues]
Runtime --> Teams[Experimental Agent Teams]
Messages --> Teams
Teams --> Teammates[In-process / tmux / iTerm2 teammates]
Slash --> Automation[command automation]
Runtime --> Workflow[Workflow tool]
Workflow --> Orchestration[deterministic multi-agent orchestration]

Primary reading order

The similarly named execution surfaces are intentionally distinct:

NeedCanonical owner
Define, select, launch, model, and concurrency-limit ordinary AgentsAgents, tasks, and subagents
Address a recipient and understand message transport/acknowledgement/replyAgent messaging and communication
Insert, interrupt, cancel, stop, notify, and evict workAgent steering, interruption, and completion
Coordinate named teammates through roster/mailbox/shared-task filesAgent Teams
Run deterministic JavaScript-controlled fan-out nowDynamic workflows
Inject prompts later or repeatedlyCron and scheduled tasks
OrderPageAutomation question answered
1Agents, tasks, and subagentsWhich built-in/native agent roles exist, what are they for, and how does Agent resolve its model, run concurrency-safe calls in parallel, choose foreground/background/isolation, and coexist with task tools and hooks?
2Worktree isolation and handoffsHow do session-wide EnterWorktree/ExitWorktree, per-Agent isolation, background edit guards, hooks/Git backends, locks, persistence, resume, and safe cleanup compose?
3Agent messaging and communicationHow does SendMessage resolve a recipient and route through an Agent queue, team mailbox, main queue, local socket, or cloud API; when does the receiver see it; and how do acknowledgement, reply, and completion differ?
4Agent TeamsHow does the gated implicit team spawn named teammates, choose in-process/tmux/iTerm2 backends, coordinate through locked roster/task/inbox files, forward permissions, stop, clean up, and narrowly resume evicted workers?
5Observer agentsHow do agent declarations auto-spawn read-only observers, persist pairings, deliver digests, and route one-way ObserverReport messages?
6Agent steering, interruption, and completionHow do now/next/later insertion, Agent steering, TUI/SDK interruption, queued/control cancellation, stop markers, notification, and terminal-state eviction differ?
7Dynamic workflowsHow does Workflow schedule parallel/pipeline agents through a FIFO concurrency limiter with shared model, effort, budget, abort, progress, and journal state?
8Slash commands and automationHow are core, bundled, plugin, workflow, filesystem, and MCP commands assembled and filtered; how do /btw, /goal, /autofix-pr, and /ultraplan isolate, resume, or hand off work; and which bundled workflow families have independent control flow?
9Cron and scheduled tasksHow do /loop, cron tools, wakeups, persistence, and missed-task handling inject later work?
10Agent and automation architectureHow are custom agents, teams, tasks, workflows, slash commands, auto-mode, and hosted review orchestrated over the same runtime?

Handoffs

Created and maintained by Yingting Huang.