How each harness starts and configures subagents, what they can see and change, which lifecycle hooks run, and how their transcripts are saved and read.
Worktrees: creation, setup, integration and cleanup
Starting one
| Question | Claude Codechecked at 2.1.299 |
|---|---|
| Is there one, and how does it start | Yes. Claude delegates on its own when a task matches a subagent's Add a phrase like "use proactively" to a description to encourage automatic delegation. |
| Built-in subagents |
Explore and Plan skip your CLAUDE.md files and git status, and can't be resumed. Turn off Explore and Plan with |
| Define your own | Write a Markdown file with YAML frontmatter ( Both folders are scanned recursively, and the nested A plugin agent is addressed by its scoped name, such as |
| What a definition can set | Frontmatter can set Plugin agents ignore Claude Code silently ignores a misspelled field; |
While it runs
| Question | Claude Codechecked at 2.1.299 |
|---|---|
| What it sees, and what comes back | A subagent doesn't see your conversation. It starts with its own system prompt, the task message Claude writes, your CLAUDE.md files, a git status snapshot and any skills listed in Explore, Plan and agents with Your output style and auto memory don't reach a non-fork subagent. 2.1.307 improves parallel fork-subagent self-identification; 2.1.305 fixes reporting the model after a subagent fallback. Neither release establishes a new delegation protocol. |
| Several at once | Yes. Claude can run several subagents at once, for example when you ask it to research modules in parallel. By default a session allows 20 at a time, and the next spawn fails with Every result comes back into the main context, so many detailed reports can use a lot of it. |
| Keep working while it runs | Yes. In interactive sessions subagents run in the background by default while you keep talking, and you can press Background subagents get a smaller set of built-in tools than foreground ones. With 2.1.302 published changes: desktop and VS Code always run the main conversation's subagents in the background, as the terminal does. A subagent's own Agent calls default to foreground in -p, Agent SDK, desktop and VS Code. |
| Your checkout or its own copy | By default a subagent works directly in your checkout, starting in the main conversation's working directory. With A worktree subagent can't edit files in your main checkout or point git at it. Kept worktrees are swept after |
| Its permissions | A subagent inherits your permission rules and permission mode. A definition can set Permission prompts from background subagents appear in your main session, labeled with the subagent's name. Press Esc to deny one tool call without stopping the subagent. Use 2.1.309 fixes split-pane teammates not inheriting leader CLI tool denies and --tools restrictions. Teammates and ordinary subagents remain distinct surfaces; publisher report, not a runtime permissions probe. |
| Subagents of subagents | Yes. Subagents can spawn their own subagents, up to three layers below the main conversation by default. At the limit the A fork can't spawn another fork, and agent-team teammates can't spawn teammates. |
Watching and handing off
| Question | Claude Codechecked at 2.1.299 |
|---|---|
| Watch, steer or stop one | Running subagents appear in a panel below the prompt. Use Subagent transcripts are saved to
|
| Hand work to a cloud agent | Yes, as a separate cloud session rather than a subagent. The CLI can't push an existing terminal session to the cloud; the Desktop app can, from its Open in menu. Requires a claude.ai account; cloud sessions aren't available through Bedrock, Google Cloud or Foundry.
|
Notes and sources
Claude Code, 9 sources
- Background subagents use a reduced built-in tool set and surface permission prompts in the main session.
- isolation: worktree creates an isolated checkout from the default branch, not necessarily the parent's HEAD.
- Managed settings, session-only --agents JSON, and plugin-provided agents are documented sources that are not represented by the current user/project location vocabulary.
- A remote isolation value appears in the Agent tool schema, but no first-party documentation establishes subagent cloud handoff, so cloudHandoff remains unknown.
- 2.1.304 fixes plugins extending headless runs past --max-turns, Stop or ended input by spawning/resuming subagents, and subagents forgetting recent work when messaged/resumed immediately after completion.
- 2.1.304 fixes agent-team shutdown approval from the main session exiting the entire CLI. VS Code background subagents now display a single status line; the full transcript stays in /tasks.
- 2.1.311 publisher fixes access to MCP tools whose servers connect after a subagent starts, isolated-worktree cleanup while nested background work remains, and duplicate execution of finished subagent skills after a cloud/background restart. Ordinary subagents, teams and hosted sessions retain separate scopes.
- 2.1.312 publisher notes: frontmatter
autoCompactWindowcan lower the window set byCLAUDE_CODE_AUTO_COMPACT_WINDOW, never raise it. Prompt and agent hooks now share a per-session concurrency limit that includes subagents. - Publisher updates: 2.1.316 adds CLAUDE_CODE_SUBAGENT_EFFORT fallback; 2.1.317 uses a different subagent/teammate model's saved/default effort rather than main-session effort, and SendMessage can background a running shell without stopping it. 2.1.318 backgrounds background-subagent shell commands after 3 minutes on all providers. 2.1.319 /tasks can reopen finished subagents after restart. No delegation probe.
Is there one, and how does it start, 2
Define your own, 1
What a definition can set, 1
Several at once, 1
Your checkout or its own copy, 2
Subagents of subagents, 1
Watch, steer or stop one, 2
Hand work to a cloud agent, 2
Subagent lifecycle hooks
Recorded start and stop events, with their control semantics and availability caveats. A dash means no event is recorded here. General session or tool events do not establish a dedicated subagent hook.
Which moments a hook can attach to, and what it can do there. Event names link to each harness’s documentation. “Block”, “deny” and “modify” change what the agent does; “observe only” can watch but not intervene. Where hook files live is on the Locations page.
| Moment | Claude CodeHook commands |
|---|---|
| Hook types |
|
| Subagents | |
| Subagent starts | SubagentStartadd context |
| Subagent finishes | SubagentStopblock, add context |
Notes and sources
Claude Code
- onFailure: "block" on a command or HTTP hook makes a failed or timed-out hook block the action (2.1.295 and later).
- Plugin mods are a separate JavaScript hook surface with their own events and are not recorded here.
- 2.1.302 published changes: at most 12 prompt and agent hooks for one event run at once; remaining handlers wait. This is not the subagent concurrency limit or a stated cap on command/MCP hooks. Superseded by 2.1.312 below.
- 2.1.304 caps skill hooks from each source (a repository, personal folder or plugin) at 1,024 hooks and 16,384 matcher characters per session; these are separate from the 12 prompt/agent-hook concurrency limit.
- 2.1.304 fixes a skill once hook removing another skill’s identical hook, preserves a PreToolUse deny reason when an SDK callback hook times out, and excludes up to 10 minutes of SessionStart command-hook runtime from the VS Code subprocess initialization timeout.
- 2.1.304 adds a transcript notice identifying the event and plugin when an earlier plugin skips a mod hook. Mod tool.check gains e.isReadOnly and decider: person; settings.read receives individual layers and can rewrite merged settings. Mods remain a separate JavaScript hook surface.
- 2.1.309 publisher fixes PowerShell command hooks failing to block on exit code 2, including Windows PreToolUse/PermissionRequest fail-open behavior without Git for Windows. No hook-execution probe.
- 2.1.307 added claude_code.safety_event OpenTelemetry instrumentation for permission/safety/hook/sandbox outcomes; 2.1.312 stops sending it. It was never a hook event or hook control authority.
- 2.1.311 publisher fixes SubagentStop firing repeatedly while a subagent runs (about twice per minute); it should run once when the subagent finishes. 2.1.310 fixes Windows PreToolUse/PermissionRequest fail-open behavior with only quoted command strings when Git Bash is missing. No hook-execution probe.
- 2.1.312 publisher notes: prompt and agent hooks run at most 24 at a time per session, subagents included, plus at most 12 that have waited longer than their event's timeout. A
timeoutunder 1 second counts as 1 second. Command, HTTP and MCP-tool hooks are not covered by this limit. No hook-execution probe. - Publisher updates: 2.1.314 truncates each PreCompact hook output to 10,000 characters; 2.1.317 adds onFailure: block to Agent SDK callbacks; 2.1.319 runs PostToolUse (up to 10 seconds) for calls finishing after a new message interrupts the turn. 2.1.321 fixes competing PreToolUse ask/defer answers, refuses MCP tool calls on >16 MiB mcp_tool hook replies, and keeps original AskUserQuestion/ExitPlanMode results despite PostToolUse replacements in Cowork cloud. Separate hosts and handler types; no execution probe.
- 2.1.328 publisher notes extend onFailure: block to mcp_tool hooks and add CLAUDE_CODE_DISABLE_DEFERRED_TOOL_RESUME to stop deferred tool execution on -p --resume/--continue. Code Mode script output no longer runs UserPromptSubmit hooks; use PostToolUse updatedToolOutput for redaction. Managed PostToolUse no longer fires for calls refused before execution; PostToolBatch receives most without a refused marker. No hook runtime probe.
- Claude Code hooks reference, Documentation, checked 2026-10-15
- Claude Code 2.1.301 published changes, Documentation, checked 2026-10-16
- Claude Code 2.1.302 published changes; no runtime probe, Documentation, checked 2026-10-19
- Claude Code 2.1.304 published changes; no runtime probe, Documentation, checked 2026-10-21
- Claude Code 2.1.309 publisher changelog, Documentation, checked 2026-10-24
- Claude Code 2.1.307 publisher changelog, Documentation, checked 2026-10-24
- Claude Code 2.1.310 publisher changelog, Documentation, checked 2026-10-28
- Claude Code 2.1.311 publisher changelog, Documentation, checked 2026-10-28
- Claude Code 2.1.312 publisher changelog, Documentation, checked 2026-10-30
- Claude Code 2.1.314 publisher changelog, Documentation, checked 2026-11-12
- Claude Code 2.1.317 publisher changelog, Documentation, checked 2026-11-12
- Claude Code 2.1.319 publisher changelog, Documentation, checked 2026-11-12
- Claude Code 2.1.321 publisher changelog, Documentation, checked 2026-11-12
- Claude Code 2.1.328 publisher changelog, Documentation, checked 2026-11-20
Subagent transcripts
Child storage and parent links are described separately from the harness’s general session format. Internal and source-observed formats can change between versions; these records do not promise a stable external schema.
| Question | Claude Codedocumented-internal; checked at 2.1.299 |
|---|---|
| Child transcripts and parent links | Subagent transcripts are written beside the parent at Compacting the main conversation does not alter subagent transcripts; subagents log their own Subagent transcripts written before 2.1.307 can show placeholder token usage and empty stop reasons. |
| Session file format | Partly Transcripts are JSONL: one JSON object per line for a message, tool use, or metadata entry, each tagged with a Each message record carries the writing Claude Code |
| What is recorded | The transcript holds the full conversation: every prompt, response, tool call and tool result, plus thinking blocks, per-response token usage, compaction markers ( Everything is plaintext and unencrypted; a secret printed by a tool ends up in the transcript. Since v2.1.299 the bytes of @-mentioned PDFs are no longer kept in the transcript. |
| Read transcripts from code | The Agent SDK exposes |
| Session record structure | Claude Code |
|---|---|
| Envelope fields | type, uuid, parentUuid, sessionId, timestamp, version, cwd, gitBranch, entrypoint, isSidechain, userType, message |
| Record discriminator | type |
| Identifiers and lineage | sessionId, uuid, parentUuid, logicalParentUuid, leafUuid, promptId, requestId, agentId, toolUseID, sourceToolAssistantUUID |
| Ordering | file append order; message records also chain via parentUuid |
Notes and sources
Claude Code, 16 sources
- Claude Code says the entry format is internal and can change between versions.
- Prompt history (~/.claude/history.jsonl) is a different artifact.
- 2.1.304 adds earlier tool names to compaction summaries in Ctrl+O, avoids storing auto-mode classifier context with every request, and fixes local transcript GC dropping messages when disk fills during trimming. Mods settings.read can impose a cleanupPeriodDays ceiling used by retention sweeps. These are publisher claims, not a new transcript schema audit.
- 2026-10-26 automatic-approval audit: publisher docs show auto-mode denials and reasons alongside tool calls in the conversation/Ctrl+O viewer. This is not evidence for a stable JSONL classifier verdict record or a complete audit of approvals.
- 2.1.304 publisher changelog says classifier context is no longer saved with every request. Older transcripts may therefore contain more classifier context. Remaining private metadata/decision fields are not exhaustively specified or claimed absent.
- For documented machine-readable classifier decisions use separately configured OpenTelemetry tool_decision: classifier_verdict and permission_mode (2.1.301+), and optional classifier_category with OTEL_LOG_TOOL_DETAILS=1. safety_event (2.1.307–2.1.311; no longer sent from 2.1.312) recorded blocked/prompted checks, not every successful classifier allow. Telemetry is not the session transcript. See docs/research/automatic-approval.md.
- 2.1.311 publisher fixes out-of-order or retracted messages retained by -p/SDK transcripts. JSON/stream-json now escape DEL, C1 controls and Unicode format characters as \uXXXX without changing parsed values. 2.1.310 fixes cleanup of recent files with very large cleanupPeriodDays; a large value does not disable retention.
- 2.1.312 publisher fixes a rare case where the first reply after a terminal resume could be missing when the session was resumed again, and makes transcripts name the effort level in force rather than a newly picked level the model has not applied yet. Not a new JSONL schema audit.
- Documentation checked 2026-11-15 against latest 2.1.325 / stable 2.1.311 release metadata. Detailed internal shapes remain the historical 2.1.310 survey (high-level observedVersion 2.1.299); readable implementation JavaScript has now been located in the installed native executable; the 2.1.325 source supplement traces selected fields and storage policies. The four-field implementation supplement is not a complete 2.1.325 schema or controlled runtime verification.
- 2026-11-15 aggregate-only existing-record survey found 1,769 version-matched 2.1.325 records across five files. Ten record/subtype families and top-level/message field types were retained without content. Unversioned metadata in these mixed files is counted separately and cannot be attributed to 2.1.325. This supplements the 2.1.310 full survey; it is not a controlled writer/resume probe or an exhaustive current schema.
- Installed 2.1.325 source correction: the native executable embeds readable JavaScript alongside bytecode/string tables. Static extraction recovered transcript constructors, write routing and GC policy tables plus four field definitions. See docs/research/evidence/claude-transcript-source-2.1.325.json and its partial JSON Schema. Keep the older full catalogue version pin; these are explicitly current source supplements.
- Expanded 2.1.325 installed-source supplement: 46 write/read/GC policy registrations plus repl-mode special handling, six previously uncatalogued metadata families, and actual cost-state validator projection with eight passing isolated checks. Do not treat constructor candidates or normalized-reader shapes as complete runtime input schemas.