SpyBara
Go Premium

Documentation 2026-11-15 23:02 UTC to 2026-11-16 23:59 UTC

63 files changed +660 −325. View all changes and history on the product overview
2026
Wed 25 11:59 Tue 24 22:59 Mon 23 23:59 Sun 22 22:59 Sat 21 22:57 Fri 20 23:57 Thu 19 23:00 Wed 18 23:59 Tue 17 23:01 Mon 16 23:59 Sat 14 23:57 Fri 13 23:02 Thu 12 23:02 Wed 11 22:59 Tue 10 21:57 Mon 9 23:02 Sun 8 22:58 Sat 7 23:58 Fri 6 23:01 Thu 5 23:03 Wed 4 23:59 Tue 3 23:58 Mon 2 23:57 Sun 1 23:57
Details

337>337>

338> * A single-shot `query()` call yields the final result message, then raises an error that includes the failure text, such as `Reached maximum number of turns`. The raise is intentional. Wrap the loop in a try block if your code needs to continue past it. The underlying Claude Code process also exits with a nonzero code.338> * A single-shot `query()` call yields the final result message, then raises an error that includes the failure text, such as `Reached maximum number of turns`. The raise is intentional. Wrap the loop in a try block if your code needs to continue past it. The underlying Claude Code process also exits with a nonzero code.

339> * A streaming input session stays alive, and you can keep sending messages, except after a session crash, which emits a final `error_during_execution` result and exits the process.339> * A streaming input session stays alive, and you can keep sending messages, except after a session crash, which emits a final `error_during_execution` result and exits the process.

340> * In TypeScript, the loop over `query()` in a streaming input session throws when the last response ends in an error result. Wrap the loop in a try block if your code needs to continue past it.

340 341 

341The result also includes a `stop_reason` field (`string | null` in TypeScript, `str | None` in Python) indicating why the model stopped generating on its final turn. Common values are `end_turn` (model finished normally), `max_tokens` (hit the output token limit), and `refusal` (the model declined the request). On error results that the loop produced, `stop_reason` carries the value from the last assistant response before the loop ended; the result Claude Code synthesizes after a session crash carries `null`.342The result also includes a `stop_reason` field (`string | null` in TypeScript, `str | None` in Python) indicating why the model stopped generating on its final turn. Common values are `end_turn` (model finished normally), `max_tokens` (hit the output token limit), and `refusal` (the model declined the request). On error results that the loop produced, `stop_reason` carries the value from the last assistant response before the loop ended; the result Claude Code synthesizes after a session crash carries `null`.

342 343 

Details

140 140 

141## Limit turns and spend141## Limit turns and spend

142 142 

143Cap turns and spend with `maxTurns` / `max_turns` and `maxBudgetUsd` / `max_budget_usd`. Both caps are off when unset. When a session hits a cap, the run ends with a result message whose subtype names the cap, `error_max_turns` or `error_max_budget_usd`. What happens next differs by input mode:143Cap turns and spend with `maxTurns` / `max_turns` and `maxBudgetUsd` / `max_budget_usd`. Both caps are off when unset. When a session hits a cap, the run ends with a result message. The result's subtype is `error_max_turns` for the turn cap and `error_max_budget_usd` for the spend cap. Single-shot and streaming input handle a cap result differently:

144 144 

145* **Single-shot `query()`**: the SDK yields the cap result and then raises, so wrap the loop in a try block to continue past the error145* **Single-shot `query()`**: the SDK yields the cap result and then raises, so wrap the loop in a try block to continue past the error

146* **Streaming input**: the session stays alive past a cap result, and the max-turns count starts over for each queued message. The budget total accumulates across messages, and once spend reaches the cap, later messages in the same conversation end with the same budget result. A [`/clear`](https://code.claude.com/docs/en/agent-sdk/cost-tracking) starts the budget over146* **Streaming input**: the session stays alive past a cap result, and the max-turns count starts over for each queued message. The budget total accumulates across messages, and once spend reaches the cap, later messages in the same conversation end with the same budget result. A [`/clear`](https://code.claude.com/docs/en/agent-sdk/cost-tracking) starts the budget over.

147* **Streaming input in TypeScript**: the loop throws when the last response ends in an error result, such as `error_max_turns`. Wrap the loop in a try block to continue past it.

147 148 

148The two caps treat `0` differently:149The two caps treat `0` differently:

149 150 

Details

91| `total_cost_usd` | Included. Counts subagent requests alongside the top-level loop |91| `total_cost_usd` | Included. Counts subagent requests alongside the top-level loop |

92| `modelUsage` / `model_usage` | Included. Counts subagent requests alongside the top-level loop, broken down by model |92| `modelUsage` / `model_usage` | Included. Counts subagent requests alongside the top-level loop, broken down by model |

93 93 

94In [single message input mode](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md#single-message-input), when background subagents are still running at the end of the final turn, Claude Code waits for them, up to the cap described in [background tasks at exit](https://code.claude.com/docs/en/headless.md#background-tasks-at-exit), before emitting the result. The result's `total_cost_usd`, `duration_api_ms`, and `modelUsage`, or `model_usage` in Python, include the work done during that wait.94In [single message input mode](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md#choose-single-shot-or-streaming-input), Claude Code waits for background subagents still running at the end of the final turn before emitting the result. The wait lasts up to the cap described in [background tasks at exit](https://code.claude.com/docs/en/headless.md#background-tasks-at-exit). The result's `total_cost_usd`, `duration_api_ms`, and `modelUsage`, or `model_usage` in Python, include the work done during that wait.

95 95 

96The following examples iterate over the message stream from a `query()` call and print the total cost when the `result` message arrives:96The following examples iterate over the message stream from a `query()` call and print the total cost when the `result` message arrives:

97 97 

Details

384 384 

385## Context Claude Code adds outside the system prompt385## Context Claude Code adds outside the system prompt

386 386 

387System reminders are messages Claude Code adds to the conversation during a session to give Claude context, such as the contents of your CLAUDE.md files or a note that a file changed on disk. Claude Code sends them in the conversation, not in the system prompt, so most reach Claude whether you use the `claude_code` preset or pass your own string as `systemPrompt`.387System reminders are messages Claude Code adds to the conversation during a session to give Claude context, such as the contents of your CLAUDE.md files. Claude Code sends them in the conversation, not in the system prompt, so most reach Claude whether you use the `claude_code` preset or pass your own string as `systemPrompt`.

388 388 

389This section covers the [reminders most likely to change how your agent behaves](#reminders-claude-code-adds-to-the-conversation), how to [turn off the ones your agent replaces](#turn-off-the-context-your-agent-replaces), and how to [see what Claude received](#see-what-claude-received) in a specific request.389This section covers the [reminders most likely to change how your agent behaves](#reminders-claude-code-adds-to-the-conversation), how to [turn off the ones your agent replaces](#turn-off-the-context-your-agent-replaces), and how to [see what Claude received](#see-what-claude-received) in a specific request.

390 390 


399* **Available skills**: the names and descriptions of the [skills](https://code.claude.com/docs/en/agent-sdk/skills.md) Claude can call399* **Available skills**: the names and descriptions of the [skills](https://code.claude.com/docs/en/agent-sdk/skills.md) Claude can call

400* **Available subagents**: the names and descriptions of the [subagents](https://code.claude.com/docs/en/agent-sdk/subagents.md) Claude can start400* **Available subagents**: the names and descriptions of the [subagents](https://code.claude.com/docs/en/agent-sdk/subagents.md) Claude can start

401* **Task list nudges**: in a [session that has the task-tracking tools](https://code.claude.com/docs/en/agent-sdk/todo-tracking.md#model-availability), a prompt to update the task list when Claude hasn't touched it for several turns401* **Task list nudges**: in a [session that has the task-tracking tools](https://code.claude.com/docs/en/agent-sdk/todo-tracking.md#model-availability), a prompt to update the task list when Claude hasn't touched it for several turns

402* **File-changed notes**: a note that a file Claude read earlier has changed on disk402* **File-changed notes**: a note that a file Claude edited earlier has since changed on disk

403 403 

404Claude Code introduces your CLAUDE.md files with a line telling Claude that the instructions override default behavior.404Claude Code introduces your CLAUDE.md files with a line telling Claude that the instructions override default behavior.

405 405 

Details

1732* `result`: text of the final assistant message on `subtype="success"`, or `None` on the `error_*` subtypes. When `subtype="success"` and `is_error=True`, this holds the API error string if one is available but can be empty, so check `api_error_status` and the preceding `AssistantMessage` content for detail.1732* `result`: text of the final assistant message on `subtype="success"`, or `None` on the `error_*` subtypes. When `subtype="success"` and `is_error=True`, this holds the API error string if one is available but can be empty, so check `api_error_status` and the preceding `AssistantMessage` content for detail.

1733* `errors`: loop-level error strings such as the max-turns message. Populated only on the `error_*` subtypes.1733* `errors`: loop-level error strings such as the max-turns message. Populated only on the `error_*` subtypes.

1734* `terminal_reason`: why the query loop ended, such as `"completed"`, `"max_turns"`, `"api_error"`, `"aborted_streaming"`, or `"aborted_tools"`. A value of `"aborted_streaming"` or `"aborted_tools"` means the turn was aborted before completing. Common causes are [`interrupt()`](#claudesdkclient) and a permission callback returning [`PermissionResultDeny`](#permissionresultdeny) with `interrupt=True`. `None` on CLI versions that predate the field, on results from local commands such as `/voice` or `/usage`, which bypass the query loop, or on synthesized error results emitted when the session fails fatally. Mirrors the TypeScript SDK's [`SDKResultMessage.terminal_reason`](https://code.claude.com/docs/en/agent-sdk/typescript#sdkresultmessage), which lists the full set of values.1734* `terminal_reason`: why the query loop ended, such as `"completed"`, `"max_turns"`, `"api_error"`, `"aborted_streaming"`, or `"aborted_tools"`. A value of `"aborted_streaming"` or `"aborted_tools"` means the turn was aborted before completing. Common causes are [`interrupt()`](#claudesdkclient) and a permission callback returning [`PermissionResultDeny`](#permissionresultdeny) with `interrupt=True`. `None` on CLI versions that predate the field, on results from local commands such as `/voice` or `/usage`, which bypass the query loop, or on synthesized error results emitted when the session fails fatally. Mirrors the TypeScript SDK's [`SDKResultMessage.terminal_reason`](https://code.claude.com/docs/en/agent-sdk/typescript#sdkresultmessage), which lists the full set of values.

1735* `origin`: origin of the user message that triggered this turn. In [streaming input mode](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md), check this to tell the result of your own prompt, where `origin` is `None` or `{"kind": "human"}`, from the result of an injected turn such as a background-task notification. Requires Python Agent SDK 0.2.137 or later.1735* `origin`: origin of the user message that triggered this turn. Requires Python Agent SDK 0.2.137 or later. Don't suppress a result on `kind` alone. In [streaming input mode](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md), check `origin` to see whether your own prompt started the turn:

1736 * **Your own prompt**: `origin` is `None` or `{"kind": "human"}`

1737 * **A background-task notification**: `origin["kind"]` is `"task-notification"`. That turn's result can also hold Claude's answer to a message you sent while the turn ran tools.

1736 1738 

1737When several background tasks finish close together, Claude Code can answer their notifications in one turn rather than one turn each. You still receive one `ResultMessage` per notification, in order, each with an `origin` whose `kind` is `"task-notification"`. All but the last have `num_turns` set to `0` and an empty `result`, and the last one carries the turn that answers them all.1739When several background tasks finish close together, Claude Code can answer their notifications in one turn rather than one turn each. You still receive one `ResultMessage` per notification, in order, each with an `origin` whose `kind` is `"task-notification"`. All but the last have `num_turns` set to `0` and an empty `result`, and the last one carries the turn that answers them all.

1738 1740 

Details

218 218 

219> [!NOTE]219> [!NOTE]

220>220>

221> This example uses streaming to show progress in real-time. If you don't need live output (for example, for background jobs or CI pipelines), you can collect all messages at once. See [Streaming vs. single-turn mode](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md) for details.221> This example prints Claude's text and tool calls as the loop receives them. If you don't need live output, collect the messages in the loop and read them after the loop ends. To choose between a single-shot `query()` and streaming input, see [Choose single-shot or streaming input](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md#choose-single-shot-or-streaming-input).

222 222 

223### Run your agent223### Run your agent

224 224 

Details

94 94 

951. **Same-host kernel**: Unlike VMs, sandboxed processes share the host kernel. A kernel vulnerability could theoretically enable escape. For some threat models this is acceptable, but if you need kernel-level isolation, use gVisor or a separate VM.951. **Same-host kernel**: Unlike VMs, sandboxed processes share the host kernel. A kernel vulnerability could theoretically enable escape. For some threat models this is acceptable, but if you need kernel-level isolation, use gVisor or a separate VM.

96 96 

972. **No TLS inspection**: By default, the proxy allowlists domains based on the client-supplied hostname and doesn't terminate or inspect encrypted traffic. Code running inside the sandbox can potentially use [domain fronting](https://en.wikipedia.org/wiki/Domain_fronting) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, use a TLS-terminating proxy that inspects traffic, as [Traffic forwarding](#traffic-forwarding) describes. For more information, see the [sandboxing security limitations](https://code.claude.com/docs/en/sandboxing.md#security-limitations).972. **No TLS inspection**: By default, the proxy enforces the allowlist based on the client-supplied hostname and doesn't terminate or inspect encrypted traffic. Code running inside the sandbox can potentially use [domain fronting](https://en.wikipedia.org/wiki/Domain_fronting) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, use a TLS-terminating proxy that inspects traffic, as [Traffic forwarding](#traffic-forwarding) describes. For more information, see the [sandboxing security limitations](https://code.claude.com/docs/en/sandboxing.md#security-limitations).

98 98 

993. **Credentials for allowed domains**: If the agent has permissive credentials for an allowed domain, ensure it cannot use that domain to trigger other network requests or to exfiltrate data.993. **Credentials for allowed domains**: If the agent has permissive credentials for an allowed domain, ensure it cannot use that domain to trigger other network requests or to exfiltrate data.

100 100 

Details

169 169 

170> [!NOTE]170> [!NOTE]

171>171>

172> A command can hit the `maxTurns` / `max_turns` limit like any other prompt, ending the query with an error result instead of `success`. For the error-result contract, see [Handle the result](https://code.claude.com/docs/en/agent-sdk/agent-loop.md#handle-the-result). If your command might hit the limit, wrap the loop in a `try`/`catch` in TypeScript or `try`/`except` in Python, as shown in [Single Message Input](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md#single-message-input), or set `maxTurns` high enough for the work to complete.172> When a command reaches the `maxTurns` / `max_turns` limit, the query ends with an error result instead of `success`. For the error-result contract, see [Handle the result](https://code.claude.com/docs/en/agent-sdk/agent-loop.md#handle-the-result). If your command might hit the limit, do one of these:

173>

174> * Set `maxTurns` high enough for the work to complete.

175> * Wrap the `query()` loop in `try`/`catch` in TypeScript or `try`/`except` in Python.

173 176 

174### Compact history with `/compact`177### Compact history with `/compact`

175 178 

Details

8 8 

9By default, the Agent SDK yields a complete `AssistantMessage` for each non-empty content block, such as a text block or a tool call, after Claude finishes generating that block. To receive incremental updates as text and tool calls are generated, enable partial message streaming.9By default, the Agent SDK yields a complete `AssistantMessage` for each non-empty content block, such as a text block or a tool call, after Claude finishes generating that block. To receive incremental updates as text and tool calls are generated, enable partial message streaming.

10 10 

11> [!TIP]11> [!NOTE]

12>12>

13> This page covers output streaming (receiving tokens in real-time). For input modes (how you send messages), see [Send messages to agents](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md). You can also [stream responses using the Agent SDK via the CLI](https://code.claude.com/docs/en/headless.md).13> These cases are covered on other pages:

14>

15> * **Sending messages to a running session**: see [Send messages to a running agent](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md)

16> * **Streaming responses from the CLI**: see [stream responses using the Agent SDK via the CLI](https://code.claude.com/docs/en/headless.md)

14 17 

15## Enable streaming output18## Enable streaming output

16 19 


327 330 

328Now that you can stream text and tool calls in real-time, explore these related topics:331Now that you can stream text and tool calls in real-time, explore these related topics:

329 332 

330* [Interactive vs one-shot queries](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md): choose between input modes for your use case333* [Send messages to a running agent](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md): interrupt Claude's response or attach an image to a message

331* [Structured outputs](https://code.claude.com/docs/en/agent-sdk/structured-outputs.md): get typed JSON responses from the agent334* [Structured outputs](https://code.claude.com/docs/en/agent-sdk/structured-outputs.md): get typed JSON responses from the agent

332* [Permissions](https://code.claude.com/docs/en/agent-sdk/permissions.md): control which tools the agent can use335* [Permissions](https://code.claude.com/docs/en/agent-sdk/permissions.md): control which tools the agent can use

Details

2> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt2> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt

3> Use this file to discover all available pages before exploring further.3> Use this file to discover all available pages before exploring further.

4 4 

5# Streaming Input5# Send messages to a running agent

6 6 

7> Understanding the two input modes for Claude Agent SDK and when to use each7> Send follow-up messages and images to one Agent SDK session with streaming input, read each response, and interrupt a response to redirect Claude.

8 8 

9## Overview9Streaming input keeps an Agent SDK session open so your application can send it more than one message while it runs. You can also attach images to a message and stop a response partway through to redirect Claude.

10 10 

11The Claude Agent SDK supports two distinct input modes for interacting with agents:11> [!NOTE]

12>

13> Streaming input covers the messages you send. To show Claude's response as it's generated, see [Stream responses in real-time](https://code.claude.com/docs/en/agent-sdk/streaming-output.md).

14 

15## Choose single-shot or streaming input

12 16 

13* **Streaming Input Mode**: a persistent, interactive session17Choose streaming input for an application that holds a conversation with Claude, such as a chat interface. Use streaming input to attach images to a message, interrupt a response, or [switch the model or permission mode](https://code.claude.com/docs/en/agent-sdk/configuration.md#change-configuration-mid-session) while the session runs.

14* **Single Message Input**: one-shot queries that use session state and resuming

15 18 

16## Streaming Input Mode (Recommended)19A single-shot call passes one prompt string to `query()`. The call ends after Claude answers it. Single-shot fits a single task, such as a serverless function. To follow up after that call ends, start a new call that resumes the session. For more information, see [Continue, resume, and fork](https://code.claude.com/docs/en/agent-sdk/sessions.md#continue-resume-and-fork).

17 20 

18Streaming input mode is the **preferred** way to use the Claude Agent SDK. It provides full access to the agent's capabilities and enables rich, interactive experiences.21## Send more than one message to a session

19 22 

20It allows the agent to operate as a long lived process that takes in user input, handles interruptions, surfaces permission requests, and handles session management.23* **TypeScript**: write an [async generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function%2A) that yields [`SDKUserMessage`](https://code.claude.com/docs/en/agent-sdk/typescript#sdkusermessage) objects, and pass it as the `prompt` of `query()`. Make the generator wait between yields for the next message from your user.

24* **Python**: open a `ClaudeSDKClient` and pass each message to `client.query()`. Pass a string for a text message. To attach an image, pass an [async generator](https://docs.python.org/3/glossary.html#term-asynchronous-generator) that yields user message dicts.

21 25 

22### Benefits26To have Claude answer each message in its own response, wait for the previous response's [result message](#read-each-response) before you send the next one:

23 27 

24In streaming input mode, you work in a persistent session with these capabilities:28* **TypeScript**: have your generator await a promise. Resolve it in your `for await` loop over `query()` when the result message arrives.

29* **Python**: call `client.query()` with the next message after your [`receive_response()`](https://code.claude.com/docs/en/agent-sdk/python#claudesdkclient) loop ends.

25 30 

26* **Image uploads**: attach images directly to messages for visual analysis and understanding31> [!NOTE]

27* **Queued messages**: send multiple messages that process sequentially, with ability to interrupt32>

28* **Tool integration**: full access to all tools and custom MCP servers during the session33> A message you send during tool calls reaches Claude after those tool calls finish. Claude then answers it and your earlier message in one response. If the turn ends first, Claude starts a new turn for it. For details, see [Turns and budget](https://code.claude.com/docs/en/agent-sdk/agent-loop.md#turns-and-budget).

29* **Real-time feedback**: see responses as they're generated, not just final results

30* **Context persistence**: maintain conversation context across multiple turns naturally

31 34 

32### Implementation Example35### Send a follow-up with an image

33 36 

34These examples read an image named `diagram.png` from the working directory. Create one there first, or change the filename to point at your own image.37This example sends a text question, then a follow-up with an image, and prints Claude's response to each. Before you run it, save a PNG image as `diagram.png` in your working directory:

35 38 

36```typescript TypeScript theme={null}39```typescript TypeScript theme={null}

40import { readFile } from "node:fs/promises";

37import { query, type SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";41import { query, type SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";

38import { readFile } from "fs/promises";

39 42 

40async function* generateMessages(): AsyncGenerator<SDKUserMessage> {43let firstResponseDone!: () => void;

41 // First message44const firstResponseFinished = new Promise<void>((resolve) => {

45 firstResponseDone = resolve;

46});

47 

48async function* messages(): AsyncGenerator<SDKUserMessage> {

42 yield {49 yield {

43 type: "user",50 type: "user",

44 message: {51 message: {

45 role: "user",52 role: "user",

46 content: "Analyze this codebase for security issues"53 content: "Explain in two sentences what a message queue does.",

47 },54 },

48 parent_tool_use_id: null55 parent_tool_use_id: null,

49 };56 };

50 57 

51 // Wait for conditions or user input58 await firstResponseFinished;

52 await new Promise((resolve) => setTimeout(resolve, 2000));

53 59 

54 // Follow-up with image60 const image = await readFile("diagram.png");

55 yield {61 yield {

56 type: "user",62 type: "user",

57 message: {63 message: {

58 role: "user",64 role: "user",

59 content: [65 content: [

60 {66 { type: "text", text: "Describe this image in one sentence." },

61 type: "text",

62 text: "Review this architecture diagram"

63 },

64 {67 {

65 type: "image",68 type: "image",

66 source: {69 source: {

67 type: "base64",70 type: "base64",

68 media_type: "image/png",71 media_type: "image/png",

69 data: await readFile("diagram.png", "base64")72 data: image.toString("base64"),

70 }73 },

71 }

72 ]

73 },74 },

74 parent_tool_use_id: null75 ],

76 },

77 parent_tool_use_id: null,

75 };78 };

76}79}

77 80 

78// Process streaming responses81let responses = 0;

79for await (const message of query({82for await (const message of query({ prompt: messages() })) {

80 prompt: generateMessages(),83 if (message.type === "assistant") {

81 options: {84 for (const block of message.message.content) {

82 maxTurns: 10,85 if (block.type === "text") {

83 allowedTools: ["Read", "Grep"]86 console.log(block.text);

87 }

88 }

89 } else if (message.type === "result") {

90 responses += 1;

91 console.log(`Response ${responses} finished: ${message.subtype}`);

92 if (responses === 1) {

93 firstResponseDone();

84 }94 }

85})) {

86 if (message.type === "result" && message.subtype === "success") {

87 console.log(message.result);

88 }95 }

89}96}

90```97```

91 98 

92```python Python theme={null}99```python Python theme={null}

93from claude_agent_sdk import (

94 ClaudeSDKClient,

95 ClaudeAgentOptions,

96 AssistantMessage,

97 TextBlock,

98)

99import asyncio100import asyncio

100import base64101import base64

102from pathlib import Path

101 103 

104from claude_agent_sdk import AssistantMessage, ClaudeSDKClient, ResultMessage, TextBlock

102 105 

103async def streaming_analysis():

104 async def message_generator():

105 # First message

106 yield {

107 "type": "user",

108 "message": {

109 "role": "user",

110 "content": "Analyze this codebase for security issues",

111 },

112 }

113 

114 # Wait for conditions

115 await asyncio.sleep(2)

116 

117 # Follow-up with image

118 with open("diagram.png", "rb") as f:

119 image_data = base64.b64encode(f.read()).decode()

120 106 

107async def image_message():

108 image_data = base64.b64encode(Path("diagram.png").read_bytes()).decode()

121 yield {109 yield {

122 "type": "user",110 "type": "user",

123 "message": {111 "message": {

124 "role": "user",112 "role": "user",

125 "content": [113 "content": [

126 {"type": "text", "text": "Review this architecture diagram"},114 {"type": "text", "text": "Describe this image in one sentence."},

127 {115 {

128 "type": "image",116 "type": "image",

129 "source": {117 "source": {


136 },124 },

137 }125 }

138 126 

139 # Use ClaudeSDKClient for streaming input

140 options = ClaudeAgentOptions(max_turns=10, allowed_tools=["Read", "Grep"])

141 127 

142 async with ClaudeSDKClient(options) as client:128async def main():

143 # Send streaming input129 async with ClaudeSDKClient() as client:

144 await client.query(message_generator())130 await client.query("Explain in two sentences what a message queue does.")

131 async for message in client.receive_response():

132 if isinstance(message, AssistantMessage):

133 for block in message.content:

134 if isinstance(block, TextBlock):

135 print(block.text)

136 elif isinstance(message, ResultMessage):

137 print(f"Response 1 finished: {message.subtype}")

145 138 

146 # Process responses139 await client.query(image_message())

147 async for message in client.receive_response():140 async for message in client.receive_response():

148 if isinstance(message, AssistantMessage):141 if isinstance(message, AssistantMessage):

149 for block in message.content:142 for block in message.content:

150 if isinstance(block, TextBlock):143 if isinstance(block, TextBlock):

151 print(block.text)144 print(block.text)

145 elif isinstance(message, ResultMessage):

146 print(f"Response 2 finished: {message.subtype}")

152 147 

153 148 

154asyncio.run(streaming_analysis())149asyncio.run(main())

155```150```

156 151 

157When you run the example, the TypeScript version prints each response as it completes. The Python version's `receive_response()` loop ends at the first result message, so it prints the security analysis; to read both responses, use one `query()` and `receive_response()` pair per message as shown in the [Python reference's example of continuing a conversation](https://code.claude.com/docs/en/agent-sdk/python.md#example-continuing-a-conversation).152When you run either version, the example prints `Response 1 finished: success` and `Response 2 finished: success`.

158 153 

159If an image block's `source` is missing or isn't an object, the SDK doesn't report an error. Claude Code sends Claude a text note in place of the image, such as `[Image could not be processed: image block has no source object]`, and the session continues.154If Claude didn't see your image, see [Image could not be processed](https://code.claude.com/docs/en/agent-sdk/troubleshooting.md#image-could-not-be-processed).

160 155 

161> [!NOTE]156### Feed messages from a chat interface in TypeScript

162>

163> In the TypeScript SDK, if your message generator throws, for example when a file it reads is missing, the stream ends with an error that reads `Claude Code process aborted by user` instead of the original error, so check the code inside your generator first when you see that message. The error may also be preceded by a long minified line of bundled SDK source, so read to the end of the output for the error text.

164>

165> In the Python SDK, a generator exception is logged at debug level and the session stalls without raising, so if a streaming session hangs with no output, enable debug logging and check your generator.

166 157 

167## Single Message Input158Feed your user's messages to your prompt generator through a queue:

168 159 

169Single message input is simpler but more limited.160* **`pushMessage()`**: your interface's input handler calls this for each message the user sends.

161* **`closeInput()`**: the handler calls this when the user closes the chat.

162* **`userMessages()`**: the generator you pass as the `prompt` of `query()`.

170 163 

171### When to Use Single Message Input164`pushMessage()` adds each message to an array, and the generator reads from that array. When the array is empty, the generator waits until a message arrives or the chat closes:

172 165 

173Use single message input when:166```typescript theme={null}

167import type { SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";

174 168 

175* You need a one-shot response169const pending: string[] = [];

176* You do not need image attachments or mid-session control methods170let wake: (() => void) | null = null;

177* You need to operate in a stateless environment, such as a lambda function171let closed = false;

178 172 

179### Limitations173// The interface's input handler calls this with each message the user sends.

174function pushMessage(text: string): void {

175 pending.push(text);

176 wake?.();

177}

180 178 

181> [!WARNING]179// The interface calls this when the user closes the chat.

182>180function closeInput(): void {

183> Single message input mode does **not** support:181 closed = true;

184>182 wake?.();

185> * Direct image attachments in messages183}

186> * Dynamic message queueing184 

187> * Real-time interruption185async function* userMessages(): AsyncGenerator<SDKUserMessage> {

188> * Natural multi-turn conversations186 while (true) {

187 const text = pending.shift();

188 if (text !== undefined) {

189 yield { type: "user", message: { role: "user", content: text }, parent_tool_use_id: null };

190 } else if (closed) {

191 return;

192 } else {

193 await new Promise<void>((resolve) => (wake = resolve));

194 wake = null;

195 }

196 }

197}

198```

199 

200Messages you push during a response can share one response. To choose when Claude reads a message you push during a response, set the message's [`priority`](https://code.claude.com/docs/en/agent-sdk/typescript#sdkusermessage) field.

201 

202## Read each response

203 

204Claude ends each response with a result message.

205 

206* **TypeScript**: the `for await` loop over `query()` yields each response's messages in order. The loop ends after the last response's result message, once your generator has returned. To match a result to the messages it answers, set a `uuid` on each message you send, and read the result's [`user_message_uuids`](https://code.claude.com/docs/en/agent-sdk/typescript#user_message_uuids).

207* **Python**: start a `receive_response()` loop for each response, because each loop stops after the next [`ResultMessage`](https://code.claude.com/docs/en/agent-sdk/python#resultmessage). The client keeps the conversation's context from one message to the next. For more information, see [Automatic session management](https://code.claude.com/docs/en/agent-sdk/sessions.md#automatic-session-management).

189 208 

190If a query ends with an error result, such as `error_max_turns`, a single message `query()` call raises an error that includes the failure text after yielding the final result message, so wrap the loop in a try block if your code needs to continue. See [Handle the result](https://code.claude.com/docs/en/agent-sdk/agent-loop.md#handle-the-result) for the result subtypes.209The result message's `subtype` field reports how the response ended, such as `success` or `error_during_execution`.

191 210 

192### Implementation Example211If the last response ends in an error result:

212 

213* **TypeScript**: the loop over `query()` yields that result and then throws. Wrap the loop in `try`/`catch` to handle the exception. To keep the conversation going after the throw, start a new `query()` call that [resumes the session](https://code.claude.com/docs/en/agent-sdk/sessions.md#continue-resume-and-fork). While your generator still has messages to send, an error result for an earlier response doesn't throw.

214* **Python**: `receive_response()` on a `ClaudeSDKClient` yields the error result without raising.

215 

216For what each result subtype means, see [Handle the result](https://code.claude.com/docs/en/agent-sdk/agent-loop.md#handle-the-result).

217 

218## Interrupt Claude's response

219 

220To stop a response partway through and keep the session open, call `interrupt()` on the object that runs the session:

221 

222* **TypeScript**: pass an async generator as `prompt`, save the [`Query` object](https://code.claude.com/docs/en/agent-sdk/typescript#query-object) returned by `query()`, and call `interrupt()` on it.

223* **Python**: call `interrupt()` on the `ClaudeSDKClient`. If a `receive_response()` loop is reading the response, that loop ends at the interrupted response's `ResultMessage`. Send your next message after that result arrives.

224 

225When you call `interrupt()` during a response, that response ends with an `error_during_execution` result. Messages you sent before the interrupt that Claude hadn't read yet still reach Claude once the interrupted response ends. For what the TypeScript loop does when the last response is an error result, see [Read each response](#read-each-response).

226 

227This example asks Claude for a long essay. The example calls `interrupt()` three seconds after the session starts, then sends a second message to the same session once the interrupted response ends:

193 228 

194```typescript TypeScript theme={null}229```typescript TypeScript theme={null}

195import { query } from "@anthropic-ai/claude-agent-sdk";230import { query, type SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";

196 231 

197// Simple one-shot query232let firstResponseDone!: () => void;

198// query() throws after an error result, such as error_max_turns233const firstResponseFinished = new Promise<void>((resolve) => {

199try {234 firstResponseDone = resolve;

200 for await (const message of query({235});

201 prompt: "Explain the authentication flow",236 

202 options: {237async function* messages(): AsyncGenerator<SDKUserMessage> {

203 maxTurns: 5,238 yield {

204 allowedTools: ["Read", "Grep"]239 type: "user",

205 }240 message: {

206 })) {241 role: "user",

207 if (message.type === "result" && message.subtype === "success") {242 content: "Write a 2,000-word essay on the history of the printing press.",

208 console.log(message.result);243 },

209 }244 parent_tool_use_id: null,

210 }245 };

211} catch (error) {246 

212 console.error(`Query failed: ${error}`);247 await firstResponseFinished;

248 

249 yield {

250 type: "user",

251 message: {

252 role: "user",

253 content: "In one sentence, what is a prime number?",

254 },

255 parent_tool_use_id: null,

256 };

213}257}

214 258 

215// Continue conversation with session management259const conversation = query({ prompt: messages() });

216try {260 

217 for await (const message of query({261let responses = 0;

218 prompt: "Now explain the authorization process",262for await (const message of conversation) {

219 options: {263 if (message.type === "system" && message.subtype === "init" && responses === 0) {

220 continue: true,264 setTimeout(async () => {

221 maxTurns: 5265 await conversation.interrupt();

266 console.log("Interrupt sent");

267 }, 3000);

268 } else if (message.type === "assistant") {

269 for (const block of message.message.content) {

270 if (block.type === "text") {

271 console.log(block.text);

272 }

222 }273 }

223 })) {274 } else if (message.type === "result") {

224 if (message.type === "result" && message.subtype === "success") {275 responses += 1;

225 console.log(message.result);276 console.log(`Response ${responses} finished: ${message.subtype}`);

277 if (responses === 1) {

278 firstResponseDone();

226 }279 }

227 }280 }

228} catch (error) {

229 console.error(`Query failed: ${error}`);

230}281}

231```282```

232 283 

233```python Python theme={null}284```python Python theme={null}

234from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage

235import asyncio285import asyncio

236 286 

287from claude_agent_sdk import AssistantMessage, ClaudeSDKClient, ResultMessage, TextBlock

288 

289 

290async def main():

291 async with ClaudeSDKClient() as client:

292 await client.query("Write a 2,000-word essay on the history of the printing press.")

293 await asyncio.sleep(3)

294 await client.interrupt()

295 print("Interrupt sent")

296 async for message in client.receive_response():

297 if isinstance(message, AssistantMessage):

298 for block in message.content:

299 if isinstance(block, TextBlock):

300 print(block.text)

301 elif isinstance(message, ResultMessage):

302 print(f"Response 1 finished: {message.subtype}")

303 

304 await client.query("In one sentence, what is a prime number?")

305 async for message in client.receive_response():

306 if isinstance(message, AssistantMessage):

307 for block in message.content:

308 if isinstance(block, TextBlock):

309 print(block.text)

310 elif isinstance(message, ResultMessage):

311 print(f"Response 2 finished: {message.subtype}")

312 

237 313 

238async def single_message_example():314asyncio.run(main())

239 # Simple one-shot query using query() function

240 # query() raises ResultError after an error result, such as error_max_turns

241 try:

242 async for message in query(

243 prompt="Explain the authentication flow",

244 options=ClaudeAgentOptions(max_turns=5, allowed_tools=["Read", "Grep"]),

245 ):

246 if isinstance(message, ResultMessage) and message.subtype == "success":

247 print(message.result)

248 except Exception as e:

249 print(f"Query failed: {e}")

250 

251 # Continue conversation with session management

252 try:

253 async for message in query(

254 prompt="Now explain the authorization process",

255 options=ClaudeAgentOptions(continue_conversation=True, max_turns=5),

256 ):

257 if isinstance(message, ResultMessage) and message.subtype == "success":

258 print(message.result)

259 except Exception as e:

260 print(f"Query failed: {e}")

261 

262 

263asyncio.run(single_message_example())

264```315```

265 316 

266When you run the example, each query prints its final result text: first the authentication explanation, then the authorization explanation.317When you run either version, the first response stops partway through the essay, and the example prints `Response 1 finished: error_during_execution`. Claude then answers the second message. The output ends with `Response 2 finished: success`.

318 

319## Next steps

320 

321* [Stream responses in real-time](https://code.claude.com/docs/en/agent-sdk/streaming-output.md): show text and tool calls as Claude generates them

322* [Handle approvals and user input](https://code.claude.com/docs/en/agent-sdk/user-input.md): answer Claude's permission requests and clarifying questions

323* [Change configuration mid-session](https://code.claude.com/docs/en/agent-sdk/configuration.md#change-configuration-mid-session): switch the model or permission mode while the session runs

324* [`Query` object](https://code.claude.com/docs/en/agent-sdk/typescript#query-object) in TypeScript and [`ClaudeSDKClient`](https://code.claude.com/docs/en/agent-sdk/python#claudesdkclient) in Python: the methods that send messages to a running session or control it

325* [Work with sessions](https://code.claude.com/docs/en/agent-sdk/sessions.md): resume, continue, or fork a conversation

Details

211 211 

212### Automatic invocation212### Automatic invocation

213 213 

214Claude automatically decides when to invoke subagents based on the task and each subagent's `description`. For example, if you define a `performance-optimizer` subagent with the description "Performance optimization specialist for query tuning", Claude will invoke it when your prompt mentions optimizing queries.214Claude automatically decides when to invoke subagents based on the task and each subagent's `description`. For example, a `performance-optimizer` subagent with the description "Performance optimization specialist for query tuning" fits a prompt about optimizing queries.

215 215 

216Write clear, specific descriptions so Claude can match tasks to the right subagent.216Write clear, specific descriptions so Claude can match tasks to the right subagent.

217 217 

218### Explicit invocation218### Explicit invocation

219 219 

220To guarantee Claude uses a specific subagent, mention it by name in your prompt:220To ask for a specific subagent, mention it by name in your prompt:

221 221 

222```text theme={null}222```text theme={null}

223"Use the code-reviewer agent to check the authentication module"223"Use the code-reviewer agent to check the authentication module"

224```224```

225 225 

226This bypasses automatic matching and directly invokes the named subagent.

227 

228### Forked subagents226### Forked subagents

229 227 

230A [fork](https://code.claude.com/docs/en/sub-agents.md#fork-the-current-conversation) is a subagent that copies the conversation so far instead of starting fresh. From Claude Code v2.1.302, Claude can start forks in your application with nothing configured, by calling the Agent tool with `subagent_type: "fork"`.228A [fork](https://code.claude.com/docs/en/sub-agents.md#fork-the-current-conversation) is a subagent that copies the conversation so far instead of starting fresh. From Claude Code v2.1.302, Claude can start forks in your application with nothing configured, by calling the Agent tool with `subagent_type: "fork"`.

Details

371 371 

372* [Agent SDK reference - TypeScript](https://code.claude.com/docs/en/agent-sdk/typescript.md): the options, types, and tool schemas for the TypeScript SDK, including the Task tool input and output types372* [Agent SDK reference - TypeScript](https://code.claude.com/docs/en/agent-sdk/typescript.md): the options, types, and tool schemas for the TypeScript SDK, including the Task tool input and output types

373* [Agent SDK reference - Python](https://code.claude.com/docs/en/agent-sdk/python.md): the options, types, and tool documentation for the Python SDK373* [Agent SDK reference - Python](https://code.claude.com/docs/en/agent-sdk/python.md): the options, types, and tool documentation for the Python SDK

374* [Streaming Input](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md): the two input modes, and when to use streaming input instead of the single-shot calls these examples use374* [Send messages to a running agent](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md): use streaming input in place of the single-shot calls these examples use

375* [Give Claude custom tools](https://code.claude.com/docs/en/agent-sdk/custom-tools.md): define your own tools with the SDK's in-process MCP server375* [Give Claude custom tools](https://code.claude.com/docs/en/agent-sdk/custom-tools.md): define your own tools with the SDK's in-process MCP server

Details

4 4 

5# Troubleshoot the Agent SDK5# Troubleshoot the Agent SDK

6 6 

7> Fix Agent SDK errors: the Claude Code CLI fails to start or exits, a tool message is too large, or a result arrives without structured output.7> Fix Agent SDK errors: the Claude Code CLI fails to start or exits, your prompt generator throws, a tool message is too large, or structured output is missing.

8 8 

9This page covers Agent SDK errors in CLI startup, CLI process exit, large tool calls and results, and structured outputs. Entries on this page are keyed to the error you see. Each entry names the cause and what to do.9This page covers Agent SDK errors in CLI startup, CLI process exit, large tool calls and results, streaming input, and structured outputs. Entries on this page are keyed to the error you see. Each entry names the cause and what to do.

10 10 

11Symptoms tied to a feature, such as a hook not firing or a skill not being used, have a troubleshooting section on that feature's page. The table names the section or page that covers each symptom:11Symptoms tied to a feature, such as a hook not firing or a skill not being used, have a troubleshooting section on that feature's page. Look up your symptom in this table to find the section or page that covers it:

12 12 

13| Symptom | Go to |13| Symptom | Go to |

14| :- | :- |14| :- | :- |


21| An agent that works on your machine fails in a deployed service or container | [Troubleshoot deployment failures](https://code.claude.com/docs/en/agent-sdk/hosting.md#troubleshoot-deployment-failures) |21| An agent that works on your machine fails in a deployed service or container | [Troubleshoot deployment failures](https://code.claude.com/docs/en/agent-sdk/hosting.md#troubleshoot-deployment-failures) |

22| `Not logged in`, `Invalid API key`, `API Error`, `429`, `There's an issue with the selected model` | [Error reference](https://code.claude.com/docs/en/errors.md#find-your-error) |22| `Not logged in`, `Invalid API key`, `API Error`, `429`, `There's an issue with the selected model` | [Error reference](https://code.claude.com/docs/en/errors.md#find-your-error) |

23| `CLINotFoundError`, `CLIConnectionError`, `ProcessError`, `Claude Code process exited with code N`, `Claude Code returned an error result`, `CLIJSONDecodeError`, `structured_output` is `None` | [CLI startup](#cli-startup), [CLI process exit](#cli-process-exit), [Large tool calls and results](#large-tool-calls-and-results), and [Structured outputs](#structured-outputs) on this page |23| `CLINotFoundError`, `CLIConnectionError`, `ProcessError`, `Claude Code process exited with code N`, `Claude Code returned an error result`, `CLIJSONDecodeError`, `structured_output` is `None` | [CLI startup](#cli-startup), [CLI process exit](#cli-process-exit), [Large tool calls and results](#large-tool-calls-and-results), and [Structured outputs](#structured-outputs) on this page |

24| `Operation aborted`, `Claude Code process aborted by user`, `Prompt stream failed; closing stdin`, or a Python `query()` loop that stops, with no exception, before all your messages are answered | [Streaming input](#streaming-input) on this page |

25| `Image could not be processed` | [Image could not be processed](#image-could-not-be-processed) on this page |

24 26 

25## CLI startup27## CLI startup

26 28 


1641. If you hold a `ClaudeSDKClient` open, call `disconnect()`. The client receives no more messages after this error, but Claude Code keeps running and can still make changes.1661. If you hold a `ClaudeSDKClient` open, call `disconnect()`. The client receives no more messages after this error, but Claude Code keeps running and can still make changes.

1652. Start a new `query()` or `ClaudeSDKClient` with the larger limit and [`continue_conversation=True`](https://code.claude.com/docs/en/agent-sdk/sessions#continue-resume-and-fork), which picks the most recent session in the working directory. To pick a specific session, set `resume` to `data["session_id"]` from the init [`SystemMessage`](https://code.claude.com/docs/en/agent-sdk/python#systemmessage).1672. Start a new `query()` or `ClaudeSDKClient` with the larger limit and [`continue_conversation=True`](https://code.claude.com/docs/en/agent-sdk/sessions#continue-resume-and-fork), which picks the most recent session in the working directory. To pick a specific session, set `resume` to `data["session_id"]` from the init [`SystemMessage`](https://code.claude.com/docs/en/agent-sdk/python#systemmessage).

166 168 

169## Streaming input

170 

171### Operation aborted

172 

173In TypeScript, your `for await` loop over `query()` throws one of these messages as an `AbortError`. Either one means the query was aborted:

174 

175```text theme={null}

176Operation aborted

177Claude Code process aborted by user

178```

179 

180Check for these causes:

181 

182* **Your code aborted the query**: if your code calls `abort()` on the `AbortController` you passed as the [`abortController`](https://code.claude.com/docs/en/agent-sdk/typescript#options) option, the loop throws one of these errors. If you didn't intend the abort, check where your code calls `abort()`.

183* **Your async generator threw**: the error doesn't include your generator's own error message. To see that message, wrap the generator's body in `try`/`catch`, log the caught error, and rethrow it. Then fix the error you logged.

184 

185### Prompt stream failed; closing stdin

186 

187In Python, when the async generator you passed to the `query()` function raises an exception, your `async for` loop over `query()` ends with no exception. The SDK logs this line at `ERROR` level. If you haven't configured logging, Python prints the line to stderr:

188 

189```text theme={null}

190Prompt stream failed; closing stdin: <your exception's message>

191```

192 

193To see the exception's traceback, wrap the generator's body in `try`/`except`. Log the exception with its traceback and raise it again. Then fix the exception you logged.

194 

195### Image could not be processed

196 

197When an image block in your message has no `source` object, no error reaches your code. Claude receives this text note in place of the image:

198 

199```text theme={null}

200[Image could not be processed: image block has no source object]

201```

202 

203Claude answers without the image. Check that each image block has a `source` object, as in [Send a follow-up with an image](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md#send-a-follow-up-with-an-image).

204 

167## Structured outputs205## Structured outputs

168 206 

169### structured\_output is None but the result says success207### structured\_output is None but the result says success

Details

1744`SDKAssistantMessageError` is one of: `'authentication_failed'`, `'oauth_org_not_allowed'`, `'account_on_hold'`, `'billing_error'`, `'rate_limit'`, `'overloaded'`, `'invalid_request'`, `'model_not_found'`, `'server_error'`, `'max_output_tokens'`, `'cloud_credential_error'`, or `'unknown'`. Four of these values mean more than their names say:1744`SDKAssistantMessageError` is one of: `'authentication_failed'`, `'oauth_org_not_allowed'`, `'account_on_hold'`, `'billing_error'`, `'rate_limit'`, `'overloaded'`, `'invalid_request'`, `'model_not_found'`, `'server_error'`, `'max_output_tokens'`, `'cloud_credential_error'`, or `'unknown'`. Four of these values mean more than their names say:

1745 1745 

1746* `'model_not_found'`: the selected model doesn't exist or isn't available to your account or deployment1746* `'model_not_found'`: the selected model doesn't exist or isn't available to your account or deployment

1747* `'overloaded'`: the API returned a 529 because the server is at capacity, as opposed to `'rate_limit'`, which is a 429 against your quota1747* `'overloaded'`: appears on [`api_retry` events](https://code.claude.com/docs/en/headless#handle-api-retries) when the API returns a 529 because the server is at capacity. When an HTTP 529 ends the turn, the assistant message carries `'server_error'`. A 429 against your quota is `'rate_limit'`

1748* `'account_on_hold'`: [your account is on hold](https://code.claude.com/docs/en/errors.md#your-account-is-on-hold)1748* `'account_on_hold'`: [your account is on hold](https://code.claude.com/docs/en/errors.md#your-account-is-on-hold)

1749* `'cloud_credential_error'`: Claude Code couldn't obtain usable AWS or Google Cloud credentials on the machine it runs on, so no request reached the cloud provider. The usual cause is a cloud sign-in that expired or was never completed on that machine, though a briefly unreachable credential service reports the same value. See [Could not load AWS or Google Cloud credentials](https://code.claude.com/docs/en/errors.md#could-not-load-aws-or-google-cloud-credentials). Requires TypeScript Agent SDK v0.3.267 or later, which bundles Claude Code v2.1.2671749* `'cloud_credential_error'`: Claude Code couldn't obtain usable AWS or Google Cloud credentials on the machine it runs on, so no request reached the cloud provider. The usual cause is a cloud sign-in that expired or was never completed on that machine, though a briefly unreachable credential service reports the same value. See [Could not load AWS or Google Cloud credentials](https://code.claude.com/docs/en/errors.md#could-not-load-aws-or-google-cloud-credentials). Requires TypeScript Agent SDK v0.3.267 or later, which bundles Claude Code v2.1.267

1750 1750 

agent-view.md +2 −2

Details

8 8 

9Agent view, opened with `claude agents`, is one screen for all your background sessions: what's running, what needs your input, and what's done. Dispatch new sessions, watch their state at a glance instead of scrolling through transcripts, and step in only when one needs you. Each background session is a full Claude Code conversation that keeps running without a terminal attached, so you can open it, reply, and leave whenever you want.9Agent view, opened with `claude agents`, is one screen for all your background sessions: what's running, what needs your input, and what's done. Dispatch new sessions, watch their state at a glance instead of scrolling through transcripts, and step in only when one needs you. Each background session is a full Claude Code conversation that keeps running without a terminal attached, so you can open it, reply, and leave whenever you want.

10 10 

11![Agent view in a terminal. A line at the top counts the sessions awaiting input, working, and completed. Four sessions are grouped under Needs input, Working, and Completed. Each row shows the session's name, its latest status or question, and a time. At the bottom are an input for describing a new task and a row of keyboard hints.](https://mintcdn.com/claude-code/v_J840yKc6uuKDX_/images/agent-view-light.png?fit=max\&auto=format\&n=v_J840yKc6uuKDX_\&q=85\&s=bd95fda83ea66ca8b2e0e7b68f8cb29e)11![Agent view in a terminal. A line at the top counts the sessions awaiting input, working, and completed. Four sessions are grouped under Needs input, Working, and Completed. Each row shows the session's name, its latest status or question, and a time. At the bottom are an input for describing a new task and a row of keyboard hints.](https://mintcdn.com/claude-code/H7YQo-xfDxC94ETh/images/agent-view-light.png?fit=max\&auto=format\&n=H7YQo-xfDxC94ETh\&q=85\&s=f27b570ff81c2a316bef487645b1331c)

12 12 

13Use agent view when you have several independent tasks Claude can work on without you watching every step. Dispatch a bug fix, a pull request review, and a flaky-test investigation as three rows, keep working in another window, and check back when a row shows it needs you or has a result.13Use agent view when you have several independent tasks Claude can work on without you watching every step. Dispatch a bug fix, a pull request review, and a flaky-test investigation as three rows, keep working in another window, and check back when a row shows it needs you or has a result.

14 14 


265 265 

266If you press `←` right after you delete the last of the prompt's text or move through prompt history, Claude Code asks you to confirm: the first press shows `Press ← again to open agents`, or `Press ← again to go back to agents` in an attached session, and the second press switches.266If you press `←` right after you delete the last of the prompt's text or move through prompt history, Claude Code asks you to confirm: the first press shows `Press ← again to open agents`, or `Press ← again to go back to agents` in an attached session, and the second press switches.

267 267 

268When `←` backgrounds a foreground session, agent view shows `Your conversation moved to the background` above the list, with that session's row already selected. From there:268After you background a session with `←`:

269 269 

270* Press `Enter` to reopen the conversation.270* Press `Enter` to reopen the conversation.

271* Press `Esc` to undo the switch and return to the conversation. If `Esc` shows `Still starting — try again in a moment`, the background session isn't ready yet, so press `Esc` again in a moment.271* Press `Esc` to undo the switch and return to the conversation. If `Esc` shows `Still starting — try again in a moment`, the background session isn't ready yet, so press `Esc` again in a moment.

Details

464export ANTHROPIC_BEDROCK_SERVICE_TIER=priority464export ANTHROPIC_BEDROCK_SERVICE_TIER=priority

465```465```

466 466 

467Claude Code sends this as the `X-Amzn-Bedrock-Service-Tier` header on every [Invoke API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) request from a session that has the variable, except its [model access checks](#startup-model-checks). Setting it has no effect on requests to the [Mantle endpoint](#use-the-mantle-endpoint) or through a [Claude apps gateway](https://code.claude.com/docs/en/claude-apps-gateway). Tier availability varies by model and region. Reserved capacity uses a [provisioned throughput](https://docs.aws.amazon.com/bedrock/latest/userguide/prov-throughput.html) ARN as the model ID instead of this setting.467Claude Code sends this as the `X-Amzn-Bedrock-Service-Tier` header on every [Invoke API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) request from a session that has the variable, except its [model access checks](#startup-model-checks). Setting it has no effect on requests to the [Mantle endpoint](#use-the-mantle-endpoint) or through a [Claude apps gateway](https://code.claude.com/docs/en/claude-apps-gateway). Tier availability varies by model and region.

468 468 

469To cover [background sessions](https://code.claude.com/docs/en/agent-view.md#settings-and-provider) you start from a terminal, set `ANTHROPIC_BEDROCK_SERVICE_TIER` in the [`env`](https://code.claude.com/docs/en/settings-reference#env) block of your settings. Those sessions get the value you export only when the shell that started the [supervisor](https://code.claude.com/docs/en/agent-view.md#the-supervisor-process) exported it.469To cover [background sessions](https://code.claude.com/docs/en/agent-view.md#settings-and-provider) you start from a terminal, set `ANTHROPIC_BEDROCK_SERVICE_TIER` in the [`env`](https://code.claude.com/docs/en/settings-reference#env) block of your settings. Those sessions get the value you export only when the shell that started the [supervisor](https://code.claude.com/docs/en/agent-view.md#the-supervisor-process) exported it.

470 470 

analytics.md +7 −21

Details

71>71>

72> These metrics are deliberately conservative and represent an underestimate of Claude Code's actual impact. Only lines and PRs where there is high confidence in Claude Code's involvement are counted.72> These metrics are deliberately conservative and represent an underestimate of Claude Code's actual impact. Only lines and PRs where there is high confidence in Claude Code's involvement are counted.

73 73 

74The dashboard displays these summary metrics at the top:74The dashboard displays these summary metrics:

75 75 

76* **PRs with CC**: total count of merged pull requests that contain at least one line of code written with Claude Code76* **PRs with Claude Code**: merged pull requests that contain at least one line of code written with Claude Code. One card shows the count, and one shows the share of all merged PRs

77* **Lines of code with CC**: total lines of code across all merged PRs that were written with Claude Code assistance. Only "effective lines" are counted: lines with more than 3 characters after normalization, excluding empty lines and lines with only brackets or trivial punctuation.77* **LOC with Claude Code**: total lines of code (LOC) across all merged PRs that were written with Claude Code assistance. Only "effective lines" are counted: lines with more than 3 characters after normalization.

78* **PRs with Claude Code (%)**: percentage of all merged PRs that contain Claude Code-assisted code

79* **Suggestion accept rate**: percentage of times users accept Claude Code's code editing suggestions, including Edit, Write, and NotebookEdit tool usage78* **Suggestion accept rate**: percentage of times users accept Claude Code's code editing suggestions, including Edit, Write, and NotebookEdit tool usage

80* **Lines of code accepted**: total lines of code that Claude Code's Edit and Write tools added or removed in accepted edits. This excludes rejected suggestions, and lines deleted later don't reduce the total.79* **Lines of code accepted**: total lines of code that Claude Code's Edit and Write tools added or removed in accepted edits. This excludes rejected suggestions, and lines deleted later don't reduce the total.

81 80 


83 82 

84The dashboard includes several charts to visualize trends over time.83The dashboard includes several charts to visualize trends over time.

85 84 

86#### Track adoption

87 

88The Adoption chart shows daily usage trends:

89 

90* **users**: daily active users

91* **sessions**: number of active Claude Code sessions per day

92 

93#### Measure PRs per user85#### Measure PRs per user

94 86 

95This chart displays individual developer activity over time:87**Total PRs per user** is the number of PRs merged per day divided by daily active users.

96 

97* **PRs per user**: total number of PRs merged per day divided by daily active users

98* **users**: daily active users

99 88 

100Use this to understand how individual productivity changes as Claude Code adoption increases.89Use this to understand how individual productivity changes as Claude Code adoption increases.

101 90 

102#### View pull requests breakdown91#### View pull requests breakdown

103 92 

104The Pull requests chart shows a daily breakdown of merged PRs:93The **PRs with Claude Code** chart compares each day's merged PRs with Claude Code to **All PRs**.

105 

106* **PRs with CC**: pull requests containing Claude Code-assisted code

107* **PRs without CC**: pull requests without Claude Code-assisted code

108 94 

109Toggle to **Lines of code** view to see the same breakdown by lines of code rather than PR count.95Toggle to **Lines of code** view to see the same breakdown by lines of code rather than PR count.

110 96 


162 148 

163#### Monitor adoption149#### Monitor adoption

164 150 

165Track the Adoption chart and user counts to identify:151Track the **Users** and **Sessions** charts to identify:

166 152 

167* Active users who can share best practices153* Active users who can share best practices

168* Overall adoption trends across your organization154* Overall adoption trends across your organization


173Contribution metrics help answer "Is this tool worth the investment?" with data from your own codebase:159Contribution metrics help answer "Is this tool worth the investment?" with data from your own codebase:

174 160 

175* Track changes in PRs per user over time as adoption increases161* Track changes in PRs per user over time as adoption increases

176* Compare PRs and lines of code shipped with vs. without Claude Code162* Compare PRs and lines of code shipped with Claude Code to all PRs and lines of code

177* Use alongside [DORA metrics](https://dora.dev/), sprint velocity, or other engineering KPIs to understand changes from adopting Claude Code163* Use alongside [DORA metrics](https://dora.dev/), sprint velocity, or other engineering KPIs to understand changes from adopting Claude Code

178 164 

179#### Identify power users165#### Identify power users

artifacts.md +1 −1

Details

204 204 

205You can stop Claude from replying on its own in any of these ways:205You can stop Claude from replying on its own in any of these ways:

206 206 

207* **Press Ctrl+C once at an idle prompt**: Claude pauses replying on every artifact your session is watching. Replies start again after you send your next message.207* **Press Ctrl+C once at an idle, empty prompt**: Claude pauses replying on every artifact your session is watching. Replies start again after you send your next message.

208* **Stop the task in `/tasks`**: Claude stops replying on that artifact until you ask it to resume replies there. Publishing the artifact again doesn't start replies again, and the stop still applies when you resume the session later.208* **Stop the task in `/tasks`**: Claude stops replying on that artifact until you ask it to resume replies there. Publishing the artifact again doesn't start replies again, and the stop still applies when you resume the session later.

209* **Press `Ctrl+X Ctrl+K` twice within 3 seconds**: the chord that [stops every running background subagent](https://code.claude.com/docs/en/interactive-mode.md#general-controls) also stops Claude from replying on every artifact for the rest of the session. Asking Claude to resume replies doesn't undo this stop.209* **Press `Ctrl+X Ctrl+K` twice within 3 seconds**: the chord that [stops every running background subagent](https://code.claude.com/docs/en/interactive-mode.md#general-controls) also stops Claude from replying on every artifact for the rest of the session. Asking Claude to resume replies doesn't undo this stop.

210 210 

Details

224 224 

225> [!NOTE]225> [!NOTE]

226>226>

227> In a [Code Mode](https://code.claude.com/docs/en/code-mode.md#permission-checks) session, the classifier applies `hard_deny` and `soft_deny` when it reviews Claude's code, and not to each tool call the code makes. `permissions.deny` rules apply to each call.227> In a [Code Mode](https://code.claude.com/docs/en/code-mode.md#permission-checks) session, the classifier applies `hard_deny` and `soft_deny` to each piece of code as a whole, before the code runs. To block a specific tool call that the code makes, use a `permissions.deny` rule.

228 228 

229Inside the classifier, precedence works in four tiers:229Inside the classifier, precedence works in four tiers:

230 230 

Details

62 62 

63Every production topology here puts an L7 proxy, such as an Ingress, Cloud Run's front end, or an ALB, in front of plain-HTTP replicas. Set [`listen.trusted_proxies`](https://code.claude.com/docs/en/claude-apps-gateway-config#listen) to the proxy's source ranges so the gateway reads client IPs from `X-Forwarded-For`. The gateway honors the header only when the TCP peer is trusted. The [Google Cloud](https://code.claude.com/docs/en/claude-apps-gateway-on-gcp.md) and [AWS](https://code.claude.com/docs/en/claude-apps-gateway-on-aws.md) worked examples have concrete values per topology. Without trusted proxies, every request appears to come from the proxy's IP, which collapses per-IP rate limits into one shared bucket and records the proxy's IP in audit events.63Every production topology here puts an L7 proxy, such as an Ingress, Cloud Run's front end, or an ALB, in front of plain-HTTP replicas. Set [`listen.trusted_proxies`](https://code.claude.com/docs/en/claude-apps-gateway-config#listen) to the proxy's source ranges so the gateway reads client IPs from `X-Forwarded-For`. The gateway honors the header only when the TCP peer is trusted. The [Google Cloud](https://code.claude.com/docs/en/claude-apps-gateway-on-gcp.md) and [AWS](https://code.claude.com/docs/en/claude-apps-gateway-on-aws.md) worked examples have concrete values per topology. Without trusted proxies, every request appears to come from the proxy's IP, which collapses per-IP rate limits into one shared bucket and records the proxy's IP in audit events.

64 64 

65Don't redirect requests to the gateway's device-authorization and token endpoints, for example with an HTTP-to-HTTPS or host-canonicalization rewrite at the ingress. Claude Code doesn't follow redirects on those requests, so an ingress rule that redirects them breaks sign-in and token refresh.65Don't redirect requests bound for the gateway's device-authorization and token endpoints, for example with an HTTP-to-HTTPS or host-canonicalization rewrite at the ingress. Claude Code doesn't follow redirects on those requests, so an ingress rule that redirects them breaks sign-in and token refresh.

66 66 

67Give the proxy any idle timeout longer than the gateway's keepalive interval, which depends on the upstream:67Give the proxy any idle timeout longer than the gateway's keepalive interval, which depends on the upstream:

68 68 

Details

16 16 

17Click files in the tree to see what each one does, when it loads, and an example.17Click files in the tree to see what each one does, when it loads, and an example.

18 18 

19Configuration files

20 

21**`CLAUDE.md`**

22 

23**When it loads**: Loaded into context at session start

24 

25Project-specific instructions that shape how Claude works in this repository. Put your conventions, common commands, and architectural context here.

26 

27**`.mcp.json`**

28 

29**When it loads**: In interactive sessions, MCP servers you've [approved](https://code.claude.com/docs/en/mcp.md#project-scope) load when the session begins. Tool schemas are deferred by default and load on demand via [tool search](https://code.claude.com/docs/en/mcp.md#scale-with-mcp-tool-search)

30 

31Configures Model Context Protocol (MCP) servers that give Claude access to external tools: databases, APIs, browsers, and more. This file holds the project-scoped servers your whole team uses. Personal servers you want to keep to yourself go in `~/.claude.json`.

32 

33**`.worktreeinclude`**

34 

35**When it loads**: Read when Claude creates a [git worktree](https://code.claude.com/docs/en/worktrees.md) via `--worktree`, the `EnterWorktree` tool, or subagent `isolation: worktree`

36 

37Lists gitignored files to copy from your main repository into each new worktree. Worktrees are fresh checkouts, so untracked files like `.env` are missing by default. Patterns here use `.gitignore` syntax. Only files that match a pattern and are also gitignored get copied.

38 

39**`.claude/`**

40 

41Project settings, rules, skills, subagents, and other configuration. If you use git, commit most of these files so your team shares them, and keep personal ones such as `settings.local.json` out of your commits.

42 

43**`.claude/settings.json`**

44 

45**When it loads**: Read at session start. Most edits [apply to the running session](https://code.claude.com/docs/en/settings.md#when-edits-take-effect)

46 

47Settings that Claude Code applies directly. Permissions control which commands and tools Claude can use; hooks run your scripts at specific points in a session. Unlike CLAUDE.md, which Claude reads as guidance, these are enforced whether Claude follows them or not.

48 

49This file ranks above `~/.claude/settings.json` and below `.claude/settings.local.json`, the `--settings` flag, and managed settings in [settings precedence](https://code.claude.com/docs/en/settings.md#settings-precedence). For most single-value keys, such as `model`, Claude Code uses the highest-ranked value. Most lists, such as `permissions.allow`, [merge across files](https://code.claude.com/docs/en/settings.md#lists-merge-instead-of-overriding).

50 

51**`.claude/settings.local.json`**

52 

53**When it loads**: Read at session start. Most edits [apply to the running session](https://code.claude.com/docs/en/settings.md#when-edits-take-effect)

54 

55Your personal settings for this project. Same JSON format as `settings.json`, gitignored when Claude Code saves a setting to it.

56 

57This file ranks above `.claude/settings.json` and below the `--settings` flag and managed settings in [settings precedence](https://code.claude.com/docs/en/settings.md#settings-precedence). For most single-value keys, such as `model`, Claude Code uses the highest-ranked value. Most lists, such as `permissions.allow`, [merge across files](https://code.claude.com/docs/en/settings.md#lists-merge-instead-of-overriding).

58 

59**`.claude/rules/`**

60 

61**When it loads**: Rules without `paths:` frontmatter load at session start. Rules with `paths:` load when Claude reads, writes, or edits a matching file

62 

63Project instructions split into topic files. Like CLAUDE.md, rules are guidance that Claude Code doesn't enforce. For enforced behavior use [hooks](https://code.claude.com/docs/en/hooks.md) or [permissions](https://code.claude.com/docs/en/permissions.md).

64 

65**`.claude/skills/`**

66 

67**When it loads**: Invoked with `/skill-name` or when Claude matches the task to a skill

68 

69Each skill is a folder with a `SKILL.md` file plus any supporting files it needs. By default, both you and Claude can invoke a skill. Use [frontmatter](https://code.claude.com/docs/en/skills.md#frontmatter-reference) to control that: `disable-model-invocation: true` so Claude can't invoke a skill like `/deploy` on its own, or `user-invocable: false` so only Claude can invoke the skill.

70 

71**`.claude/commands/`**

72 

73**When it loads**: Invoked with `/command-name` or when Claude matches the task to a command

74 

75Holds single-file commands: a prompt saved as `.claude/commands/deploy.md` runs as `/deploy`. For a new command, use a [skill](#ce-skills), which can bundle reference docs, templates, or scripts alongside the prompt.

76 

77**`.claude/output-styles/`**

78 

79**When it loads**: Read at startup in the terminal, so restart Claude Code after you add or edit a style

80 

81Each Markdown file defines an [output style](https://code.claude.com/docs/en/output-styles.md#how-output-styles-work), a set of instructions that adjusts how Claude works. Put a style here if your team shares it, like a review mode everyone uses. See [`~/.claude/output-styles/`](#ce-global-output-styles) for how to select one.

82 

83**`.claude/agents/`**

84 

85**When it loads**: Each subagent runs in its own context window when you or Claude invoke it

86 

87Each Markdown file with `name` and `description` frontmatter defines a subagent with its own system prompt, tool access, and optionally its own model. Useful for parallel work or isolated tasks.

88 

89**`.claude/workflows/`**

90 

91**When it loads**: Loaded at startup when [workflows are on](https://code.claude.com/docs/en/workflows.md). Each saved workflow runs as a `/<name>` command

92 

93Each `.js` file is a [dynamic workflow](https://code.claude.com/docs/en/workflows.md): a script the runtime executes to spawn and coordinate many subagents. To add one, have Claude write a workflow, then run `/workflows` in the session and save it here.

94 

95**`.claude/agent-memory/`**

96 

97**When it loads**: First 200 lines of a subagent's `MEMORY.md`, capped at 25KB, loaded into its system prompt when the subagent runs

98 

99Subagents with [`memory: project`](https://code.claude.com/docs/en/sub-agents#enable-persistent-memory) in their frontmatter get a dedicated memory directory here while [auto memory](https://code.claude.com/docs/en/memory.md#auto-memory) is on. Each subagent reads and writes its own `MEMORY.md`, separate from your main session's auto memory in `~/.claude/projects/`.

100 

101**`.claude/agent-memory/<agent-name>/MEMORY.md`**

102 

103**When it loads**: First 200 lines, capped at 25KB, loaded into the subagent's system prompt when the subagent runs

104 

105An index of the notes the subagent has saved. The subagent creates and updates this file itself, in the same format as your main [auto memory](https://code.claude.com/docs/en/memory.md#storage-location) index.

106 

107**`~/.claude.json`**

108 

109**When it loads**: Read at session start for your preferences and MCP servers. Claude Code writes back to it when you change a [global config option](https://code.claude.com/docs/en/settings-reference.md#global-config-settings) in `/config` or trust a project folder

110 

111Holds account details, per-project trust decisions, your personal MCP servers, and UI toggles.

112 

113**`~/.claude/`**

114 

115The global counterpart to your project [`.claude/`](#ce-dot-claude) directory. Configuration files in this directory apply to you in every project on this machine.

116 

117**`~/.claude/CLAUDE.md`**

118 

119**When it loads**: Loaded at session start in every project on this machine

120 

121Your global instruction file. Loaded alongside the project CLAUDE.md. If the two conflict, Claude may follow either one. Keep this file to preferences that apply everywhere: response style, commit format, personal conventions.

122 

123**`~/.claude/settings.json`**

124 

125**When it loads**: Read at session start. Most edits [apply to the running session](https://code.claude.com/docs/en/settings.md#when-edits-take-effect)

126 

127Same format as project `settings.json`: permissions, hooks, model, and environment variables. Put settings here that you want in every project, like allow rules, a preferred model, or a notification hook.

128 

129This file ranks below the project's settings files, the `--settings` flag, and managed settings in [settings precedence](https://code.claude.com/docs/en/settings.md#settings-precedence). For most single-value keys, such as `model`, Claude Code uses the highest-ranked value. Most lists, such as `permissions.allow`, [merge across files](https://code.claude.com/docs/en/settings.md#lists-merge-instead-of-overriding).

130 

131**`~/.claude/keybindings.json`**

132 

133**When it loads**: Read at session start and hot-reloaded when you edit the file

134 

135Rebind keyboard shortcuts in the interactive CLI. Run `/keybindings` in a session to create or open this file. Check the [reserved shortcuts](https://code.claude.com/docs/en/keybindings.md#reserved-shortcuts) before you pick a key.

136 

137**`~/.claude/themes/`**

138 

139**When it loads**: Read at session start and [hot-reloaded](https://code.claude.com/docs/en/terminal-config.md#create-a-custom-theme) when files change. Listed in `/theme`

140 

141Each `.json` file defines a custom color theme: a built-in `base` preset plus an `overrides` map of color tokens. Run `/theme` in a session to create one, or write the JSON yourself. Selecting a custom theme stores `custom:<slug>` as your theme preference.

142 

143**`~/.claude/projects/`**

144 

145**When it loads**: The current project's `memory/MEMORY.md` loads at session start while auto memory is on. The topic files it lists are read on demand

146 

147Holds [auto memory](https://code.claude.com/docs/en/memory.md#auto-memory), the notes Claude saves across sessions: your role and preferences, corrections you give it, project decisions, and where to find information outside the project. Each project gets its own memory directory keyed by the repository path.

148 

149**`~/.claude/projects/<project>/memory/MEMORY.md`**

150 

151**When it loads**: First 200 lines, capped at 25KB, loaded at session start while [auto memory](https://code.claude.com/docs/en/memory.md#auto-memory) is on

152 

153An index pointing to topic files for detail. Claude creates and updates this file as it works. You can edit or delete it.

154 

155**`~/.claude/projects/<project>/memory/user_role.md`**

156 

157**When it loads**: Claude reads this when a related task comes up

158 

159An example of a topic file. Claude saves each memory in its own topic file, picks the filename, and lists it in `MEMORY.md`.

160 

161**`~/.claude/rules/`**

162 

163**When it loads**: Rules without `paths:` frontmatter load at session start. Rules with `paths:` load when Claude reads, writes, or edits a matching file

164 

165Same format as project [`.claude/rules/`](#ce-rules), applied to every project on this machine. Use this for conventions you want across all your work, like personal code style or commit message format.

166 

167**`~/.claude/skills/`**

168 

169**When it loads**: Invoked with `/skill-name` or when Claude matches the task to a skill

170 

171Skills you built for yourself, available in all your projects on this machine. Same format as project [`.claude/skills/`](#ce-skills).

172 

173**`~/.claude/commands/`**

174 

175**When it loads**: Invoked with `/command-name` or when Claude matches the task to a command

176 

177Same format as project [`.claude/commands/`](#ce-commands), available in all your projects on this machine.

178 

179**`~/.claude/output-styles/`**

180 

181**When it loads**: Read at startup in the terminal, so restart Claude Code after you add or edit a style

182 

183Each Markdown file defines an [output style](https://code.claude.com/docs/en/output-styles.md#how-output-styles-work), a set of instructions that adjusts how Claude works. Use a style to adapt Claude Code for uses beyond coding, or to add teaching or review modes.

184 

185Select a built-in or custom style with `/output-style` or `/config` in a session, or with the `outputStyle` key in settings. Styles here are available in every project on this machine. If a project style has the same name, Claude Code uses the project's style.

186 

187**`~/.claude/agents/`**

188 

189**When it loads**: Each subagent runs in its own context window when you or Claude invoke it

190 

191Subagents defined here are available across all your projects on this machine. Same format as project [`.claude/agents/`](#ce-agents).

192 

193**`~/.claude/workflows/`**

194 

195**When it loads**: Loaded at startup when [workflows are on](https://code.claude.com/docs/en/workflows.md). Each saved workflow runs as a `/<name>` command

196 

197Workflow scripts saved here are available across all your projects on this machine. A project workflow with the same name in `.claude/workflows/` takes precedence.

198 

199**`~/.claude/agent-memory/`**

200 

201**When it loads**: First 200 lines of a subagent's `MEMORY.md`, capped at 25KB, loaded into its system prompt when the subagent runs

202 

203Subagents with `memory: user` in their frontmatter store knowledge here while [auto memory](https://code.claude.com/docs/en/memory.md#auto-memory) is on. That knowledge persists across all projects. For project-scoped subagent memory, see [`.claude/agent-memory/`](#ce-agent-memory).

204 

19## What's not shown205## What's not shown

20 206 

21The explorer covers files you author and edit. A few related files live elsewhere:207The explorer covers files you author and edit. A few related files live elsewhere:


74| [`commands/*.md`](#ce-commands) | Project and global | ✓ | Single-file prompts; same mechanism as skills | [Skills](https://code.claude.com/docs/en/skills.md) |260| [`commands/*.md`](#ce-commands) | Project and global | ✓ | Single-file prompts; same mechanism as skills | [Skills](https://code.claude.com/docs/en/skills.md) |

75| [`output-styles/*.md`](#ce-output-styles) | Project and global | ✓ | Custom instruction sets that adjust how Claude works | [Output styles](https://code.claude.com/docs/en/output-styles.md) |261| [`output-styles/*.md`](#ce-output-styles) | Project and global | ✓ | Custom instruction sets that adjust how Claude works | [Output styles](https://code.claude.com/docs/en/output-styles.md) |

76| [`agents/*.md`](#ce-agents) | Project and global | ✓ | Subagent definitions with their own prompt and tools | [Subagents](https://code.claude.com/docs/en/sub-agents.md) |262| [`agents/*.md`](#ce-agents) | Project and global | ✓ | Subagent definitions with their own prompt and tools | [Subagents](https://code.claude.com/docs/en/sub-agents.md) |

77| [`workflows/*.js`](#ce-workflows) | Project and global | ✓ | Dynamic workflow scripts written by Claude and saved from `/workflows`; each file becomes a `/<name>` command | [Dynamic workflows](https://code.claude.com/docs/en/workflows.md) |263| [`workflows/*.js`](#ce-workflows) | Project and global | ✓ | Dynamic workflow scripts written by Claude and saved from `/workflows`; each saved workflow runs as a `/<name>` command | [Dynamic workflows](https://code.claude.com/docs/en/workflows.md) |

78| [`agent-memory/<name>/`](#ce-agent-memory) | Project and global | ✓ | Persistent memory for subagents | [Persistent memory](https://code.claude.com/docs/en/sub-agents.md#enable-persistent-memory) |264| [`agent-memory/<name>/`](#ce-agent-memory) | Project and global | ✓ | Persistent memory for subagents | [Persistent memory](https://code.claude.com/docs/en/sub-agents.md#enable-persistent-memory) |

79| [`~/.claude.json`](#ce-claude-json) | Global only | | App state, account details, UI toggles, personal MCP servers. If it's missing, Claude Code creates it when you start a session or run a subcommand such as `claude auth status`, but not for `--version` or `--help`. | [Global config](https://code.claude.com/docs/en/settings-reference.md#global-config-settings) |265| [`~/.claude.json`](#ce-claude-json) | Global only | | App state, account details, UI toggles, personal MCP servers. If it's missing, Claude Code creates it when you start a session or run a subcommand such as `claude auth status`, but not for `--version` or `--help`. | [Global config](https://code.claude.com/docs/en/settings-reference.md#global-config-settings) |

80| [`projects/<project>/memory/`](#ce-global-projects) | Global only | | Auto memory: Claude's notes to itself across sessions | [Auto memory](https://code.claude.com/docs/en/memory.md#auto-memory) |266| [`projects/<project>/memory/`](#ce-global-projects) | Global only | | Auto memory: Claude's notes to itself across sessions | [Auto memory](https://code.claude.com/docs/en/memory.md#auto-memory) |

Details

258* **In the Claude desktop app**: open **Settings > Code** or **Settings > Claude Code** and turn on **Use this computer from your phone and claude.ai**. Add the folder to the list under that switch. Threads can run on this computer while the app is open.258* **In the Claude desktop app**: open **Settings > Code** or **Settings > Claude Code** and turn on **Use this computer from your phone and claude.ai**. Add the folder to the list under that switch. Threads can run on this computer while the app is open.

259* **In a terminal**: run `claude remote-control` in the folder and leave it running. In a git repository, add `--spawn worktree` to give each thread there its own [worktree](https://code.claude.com/docs/en/worktrees.md) instead of the folder itself.259* **In a terminal**: run `claude remote-control` in the folder and leave it running. In a git repository, add `--spawn worktree` to give each thread there its own [worktree](https://code.claude.com/docs/en/worktrees.md) instead of the folder itself.

260 260 

261**2. Ask for the task with Work locally**261**2. Ask for the task**

262 262 

263In the project conversation, choose **Work locally** from the **+** menu beside the message box, which tags your message **Local**, and write what you want done. Saying in the message that the task should run on your computer works too.263In the project conversation, choose **Work locally** from the **+** menu, or **Work in a local folder** in the desktop app, and write what you want done. Saying in the message that the task should run on your computer works too.

264 

265If **Work locally** is greyed out with a note about trusted devices, [**Require trusted devices**](https://code.claude.com/docs/en/remote-control.md#trusted-devices) is on for your account and this project can't run a thread on your computer. To work in that folder, run Claude Code on that computer directly.

264 266 

265**3. Allow it on the card**267**3. Allow it on the card**

266 268 

267Claude answers with an **Allow Claude to work in a folder on your device** card. Pick the folder if you connected several. Two threads working in one folder at the same time can overwrite each other's changes, so if the folder is a git repository, you can turn on **Worktree** in the folder's options to give this thread its own worktree instead. Then click **Allow once**.269Claude answers with an **Allow Claude to work in a folder on your computer** card. Pick the folder if you connected several. Two threads working in one folder at the same time can overwrite each other's changes. If the folder is a git repository, you can turn on **Worktree** in the folder's options to give this thread its own worktree instead. Then click **Allow once**.

268 270 

269The thread runs in [auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode), so Claude runs commands and edits files in that folder without asking you each time. If auto mode is unavailable or turned off in that computer's Claude Code, the thread runs without it, and any permission prompt it raises waits for your answer in the thread, as [Unblock a thread waiting on approval](#unblock-a-thread-waiting-on-approval) describes.271The thread runs in [auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode), so Claude runs commands and edits files in that folder without asking you each time. If auto mode is unavailable or turned off in that computer's Claude Code, the thread runs without it, and any permission prompt it raises waits for your answer in the thread, as [Unblock a thread waiting on approval](#unblock-a-thread-waiting-on-approval) describes.

270 272 


275* **To get the thread going again**: see [Lost contact with your folder](#lost-contact-with-your-folder)277* **To get the thread going again**: see [Lost contact with your folder](#lost-contact-with-your-folder)

276* **To keep the computer from sleeping on its own**: in the desktop app, turn on **Keep this computer awake for Remote Control** in **Settings > Code** or **Settings > Claude Code**278* **To keep the computer from sleeping on its own**: in the desktop app, turn on **Keep this computer awake for Remote Control** in **Settings > Code** or **Settings > Claude Code**

277 279 

278A project can't run a thread on your computer while [**Require trusted devices**](https://code.claude.com/docs/en/remote-control.md#trusted-devices) is on for your account.

279 

280## Give a project standing context280## Give a project standing context

281 281 

282Project memory, project instructions, and the project's repositories, files, and environment carry context across threads. You set each one once.282Project memory, project instructions, and the project's repositories, files, and environment carry context across threads. You set each one once.

Details

117| `--plugin-url` | Fetch a plugin `.zip` archive from a URL for this session only. Repeat the flag for multiple plugins, or pass space-separated URLs in a single quoted value | `claude --plugin-url https://example.com/plugin.zip` |117| `--plugin-url` | Fetch a plugin `.zip` archive from a URL for this session only. Repeat the flag for multiple plugins, or pass space-separated URLs in a single quoted value | `claude --plugin-url https://example.com/plugin.zip` |

118| `--print`, `-p` | Print response without interactive mode (see [Agent SDK documentation](https://code.claude.com/docs/en/agent-sdk/overview.md) for programmatic usage details). For `--resume` on a background session that is still running, see [Resume a running background session](https://code.claude.com/docs/en/sessions.md#resume-a-running-background-session) | `claude -p "query"` |118| `--print`, `-p` | Print response without interactive mode (see [Agent SDK documentation](https://code.claude.com/docs/en/agent-sdk/overview.md) for programmatic usage details). For `--resume` on a background session that is still running, see [Resume a running background session](https://code.claude.com/docs/en/sessions.md#resume-a-running-background-session) | `claude -p "query"` |

119| `--prompt-suggestions` | Emit a `prompt_suggestion` message with a predicted next user prompt after each turn that generates one; very short conversations can produce none. Requires `--print`, `--output-format stream-json`, and `--verbose`. See [Prompt suggestions](https://code.claude.com/docs/en/interactive-mode.md#prompt-suggestions) | `claude -p --prompt-suggestions --output-format stream-json --verbose "query"` |119| `--prompt-suggestions` | Emit a `prompt_suggestion` message with a predicted next user prompt after each turn that generates one; very short conversations can produce none. Requires `--print`, `--output-format stream-json`, and `--verbose`. See [Prompt suggestions](https://code.claude.com/docs/en/interactive-mode.md#prompt-suggestions) | `claude -p --prompt-suggestions --output-format stream-json --verbose "query"` |

120| `--ref <branch>` | With `--environment`, base the new session's checkout on a named ref instead of local `HEAD` | `claude -p "Run the smoke test" --environment ccpool_abc123 --ref main` |120| `--ref <branch>` | With `--environment`, base the new session's checkout on a named ref. Requires Claude Code v2.1.224 or later | `claude -p "Run the smoke test" --environment ccpool_abc123 --ref main` |

121| `--remote` | Deprecated alias for `--cloud`, including the existing-session form | `claude --remote "Fix the login bug"` |121| `--remote` | Deprecated alias for `--cloud`, including the existing-session form | `claude --remote "Fix the login bug"` |

122| `--remote-control`, `--rc` | Start an interactive session with [Remote Control](https://code.claude.com/docs/en/remote-control.md#start-a-remote-control-session) enabled so you can also control it from claude.ai or the Claude app. Optionally pass a name for the session | `claude --remote-control "My Project"` |122| `--remote-control`, `--rc` | Start an interactive session with [Remote Control](https://code.claude.com/docs/en/remote-control.md#start-a-remote-control-session) enabled so you can also control it from claude.ai or the Claude app. Optionally pass a name for the session | `claude --remote-control "My Project"` |

123| `--remote-control-session-name-prefix <prefix>` | Prefix for auto-generated [Remote Control](https://code.claude.com/docs/en/remote-control.md) session names when no explicit name is set. Defaults to your machine's hostname, producing names like `myhost-graceful-unicorn`. Set `CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX` for the same effect | `claude remote-control --remote-control-session-name-prefix dev-box` |123| `--remote-control-session-name-prefix <prefix>` | Prefix for auto-generated [Remote Control](https://code.claude.com/docs/en/remote-control.md) session names when no explicit name is set. Defaults to your machine's hostname, producing names like `myhost-graceful-unicorn`. Set `CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX` for the same effect | `claude remote-control --remote-control-session-name-prefix dev-box` |

Details

296| Your user `~/.claude/CLAUDE.md` | No | Lives on your machine, not in the repo. See [Add personal preferences without committing to the repo](#add-personal-preferences-without-committing-to-the-repo) |296| Your user `~/.claude/CLAUDE.md` | No | Lives on your machine, not in the repo. See [Add personal preferences without committing to the repo](#add-personal-preferences-without-committing-to-the-repo) |

297| Your user `~/.claude/skills/`, `~/.claude/agents/`, `~/.claude/commands/` | No | Live on your machine, not in the repo. Commit them to the repo's `.claude/` directory instead. Cloud sessions automatically load [skills you enable on claude.ai](https://code.claude.com/docs/en/skills.md#skills-in-cowork-and-cloud-sessions) |297| Your user `~/.claude/skills/`, `~/.claude/agents/`, `~/.claude/commands/` | No | Live on your machine, not in the repo. Commit them to the repo's `.claude/` directory instead. Cloud sessions automatically load [skills you enable on claude.ai](https://code.claude.com/docs/en/skills.md#skills-in-cowork-and-cloud-sessions) |

298| Plugins enabled only in your user settings | No | User-scoped `enabledPlugins` lives in `~/.claude/settings.json` on your machine |298| Plugins enabled only in your user settings | No | User-scoped `enabledPlugins` lives in `~/.claude/settings.json` on your machine |

299| MCP servers you added with `claude mcp add` at the default local scope or the user scope | No | Those write to `~/.claude.json` on your machine, not the repo. Add the server with `claude mcp add --scope project`, which writes the repo's [`.mcp.json`](https://code.claude.com/docs/en/mcp#project-scope), and commit that file. A session with one repository loads it |299| MCP servers you added with `claude mcp add` at the default local scope or the user scope | No | At those scopes, the command writes to `~/.claude.json` on your machine. Run `claude mcp add --scope project` from the repository root to write the repo's [`.mcp.json`](https://code.claude.com/docs/en/mcp#project-scope), and commit that file. A session with one repository loads it |

300| Transport variables in your repo's `.claude/settings.json` `env` block, such as `NODE_EXTRA_CA_CERTS` and the [mTLS client certificate variables](https://code.claude.com/docs/en/network-config.md#mtls-authentication) | No | The hosting environment manages the session's API connection, so Claude Code ignores these keys and notes each ignored key in the session's debug log |300| Transport variables in your repo's `.claude/settings.json` `env` block, such as `NODE_EXTRA_CA_CERTS` and the [mTLS client certificate variables](https://code.claude.com/docs/en/network-config.md#mtls-authentication) | No | The hosting environment manages the session's API connection, so Claude Code ignores these keys and notes each ignored key in the session's debug log |

301| API keys and tokens for services Claude calls | In an Anthropic-hosted environment, as [network secrets](#add-network-secrets) | You add the key once on the environment and the agent proxy attaches it to requests for the hosts you list. A key the agent proxy [can't attach](#requests-that-never-get-the-credential) stays in an environment variable |301| API keys and tokens for services Claude calls | In an Anthropic-hosted environment, as [network secrets](#add-network-secrets) | You add the key once on the environment and the agent proxy attaches it to requests for the hosts you list. A key the agent proxy [can't attach](#requests-that-never-get-the-credential) stays in an environment variable |

302| Interactive auth like AWS SSO | No | Not supported. SSO requires browser-based login that can't run in a cloud session |302| Interactive auth like AWS SSO | No | Not supported. SSO requires browser-based login that can't run in a cloud session |

code-mode.md +16 −12

Details

49## Requirements49## Requirements

50 50 

51* **Version**: Claude Code v2.1.323 or later, on either [release channel](https://code.claude.com/docs/en/setup.md#configure-release-channel). An older version starts without Code Mode, with or without the reason `it isn't open to your account yet`51* **Version**: Claude Code v2.1.323 or later, on either [release channel](https://code.claude.com/docs/en/setup.md#configure-release-channel). An older version starts without Code Mode, with or without the reason `it isn't open to your account yet`

52* **Account**: a Claude subscription or Console account. You can't use Code Mode through a gateway, Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform, or Microsoft Foundry52* **Account**: a Claude subscription or Console account. You can't use Code Mode through a gateway, Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform, Microsoft Foundry, or [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/en/claude-models-on-google-cloud-anthropic-managed.md)

53* **Organization**: your organization doesn't use the [HIPAA configuration](https://code.claude.com/docs/en/hipaa-setup.md) or [zero data retention](https://code.claude.com/docs/en/zero-data-retention.md)53* **Organization**: your organization doesn't use the [HIPAA configuration](https://code.claude.com/docs/en/hipaa-setup.md) or [zero data retention](https://code.claude.com/docs/en/zero-data-retention.md)

54* **Model**: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.254* **Model**: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.2

55* **Surface**: an interactive `claude` session in a terminal. Code Mode doesn't work with `-p`, the Agent SDK, the VS Code panel, the Desktop app, or cloud sessions55* **Surface**: an interactive `claude` session in a terminal. Code Mode doesn't work with `-p`, the Agent SDK, the VS Code panel, the Desktop app, or cloud sessions

56* **Agent teams**: to use Code Mode with [agent teams](https://code.claude.com/docs/en/agent-teams.md) on, you need v2.1.326 or later. Teammates run in Code Mode in the default [in-process display mode](https://code.claude.com/docs/en/agent-teams.md#choose-a-display-mode), and start without it in split panes

56* **Installation**: the [native build](https://code.claude.com/docs/en/setup.md) of Claude Code57* **Installation**: the [native build](https://code.claude.com/docs/en/setup.md) of Claude Code

57* **Windows**: [Git for Windows](https://git-scm.com/downloads/win) is installed58* **Windows**: [Git for Windows](https://git-scm.com/downloads/win) is installed

58 59 

59You also can't start Code Mode with some settings on, such as an API key helper, agent teams, OpenTelemetry export, or `DISABLE_TELEMETRY`. For the fix for each, see [Code Mode doesn't start](#code-mode-doesnt-start).60You also can't start Code Mode with some settings on, such as an API key helper, OpenTelemetry export, or `DISABLE_TELEMETRY`. For the fix for each, see [Code Mode doesn't start](#code-mode-doesnt-start).

60 61 

61## Try Code Mode62## Try Code Mode

62 63 


143 144 

144## Permissions and long-running code145## Permissions and long-running code

145 146 

146Your permission mode decides how Claude's code is checked and whether you can talk to Claude while the code runs.147Your permission mode decides how the code that Claude writes is checked and whether you can talk to Claude while the code runs.

147 148 

148### Permission checks149### Permission checks

149 150 

150Each tool call that Claude's code makes goes through your `deny` and `ask` [permission rules](https://code.claude.com/docs/en/permissions.md) and your [`PreToolUse` hooks](https://code.claude.com/docs/en/hooks#pretooluse). You don't need to change a rule or matcher for a tool such as `Bash`. Beyond rules and hooks, a classifier reviews the code in auto mode, and you answer prompts in the modes that ask:151When Claude runs code, each tool call in it goes through your `deny` and `ask` [permission rules](https://code.claude.com/docs/en/permissions.md) and your [`PreToolUse` hooks](https://code.claude.com/docs/en/hooks#pretooluse) under the tool's usual name, such as `Bash`. Beyond rules and hooks, a classifier reviews the code in auto mode, and you answer prompts in the modes that ask:

151 152 

152* **[Auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode)**: the classifier reviews each piece of code before it runs, not each tool call. It doesn't see values computed at run time, such as a path taken from search output, so keep rules or hooks for calls you must control. You can still be [prompted when new code starts while earlier code runs](#permission-prompt-with-a-countdown)153* **[Auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode)**: the classifier reviews each piece of code before it runs, not each tool call. It doesn't see values computed at run time, such as a path taken from search output, so keep rules or hooks for calls you must control. You can still be [prompted when new code starts while earlier code runs](#permission-prompt-with-a-countdown)

153* **Other [permission modes](https://code.claude.com/docs/en/permission-modes.md)**: the code starts without a review, and you're prompted for each tool call that would prompt you in that mode154* **Other [permission modes](https://code.claude.com/docs/en/permission-modes.md)**: the code starts without a review, and you're prompted for each tool call that would prompt you in that mode

154 155 

155To check the code itself, write a `PreToolUse` hook that matches `REPL`, the tool that runs Claude's code, and read the JavaScript from `tool_input.code`.156If you have a `PreToolUse` hook that allows or blocks shell commands, make it check each part of a command, as [Bash rules do](https://code.claude.com/docs/en/permissions.md#compound-commands). In Code Mode, a `git push` in a folder named `app` can reach your hook as `cd 'app' && git push`.

157 

158To check the code itself, write a `PreToolUse` hook that matches `REPL`, the tool that runs the code, and read the JavaScript from `tool_input.code`.

156 159 

157> [!WARNING]160> [!WARNING]

158>161>


179 182 

180| Reason includes | What to do |183| Reason includes | What to do |

181| :- | :- |184| :- | :- |

182| `it isn't open to your account yet` | If your version is older than v2.1.323, [update](#try-code-mode). Otherwise, check your network connection and start again. If the reason stays, try again another day |185| `it isn't open to your account in this version` or `it isn't open to your account yet` | If your version is older than v2.1.323, [update](#try-code-mode). Otherwise, check your network connection and start again. If the reason stays, try again another day |

183| `it only works with the Anthropic API` | Remove the settings that route requests through a cloud provider, a gateway, or a custom `ANTHROPIC_BASE_URL` |186| `it only works directly with the Anthropic API` or `it only works with the Anthropic API` | Remove the settings that route requests through a cloud provider, a gateway, or a custom `ANTHROPIC_BASE_URL` |

184| `it doesn't work with an API key helper` | Remove `apiKeyHelper`, `ANTHROPIC_AUTH_TOKEN`, and any `Authorization` or `X-Api-Key` header in `ANTHROPIC_CUSTOM_HEADERS`. Then sign in or set `ANTHROPIC_API_KEY` |187| `it doesn't work with an API key helper` | Remove `apiKeyHelper`, `ANTHROPIC_AUTH_TOKEN`, and any `Authorization` or `X-Api-Key` header in `ANTHROPIC_CUSTOM_HEADERS`. Then sign in or set `ANTHROPIC_API_KEY` |

185| `it only works with Opus 5.5, Sonnet 5.5 and later models` | Start with a [supported model](#requirements), for example with `--model opus`. Haiku 5.5 and Fable 5.2 also work |188| `it only works with Opus 5.5, Sonnet 5.5 and later models` | Start with a [supported model](#requirements), for example with `--model opus`. Haiku 5.5 and Fable 5.2 also work |

186| `it doesn't work in background jobs` | Start in the foreground, without `--remote-control` |189| `it doesn't work in background jobs` | Start in the foreground, without `--remote-control`. If the reason shows in a teammate's split pane, use the [in-process display mode](https://code.claude.com/docs/en/agent-teams.md#choose-a-display-mode) to run teammates in Code Mode |

187| `it needs settings that Claude Code downloads from Anthropic` | Unset the variable that [turns off feature-flag fetching](https://code.claude.com/docs/en/env-vars.md#features-that-need-feature-flag-fetching), such as `DISABLE_TELEMETRY` |190| `it needs settings that Claude Code downloads from Anthropic` | Unset the variable that [turns off feature-flag fetching](https://code.claude.com/docs/en/env-vars.md#features-that-need-feature-flag-fetching), such as `DISABLE_TELEMETRY` |

188| `OpenTelemetry is on` | Unset `CLAUDE_CODE_ENABLE_TELEMETRY` and `ENABLE_BETA_TRACING_DETAILED` if you can work without [OpenTelemetry export](https://code.claude.com/docs/en/monitoring-usage.md) |191| `OpenTelemetry is on` | Unset `CLAUDE_CODE_ENABLE_TELEMETRY` and `ENABLE_BETA_TRACING_DETAILED` if you can work without [OpenTelemetry export](https://code.claude.com/docs/en/monitoring-usage.md) |

192| `it doesn't yet work with the plugin` | In a session, run `/plugin` and disable each plugin that the reason names. If your organization turned one on, ask your administrator to turn it off |

189| `it doesn't yet work with an installed mod` | Turn off the [mod](https://code.claude.com/docs/en/plugins/mods/overview.md) that checks tool calls |193| `it doesn't yet work with an installed mod` | Turn off the [mod](https://code.claude.com/docs/en/plugins/mods/overview.md) that checks tool calls |

190| `it can't be used together with agent teams yet` | Unset `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` |194| `it can't be used together with agent teams yet` | To keep agent teams on, [update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code) to v2.1.326 or later. To stay on your version, unset `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` |

191| `this launch's tool options` | Start without `--restricted`, add `REPL` to `--tools`, and remove `REPL` from `--disallowedTools` and your `deny` rules |195| `this launch's tool options` | Start without `--restricted`, add `REPL` to `--tools`, and remove `REPL` from `--disallowedTools` and your `deny` rules |

192| `couldn't save your answer` | Make `~/.claude.json` writable |196| `couldn't save your answer` | Make `~/.claude.json` writable |

193| `your organization's settings don't allow it` | Ask your administrator about the [managed setting](#block-code-mode-for-your-organization) |197| `your organization's settings don't allow it` | Ask your administrator about the [managed setting](#block-code-mode-for-your-organization) |


208 212 

209If Claude reports a refused tool call, ask it for the error text. These errors mean that a `PreToolUse` hook didn't give a decision, which refuses the call even when [`onFailure`](https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails) is unset:213If Claude reports a refused tool call, ask it for the error text. These errors mean that a `PreToolUse` hook didn't give a decision, which refuses the call even when [`onFailure`](https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails) is unset:

210 214 

211* **`the hook failed`**: on a call from Claude's code, your hook couldn't start, was killed, exited with 126, 127, or a code above 128, or returned an HTTP error or invalid output. Fix the hook215* **`the hook failed`**: on a call from code, your hook couldn't start, was killed, exited with 126, 127, or a code above 128, or returned an HTTP error or invalid output. Fix the hook

212* **`the hook did not finish`**: your hook timed out on a call from Claude's code, or on any other tool call once Claude has run code in the session. Raise the hook's [`timeout`](https://code.claude.com/docs/en/hooks#common-fields)216* **`the hook did not finish`**: your hook timed out on a call from code, or on any other tool call once Claude has run code in the session. Raise the hook's [`timeout`](https://code.claude.com/docs/en/hooks#common-fields)

213 217 

214To let calls go ahead when a `command` or `http` hook fails or times out, set `"onFailure": "continue"` on it. If a `command` hook exits with an ordinary code such as 1, the call goes ahead unless you set `"onFailure": "block"`.218To let calls go ahead when a `command` or `http` hook fails or times out, set `"onFailure": "continue"` on it. If a `command` hook exits with an ordinary code such as 1, the call goes ahead unless you set `"onFailure": "block"`.

215 219 

216### Code output withheld by a hook220### Code output withheld by a hook

217 221 

218If Claude reports a hook's block reason where you expected output from Claude's code, check your [`UserPromptSubmit`](https://code.claude.com/docs/en/hooks#userpromptsubmit) hooks. When [code can run in the background](#long-running-code), `command`, `http`, and `mcp_tool` hooks on that event also run on code output. To let the output through, change the hook so that it doesn't block when `source` in its input is `poll_event`.222If Claude reports a hook's block reason where you expected output from code, check your [`UserPromptSubmit`](https://code.claude.com/docs/en/hooks#userpromptsubmit) hooks. When [code can run in the background](#long-running-code), `command`, `http`, and `mcp_tool` hooks on that event also run on code output. To let the output through, change the hook so that it doesn't block when `source` in its input is `poll_event`.

219 223 

220## Related resources224## Related resources

221 225 

commands.md +1 −1

Details

145| `/skills` | List available [skills](https://code.claude.com/docs/en/skills.md). Type to filter the list by name, description, or source. Press `t` to sort by token count, `Space` or `Enter` to [cycle a skill's visibility to Claude and the `/` menu](https://code.claude.com/docs/en/skills#override-skill-visibility-from-settings), and `Esc` to save and close. You can't cycle plugin skills, skills whose frontmatter sets `disable-model-invocation: true`, or skills with a `skillOverrides` entry in managed settings or the `--settings` flag |145| `/skills` | List available [skills](https://code.claude.com/docs/en/skills.md). Type to filter the list by name, description, or source. Press `t` to sort by token count, `Space` or `Enter` to [cycle a skill's visibility to Claude and the `/` menu](https://code.claude.com/docs/en/skills#override-skill-visibility-from-settings), and `Esc` to save and close. You can't cycle plugin skills, skills whose frontmatter sets `disable-model-invocation: true`, or skills with a `skillOverrides` entry in managed settings or the `--settings` flag |

146| `/slides [brief]` | **[Skill](https://code.claude.com/docs/en/skills.md#bundled-skills).** Make a new presentation as a Claude Slides [artifact](https://code.claude.com/docs/en/artifacts.md#make-a-slide-deck) filled from your brief, for example `/slides a quarterly review of the platform team`. Requires Claude Code v2.1.265 or later, a session where [artifacts are available](https://code.claude.com/docs/en/artifacts.md#availability), and an account where the [Slides template is available](https://code.claude.com/docs/en/artifacts.md#start-from-a-slides-design-or-docs-template); otherwise the command doesn't appear. Available on the Anthropic API. On Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry, and Claude Platform on AWS, artifacts aren't available, so the command is unavailable there |146| `/slides [brief]` | **[Skill](https://code.claude.com/docs/en/skills.md#bundled-skills).** Make a new presentation as a Claude Slides [artifact](https://code.claude.com/docs/en/artifacts.md#make-a-slide-deck) filled from your brief, for example `/slides a quarterly review of the platform team`. Requires Claude Code v2.1.265 or later, a session where [artifacts are available](https://code.claude.com/docs/en/artifacts.md#availability), and an account where the [Slides template is available](https://code.claude.com/docs/en/artifacts.md#start-from-a-slides-design-or-docs-template); otherwise the command doesn't appear. Available on the Anthropic API. On Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry, and Claude Platform on AWS, artifacts aren't available, so the command is unavailable there |

147| `/stats` | Alias for `/usage`. Opens on the Stats tab |147| `/stats` | Alias for `/usage`. Opens on the Stats tab |

148| `/status` | Open the Settings interface on the Status tab, showing version, model, account, and connectivity. A `Session kind` row reads `background job · attached` or `background job · unattended` in a [background session](https://code.claude.com/docs/en/agent-view.md), depending on whether a terminal is attached, and `interactive` in any other session. Before v2.1.221, `/status` didn't show this row. Works while Claude is responding |148| `/status` | Open the Settings interface on the Status tab, showing version, model, account, and connectivity. A `Session kind` row reads `background job · attached` or `background job · unattended` in a [background session](https://code.claude.com/docs/en/agent-view.md), depending on whether a terminal is attached, and `interactive` in any other session. Works while Claude is responding |

149| `/statusline` | Configure Claude Code's [status line](https://code.claude.com/docs/en/statusline.md). Describe what you want, or run without arguments to auto-configure from your shell prompt |149| `/statusline` | Configure Claude Code's [status line](https://code.claude.com/docs/en/statusline.md). Describe what you want, or run without arguments to auto-configure from your shell prompt |

150| `/stickers` | Check Claude Code sticker availability |150| `/stickers` | Check Claude Code sticker availability |

151| `/stop` | Stop the [background session](https://code.claude.com/docs/en/agent-view.md) you're attached to, or the one you send it to as a [peek reply](https://code.claude.com/docs/en/agent-view.md#peek-and-reply); the transcript and any worktree are kept. To detach without stopping, use `/exit` or press `←` |151| `/stop` | Stop the [background session](https://code.claude.com/docs/en/agent-view.md) you're attached to, or the one you send it to as a [peek reply](https://code.claude.com/docs/en/agent-view.md#peek-and-reply); the transcript and any worktree are kept. To detach without stopping, use `/exit` or press `←` |

costs.md +1 −1

Details

20>20>

21> The Session block in `/usage` shows API token usage and is intended for API users. Claude Pro, Max, and Ultra subscribers have usage included in their subscription, so the session cost figure isn't relevant for billing purposes. Subscribers see plan usage bars, activity stats, and a usage breakdown on the same screen.21> The Session block in `/usage` shows API token usage and is intended for API users. Claude Pro, Max, and Ultra subscribers have usage included in their subscription, so the session cost figure isn't relevant for billing purposes. Subscribers see plan usage bars, activity stats, and a usage breakdown on the same screen.

22 22 

23The Session block at the top of `/usage` shows detailed token usage statistics for your current session.23Run `/usage` at the Claude Code prompt and look under the **Session** heading for your current session's token usage.

24 24 

25Claude Code computes the dollar figure locally from token counts at list price, unless a [`modelPricing`](https://code.claude.com/docs/en/settings-reference#modelpricing) table is in effect. An administrator sets one in your organization's managed settings so the figure uses your contracted rates, and while a table is in effect the `Total cost` line carries the note `at your organization's configured rates`. The figure is an estimate, so for authoritative billing see [Manage costs for your organization](#manage-costs-for-your-organization).25Claude Code computes the dollar figure locally from token counts at list price, unless a [`modelPricing`](https://code.claude.com/docs/en/settings-reference#modelpricing) table is in effect. An administrator sets one in your organization's managed settings so the figure uses your contracted rates, and while a table is in effect the `Total cost` line carries the note `at your organization's configured rates`. The figure is an estimate, so for authoritative billing see [Manage costs for your organization](#manage-costs-for-your-organization).

26 26 

Details

22* A Mac, since Apple's iOS Simulator runs only on macOS22* A Mac, since Apple's iOS Simulator runs only on macOS

23* [Xcode](https://developer.apple.com/xcode/) with the iOS platform installed, which provides the simulator devices. If Xcode lists no simulators yet, see [The simulator pane says no simulators were found](#the-simulator-pane-says-no-simulators-were-found)23* [Xcode](https://developer.apple.com/xcode/) with the iOS platform installed, which provides the simulator devices. If Xcode lists no simulators yet, see [The simulator pane says no simulators were found](#the-simulator-pane-says-no-simulators-were-found)

24 * Xcode 26.x or Xcode 27 is recommended, and the pane works with either. If you have more than one Xcode installed, see [Choose which Xcode the simulator pane uses](#choose-which-xcode-the-simulator-pane-uses)24 * Xcode 26.x or Xcode 27 is recommended, and the pane works with either. If you have more than one Xcode installed, see [Choose which Xcode the simulator pane uses](#choose-which-xcode-the-simulator-pane-uses)

25 * To test on an iPhone Duo, you need Xcode 27.1 or later. See [Test your app on an iPhone Duo](#test-your-app-on-an-iphone-duo) for what else you need.

25 26 

26> [!NOTE]27> [!NOTE]

27>28>


134 135 

135Claude tells you when either applies.136Claude tells you when either applies.

136 137 

138## Test your app on an iPhone Duo

139 

140You can test your app on an iPhone Duo simulator in the simulator pane and fold the device into each of its poses: closed, half open, and open. To test on one, you need:

141 

142* Claude Desktop v4.29.0 or later, which is newer than the v1.24012.0 that the simulator pane itself requires. To update, open **Claude > Check for Updates…**, then restart the app.

143* Xcode 27.1 or later with its iOS simulator runtime, which includes the iPhone Duo simulator. For Xcode 27.1, that runtime is iOS 27.1. If it's missing, [download it from Xcode's Components settings](https://developer.apple.com/documentation/xcode/downloading-and-installing-additional-xcode-components). If you have more than one Xcode installed, [select Xcode 27.1 or later](#choose-which-xcode-the-simulator-pane-uses).

144 

145To open an iPhone Duo in the pane, name it in your request or [switch the pane to it yourself](#control-the-simulator-yourself). If the device menu doesn't list an iPhone Duo yet, select **Add simulator…** at the end of the list of devices and choose an iPhone Duo device type.

146 

147For example, to have Claude check one screen of your app in each pose:

148 

149```text theme={null}

150Run the app on the iPhone Duo simulator and check the settings screen closed, half open, and open.

151```

152 

153### Fold an iPhone Duo

154 

155* **Fold it yourself**: click one of the three pose buttons next to the rotate button. Hold the pointer over one to see its name: **Closed**, **Half open**, or **Open**. For an angle between those poses, move the pointer over the pose buttons, then drag the slider that appears above them.

156* **Ask Claude to fold it**: ask for one of the three poses, or for a half-open hinge angle from 1 to 179 degrees.

157 

158### Expect a prompt to export Xcode agent skills

159 

160Before a layout check on an iPhone Duo, Claude may ask whether to export Xcode's agent skills to your [personal skills folder](https://code.claude.com/docs/en/skills.md#where-skills-live). These skills come with Xcode to guide coding agents, and once they're in that folder, Claude Code loads them in your other projects too. They include a skill for getting your app's layout ready for the iPhone Duo.

161 

137## Limitations162## Limitations

138 163 

139Claude drives simulated devices only and can't control a physical iPhone or iPad. To test on one, run the app on it from Xcode yourself, then describe what you see or attach a screenshot to the conversation for Claude to work from.164Claude drives simulated devices only and can't control a physical iPhone or iPad. To test on one, run the app on it from Xcode yourself, then describe what you see or attach a screenshot to the conversation for Claude to work from.

env-vars.md +1 −1

Details

329| `CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS` | How many [subagents](https://code.claude.com/docs/en/sub-agents.md#concurrent-subagent-limit) can be running in one session before the Agent tool refuses to spawn another (default: 20). Accepts a positive whole number in plain digits; anything else is ignored, so the variable can adjust the cap but can't disable it. Requires Claude Code v2.1.217 or later |329| `CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS` | How many [subagents](https://code.claude.com/docs/en/sub-agents.md#concurrent-subagent-limit) can be running in one session before the Agent tool refuses to spawn another (default: 20). Accepts a positive whole number in plain digits; anything else is ignored, so the variable can adjust the cap but can't disable it. Requires Claude Code v2.1.217 or later |

330| `CLAUDE_CODE_MAX_CONTEXT_TOKENS` | Override the context window size Claude Code assumes for the active model. As of v2.1.193, how it applies depends on how Claude Code resolves the model ID; see [Correct the window for a gateway or custom model ID](https://code.claude.com/docs/en/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id). Use this when routing to a model through `ANTHROPIC_BASE_URL` whose context window does not match the built-in size for its name |330| `CLAUDE_CODE_MAX_CONTEXT_TOKENS` | Override the context window size Claude Code assumes for the active model. As of v2.1.193, how it applies depends on how Claude Code resolves the model ID; see [Correct the window for a gateway or custom model ID](https://code.claude.com/docs/en/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id). Use this when routing to a model through `ANTHROPIC_BASE_URL` whose context window does not match the built-in size for its name |

331| `CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH` | Maximum length in characters of MCP tool descriptions and MCP server instructions that Claude Code sends to the model. The value you set replaces both [default limits](https://code.claude.com/docs/en/mcp.md#for-mcp-server-authors): 4096, and 16384 for the description of a tool that Claude loads through tool search. Accepts a positive whole number in plain digits. Anything else is ignored and the defaults apply. Requires Claude Code v2.1.280 or later |331| `CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH` | Maximum length in characters of MCP tool descriptions and MCP server instructions that Claude Code sends to the model. The value you set replaces both [default limits](https://code.claude.com/docs/en/mcp.md#for-mcp-server-authors): 4096, and 16384 for the description of a tool that Claude loads through tool search. Accepts a positive whole number in plain digits. Anything else is ignored and the defaults apply. Requires Claude Code v2.1.280 or later |

332| `CLAUDE_CODE_MAX_OUTPUT_TOKENS` | Set the maximum number of output tokens for most requests. Defaults and caps vary by model; see [max output tokens](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison). Claude Code lowers a value above a model's cap to the cap. For a model ID Claude Code can't resolve to a model it knows, the default is 32000 and the cap is 128000. Increasing this value reduces the effective context window available before [auto-compaction](https://code.claude.com/docs/en/costs.md#reduce-token-usage) triggers |332| `CLAUDE_CODE_MAX_OUTPUT_TOKENS` | Set the maximum number of output tokens for most requests. Defaults and caps vary by model; see [max output tokens](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison). Claude Code lowers a value above a model's cap to the cap. For a model ID Claude Code [can't resolve to a model it knows](https://code.claude.com/docs/en/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id), the default is 32000 and the cap is 128000 |

333| `CLAUDE_CODE_MAX_RETRIES` | Override the number of times to retry failed API requests (default: 10). Retrying can stop earlier on `529` overloaded errors. For example, with an API key on an Opus model, it stops at the third `529` and shows [Repeated 529 Overloaded errors](https://code.claude.com/docs/en/errors.md#api-error-repeated-529-overloaded-errors). If you set a [fallback model](https://code.claude.com/docs/en/settings-reference.md#fallbackmodel), Claude Code switches to that model rather than showing the error. Capped at 15 as of v2.1.186; as of v2.1.199, `CLAUDE_CODE_RETRY_WATCHDOG` raises the default and removes the cap. For unattended sessions that need to wait through longer outages, set `CLAUDE_CODE_RETRY_WATCHDOG` instead |333| `CLAUDE_CODE_MAX_RETRIES` | Override the number of times to retry failed API requests (default: 10). Retrying can stop earlier on `529` overloaded errors. For example, with an API key on an Opus model, it stops at the third `529` and shows [Repeated 529 Overloaded errors](https://code.claude.com/docs/en/errors.md#api-error-repeated-529-overloaded-errors). If you set a [fallback model](https://code.claude.com/docs/en/settings-reference.md#fallbackmodel), Claude Code switches to that model rather than showing the error. Capped at 15 as of v2.1.186; as of v2.1.199, `CLAUDE_CODE_RETRY_WATCHDOG` raises the default and removes the cap. For unattended sessions that need to wait through longer outages, set `CLAUDE_CODE_RETRY_WATCHDOG` instead |

334| `CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION` | Removed in v2.1.224 and now a no-op. Previously capped the total number of [subagents](https://code.claude.com/docs/en/sub-agents.md) Claude could spawn with the Agent tool in one session (default: 200); spawning past the cap failed with `Subagent spawn limit reached`. The [concurrent subagent limit](https://code.claude.com/docs/en/sub-agents.md#concurrent-subagent-limit) and the [depth limit](https://code.claude.com/docs/en/sub-agents.md#let-subagents-spawn-their-own-subagents) still apply |334| `CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION` | Removed in v2.1.224 and now a no-op. Previously capped the total number of [subagents](https://code.claude.com/docs/en/sub-agents.md) Claude could spawn with the Agent tool in one session (default: 200); spawning past the cap failed with `Subagent spawn limit reached`. The [concurrent subagent limit](https://code.claude.com/docs/en/sub-agents.md#concurrent-subagent-limit) and the [depth limit](https://code.claude.com/docs/en/sub-agents.md#let-subagents-spawn-their-own-subagents) still apply |

335| `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` | Number of [subagent layers](https://code.claude.com/docs/en/sub-agents.md#let-subagents-spawn-their-own-subagents) allowed below the main conversation (default: 3). At the default, subagents can spawn their own subagents, and a subagent at the third layer can't spawn further; set `1` to turn nesting off. In v2.1.217 through v2.1.218, the default was 1, so a subagent couldn't spawn its own unless you raised the limit; v2.1.219 raised the default to 3. Accepts a positive whole number in plain digits; anything else is ignored, so the limit can be adjusted but not removed. Requires Claude Code v2.1.217 or later |335| `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` | Number of [subagent layers](https://code.claude.com/docs/en/sub-agents.md#let-subagents-spawn-their-own-subagents) allowed below the main conversation (default: 3). At the default, subagents can spawn their own subagents, and a subagent at the third layer can't spawn further; set `1` to turn nesting off. In v2.1.217 through v2.1.218, the default was 1, so a subagent couldn't spawn its own unless you raised the limit; v2.1.219 raised the default to 3. Accepts a positive whole number in plain digits; anything else is ignored, so the limit can be adjusted but not removed. Requires Claude Code v2.1.217 or later |

errors.md +13 −0

Details

407| `Reading a local file from outside this session's connected folders, or through a link, needs the approval card` | [Tool errors](#reading-a-local-file-from-outside-the-connected-folders) |407| `Reading a local file from outside this session's connected folders, or through a link, needs the approval card` | [Tool errors](#reading-a-local-file-from-outside-the-connected-folders) |

408| `cannot read file_path (...) — the file could not be examined, and no one can answer the approval card` | [Tool errors](#reading-a-local-file-from-outside-the-connected-folders) |408| `cannot read file_path (...) — the file could not be examined, and no one can answer the approval card` | [Tool errors](#reading-a-local-file-from-outside-the-connected-folders) |

409| `WebFetch cannot fetch localhost or other hostnames without a dot` | [Tool errors](#webfetch-cannot-fetch-localhost) |409| `WebFetch cannot fetch localhost or other hostnames without a dot` | [Tool errors](#webfetch-cannot-fetch-localhost) |

410| `Claude Code is unable to fetch from ...` | [Tool errors](#claude-code-is-unable-to-fetch-from-a-host) |

410| `The safety check for domain ... is rate-limited` | [Tool errors](#webfetch-domain-safety-check-failed) |411| `The safety check for domain ... is rate-limited` | [Tool errors](#webfetch-domain-safety-check-failed) |

411| `The safety check for domain ... is temporarily rate-limited` | [Tool errors](#webfetch-domain-safety-check-failed) |412| `The safety check for domain ... is temporarily rate-limited` | [Tool errors](#webfetch-domain-safety-check-failed) |

412| `Unable to verify if domain ... is safe to fetch` | [Tool errors](#webfetch-domain-safety-check-failed) |413| `Unable to verify if domain ... is safe to fetch` | [Tool errors](#webfetch-domain-safety-check-failed) |


5434 5435 

5435Before v2.1.268, WebFetch reported these URLs with a generic `Invalid URL` error.5436Before v2.1.268, WebFetch reported these URLs with a generic `Invalid URL` error.

5436 5437 

5438### Claude Code is unable to fetch from a host

5439 

5440WebFetch sends a URL's hostname to `api.anthropic.com` before requesting the page, to check it against Anthropic's domain safety blocklist. This message means the check answered that the hostname can't be fetched:

5441 

5442```text wrap theme={null}

5443Claude Code is unable to fetch from example.com

5444```

5445 

5446Claude Code didn't contact the host, because the check runs before the request.

5447 

5448For what the check sends, see [WebFetch domain safety check](https://code.claude.com/docs/en/data-usage.md#webfetch-domain-safety-check).

5449 

5437### WebFetch domain safety check failed5450### WebFetch domain safety check failed

5438 5451 

5439Before fetching a URL, WebFetch sends the URL's hostname to `api.anthropic.com` to check it against Anthropic's [domain safety blocklist](https://code.claude.com/docs/en/data-usage.md#webfetch-domain-safety-check). If the check can't complete, WebFetch can't confirm that the domain is safe, so it doesn't fetch the page and the tool result carries one of these messages instead:5452Before fetching a URL, WebFetch sends the URL's hostname to `api.anthropic.com` to check it against Anthropic's [domain safety blocklist](https://code.claude.com/docs/en/data-usage.md#webfetch-domain-safety-check). If the check can't complete, WebFetch can't confirm that the domain is safe, so it doesn't fetch the page and the tool result carries one of these messages instead:

fullscreen.md +5 −5

Details

159 159 

160On a terminal too narrow for the full label, the button shortens the hint instead of wrapping onto the transcript row underneath.160On a terminal too narrow for the full label, the button shortens the hint instead of wrapping onto the transcript row underneath.

161 161 

162To turn auto-follow off entirely so the view stays where you leave it, open `/config` and set Auto-scroll to off. With auto-scroll disabled, the view never jumps to the bottom on its own. Permission prompts and other dialogs that need a response still scroll into view regardless of this setting.162#### Turn off Auto-scroll

163 

164To keep auto-follow paused after you send a message or scroll to the bottom, open `/config` and set [Auto-scroll](https://code.claude.com/docs/en/settings-reference.md#autoscrollenabled) to off.

163 165 

164### Mouse wheel scrolling166### Mouse wheel scrolling

165 167 


221 223 

222If the display looks garbled or partially blank, press `Ctrl+L` to redraw the screen. The redraw keeps the conversation and your input in place.224If the display looks garbled or partially blank, press `Ctrl+L` to redraw the screen. The redraw keeps the conversation and your input in place.

223 225 

224`Cmd+K` does the same as `Ctrl+L` when your terminal passes it through to Claude Code. iTerm2 and Terminal.app handle `Cmd+K` themselves and clear their own screen, and Claude Code detects the cleared screen and repaints the conversation. Before v2.1.280, starting with v2.1.260, pressing `Ctrl+L`, or `Cmd+K` where it reaches Claude Code, cleared the screen in fullscreen rendering. Before v2.1.238, pressing `Ctrl+L` twice within two seconds ran `/clear`.226`Cmd+K` does the same as `Ctrl+L` when your terminal passes it through to Claude Code. iTerm2 handles `Cmd+K` itself and clears its own screen, and Claude Code detects the cleared screen and repaints the conversation. Before v2.1.280, starting with v2.1.260, pressing `Ctrl+L`, or `Cmd+K` where it reaches Claude Code, cleared the screen in fullscreen rendering. Before v2.1.238, pressing `Ctrl+L` twice within two seconds ran `/clear`.

225 227 

226## Use with tmux228## Use with tmux

227 229 

228Fullscreen rendering works inside tmux, with three caveats.230Fullscreen rendering works inside tmux, with three caveats.

229 231 

230Mouse wheel scrolling requires tmux's mouse mode. If your `~/.tmux.conf` doesn't already enable it, add this line and reload your config:232To scroll Claude Code with the mouse wheel while another tmux pane is active, turn on tmux's mouse mode in `~/.tmux.conf` and reload your config:

231 233 

232```bash theme={null}234```bash theme={null}

233set -g mouse on235set -g mouse on

234```236```

235 237 

236Without mouse mode, wheel events go to tmux instead of Claude Code. Keyboard scrolling with `PgUp` and `PgDn` works either way. Claude Code prints a one-time hint at startup if it detects tmux with mouse mode off.

237 

238Fullscreen rendering is incompatible with iTerm2's tmux integration mode, which is the mode you enter with `tmux -CC`. In integration mode, iTerm2 renders each tmux pane as a native split rather than letting tmux draw to the terminal. The alternate screen buffer and mouse tracking don't work correctly there: the mouse wheel does nothing, and double-click can corrupt the terminal state. Don't enable fullscreen rendering in `tmux -CC` sessions. Regular tmux inside iTerm2, without `-CC`, works fine.238Fullscreen rendering is incompatible with iTerm2's tmux integration mode, which is the mode you enter with `tmux -CC`. In integration mode, iTerm2 renders each tmux pane as a native split rather than letting tmux draw to the terminal. The alternate screen buffer and mouse tracking don't work correctly there: the mouse wheel does nothing, and double-click can corrupt the terminal state. Don't enable fullscreen rendering in `tmux -CC` sessions. Regular tmux inside iTerm2, without `-CC`, works fine.

239 239 

240tmux releases through the 3.6 series don't implement synchronized output, so under those versions you may see more flicker during redraws than when running Claude Code directly in your terminal. Claude Code probes the terminal for synchronized-output support at startup and uses it when the terminal reports it. If you see flicker under tmux, upgrade to the newest tmux or run Claude Code in its own terminal tab outside tmux.240tmux releases through the 3.6 series don't implement synchronized output, so under those versions you may see more flicker during redraws than when running Claude Code directly in your terminal. Claude Code probes the terminal for synchronized-output support at startup and uses it when the terminal reports it. If you see flicker under tmux, upgrade to the newest tmux or run Claude Code in its own terminal tab outside tmux.

Details

165 165 

166* **Use a full git URL.** The `owner/repo` shorthand always resolves to github.com and cannot reference a GHES host.166* **Use a full git URL.** The `owner/repo` shorthand always resolves to github.com and cannot reference a GHES host.

167* **Prefer HTTPS URLs.** SSH clones fail on machines that do not already trust your GHES host key. An HTTPS URL with your organization's standard git credential helper works on any machine with credentials configured.167* **Prefer HTTPS URLs.** SSH clones fail on machines that do not already trust your GHES host key. An HTTPS URL with your organization's standard git credential helper works on any machine with credentials configured.

168* **Confirm each machine can clone from your GHES host.** If a machine lacks credentials, the marketplace is registered but never installed, and its plugins report as not found instead of prompting for credentials.168* **Confirm each machine can clone from your GHES host.** If a machine lacks credentials, the clone fails without prompting for them, and the `/plugin` **Errors** tab shows why.

169* **Confirm the setting reaches each machine.** A managed settings file only takes effect on machines it's deployed to, for example through your device management system. See [Deploy managed settings](https://code.claude.com/docs/en/managed-settings.md#delivery-mechanisms) for file locations.169* **Confirm the setting reaches each machine.** A managed settings file only takes effect on machines it's deployed to, for example through your device management system. See [Deploy managed settings](https://code.claude.com/docs/en/managed-settings.md#delivery-mechanisms) for file locations.

170 170 

171### Allowlist GHES marketplaces in managed settings171### Allowlist GHES marketplaces in managed settings

glossary.md +2 −2

Details

331 331 

332### System reminder332### System reminder

333 333 

334A message that Claude Code, as the [harness](#agentic-harness), adds to the conversation to give Claude context. You don't send system reminders yourself. Claude Code inserts them as a session runs, for example when the session starts, when a hook returns text, or when a file changes on disk. Claude reads them alongside your messages. The following all reach Claude as system reminders:334A message that Claude Code, as the [harness](#agentic-harness), adds to the conversation to give Claude context. You don't send system reminders yourself. Claude Code inserts them as a session runs, for example when the session starts or when a hook returns text. Claude reads them alongside your messages. The following all reach Claude as system reminders:

335 335 

336* Your [CLAUDE.md](#claude-md) files336* Your [CLAUDE.md](#claude-md) files

337* The instructions of your [output style](#output-style)337* The instructions of your [output style](#output-style)

338* Text a [hook](#hook) returns as `additionalContext`338* Text a [hook](#hook) returns as `additionalContext`

339* The list of available [skills](#skill)339* The list of available [skills](#skill)

340* A note that a file Claude read earlier has changed on disk340* A note that a file Claude edited earlier has since changed on disk

341* The commit and pull request attribution lines341* The commit and pull request attribution lines

342 342 

343In a logged API request, a system reminder appears wrapped in `<system-reminder>` tags inside a user message, or on some models as a separate message with the `system` role.343In a logged API request, a system reminder appears wrapped in `<system-reminder>` tags inside a user message, or on some models as a separate message with the `system` role.

headless.md +1 −1

Details

63Bare mode also limits what happens while the session runs:63Bare mode also limits what happens while the session runs:

64 64 

65* **MCP servers**: only servers supplied on the command line connect, for example with `--mcp-config`. In an interactive session, Claude Code also skips the automatic IDE connection unless you pass `--ide`.65* **MCP servers**: only servers supplied on the command line connect, for example with `--mcp-config`. In an interactive session, Claude Code also skips the automatic IDE connection unless you pass `--ide`.

66* **System reminders**: Claude gets your prompts and the tool results without the [system reminders](https://code.claude.com/docs/en/glossary.md#system-reminder) Claude Code would add alongside them. For example, Claude isn't told when a file it read earlier changes on disk, and it doesn't get the list of available skills, including skills from an `--add-dir` folder.66* **System reminders**: Claude receives your prompts and the tool results without the [system reminders](https://code.claude.com/docs/en/glossary.md#system-reminder) Claude Code would add alongside them. For example, Claude isn't told when a file it edited earlier changes on disk, and it doesn't get the list of available skills, including skills from an `--add-dir` folder.

67* **Background tasks**: Claude can't run background commands or background subagents, and the other features that [`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`](https://code.claude.com/docs/en/env-vars) turns off are off too. A command that reaches its [timeout](https://code.claude.com/docs/en/tools-reference.md#timeout-and-output-limits) stops instead of [moving to the background](https://code.claude.com/docs/en/tools-reference.md#background-commands).67* **Background tasks**: Claude can't run background commands or background subagents, and the other features that [`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`](https://code.claude.com/docs/en/env-vars) turns off are off too. A command that reaches its [timeout](https://code.claude.com/docs/en/tools-reference.md#timeout-and-output-limits) stops instead of [moving to the background](https://code.claude.com/docs/en/tools-reference.md#background-commands).

68 68 

69Before v2.1.286, these limits held only partly: an interactive `--bare` session connected the MCP servers that a normal session would, every `--bare` session sent system reminders, and background tasks stayed available.69Before v2.1.286, these limits held only partly: an interactive `--bare` session connected the MCP servers that a normal session would, every `--bare` session sent system reminders, and background tasks stayed available.

hooks.md +25 −21

Details

303| `CwdChanged` | no matcher support | always fires on every occurrence |303| `CwdChanged` | no matcher support | always fires on every occurrence |

304| `DirectoryAdded` | how the directory was added | `slash_command`, `register_repo_root` |304| `DirectoryAdded` | how the directory was added | `slash_command`, `register_repo_root` |

305| `FileChanged` | literal filenames to watch (see [FileChanged](#filechanged)) | `.envrc\|.env` |305| `FileChanged` | literal filenames to watch (see [FileChanged](#filechanged)) | `.envrc\|.env` |

306| `StopFailure` | error type | `rate_limit`, `overloaded`, `authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `billing_error`, `invalid_request`, `model_not_found`, `server_error`, `max_output_tokens`, `cloud_credential_error`, `unknown` |306| `StopFailure` | error type | `rate_limit`, `authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `billing_error`, `invalid_request`, `model_not_found`, `server_error`, `max_output_tokens`, `cloud_credential_error`, `unknown` |

307| `InstructionsLoaded` | load reason | `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact` |307| `InstructionsLoaded` | load reason | `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact` |

308| `UserPromptExpansion` | command name | your skill or command names |308| `UserPromptExpansion` | command name | your skill or command names |

309| `Elicitation` | MCP server name | your configured MCP server names |309| `Elicitation` | MCP server name | your configured MCP server names |


807 807 

808| Stdout | Exit 0 | Exit 2 | Any other exit code |808| Stdout | Exit 0 | Exit 2 | Any other exit code |

809| :- | :- | :- | :- |809| :- | :- | :- | :- |

810| JSON object that passes [schema validation](#json-output) | Success. The fields apply | Blocking error. Claude Code still reads the fields, but they can't override the block | Success. Claude Code ignores the exit code, and the fields alone decide. For hooks [whose failure blocks the action](#block-the-action-when-a-hook-fails), the run counts as a failure instead |810| JSON object that passes [schema validation](#json-output) | Success. The fields apply | Blocking error. Claude Code still reads the fields, but a `PreToolUse` call stays blocked even if you return `"allow"` or `continue: false`. For other events, see [Exit code 2](#exit-code-2) | Success. Claude Code ignores the exit code, and the fields alone decide. For hooks [whose failure blocks the action](#block-the-action-when-a-hook-fails), the run counts as a failure instead |

811| JSON that [can't be parsed](#exit-code-0) or fails schema validation | Non-blocking error. The notice carries the parse or validation message | Blocking error. Your stderr is the reason | Non-blocking error. The notice carries the parse or validation message |811| JSON that [can't be parsed](#exit-code-0) or fails schema validation | Non-blocking error. The notice carries the parse or validation message | Blocking error. Your stderr is the reason | Non-blocking error. The notice carries the parse or validation message |

812| [Plain text](#exit-code-0), or nothing | Success | Blocking error. Your stderr is the reason | Non-blocking error. The notice carries the first line of your stderr |812| [Plain text](#exit-code-0), or nothing | Success | Blocking error. Your stderr is the reason | Non-blocking error. The notice carries the first line of your stderr |

813 813 


844 844 

845The message that comes with the block is your hook's stderr. If your hook also printed JSON that makes a blocking decision, Claude Code uses that decision's reason instead.845The message that comes with the block is your hook's stderr. If your hook also printed JSON that makes a blocking decision, Claude Code uses that decision's reason instead.

846 846 

847Exit 2 blocks even when your hook prints JSON:847Exit code 2 still blocks with most JSON your hook prints:

848 848 

849* **JSON that passes schema validation**: Claude Code still reads the [JSON output](#json-output) fields, but they can't override the block. Even a `permissionDecision` of `"allow"` doesn't let the action through. On `Elicitation` and `ElicitationResult`, an exit-2 hook's `hookSpecificOutput` is ignored.849* **JSON that sets `continue: false`**: on events such as `Stop` and `SubagentStop`, the field takes precedence over exit code 2, so Claude or the subagent ends its turn. To keep Claude or the subagent working, leave the field out. On `PreToolUse`, the tool call stays blocked with or without the field.

850* **Other JSON that passes schema validation**: Claude Code still reads the [JSON output](#json-output) fields. Even a `permissionDecision` of `"allow"` doesn't let the action through. On `Elicitation` and `ElicitationResult`, an exit-2 hook's `hookSpecificOutput` is ignored.

850* **JSON that fails schema validation**: the hook still blocks. Claude Code uses your stderr as the blocking reason and records the validation failure in the debug log.851* **JSON that fails schema validation**: the hook still blocks. Claude Code uses your stderr as the blocking reason and records the validation failure in the debug log.

851 852 

852This script blocks `rm` commands by exiting 2 and leaves every other command to the normal permission flow:853This script blocks `rm` commands by exiting 2 and leaves every other command to the normal permission flow:


1022 1023 

1023Exit code 2 is the way a hook signals "stop, don't do this." The effect depends on the event, because some events represent actions that can be blocked (like a tool call that hasn't happened yet) and others represent things that already happened or can't be prevented.1024Exit code 2 is the way a hook signals "stop, don't do this." The effect depends on the event, because some events represent actions that can be blocked (like a tool call that hasn't happened yet) and others represent things that already happened or can't be prevented.

1024 1025 

1026If your hook exits 2 and also sets `continue: false`, check [Exit code 2](#exit-code-2) first, because the result can differ from your event's row.

1027 

1025| Hook event | Can block? | What happens on exit 2 |1028| Hook event | Can block? | What happens on exit 2 |

1026| :- | :- | :- |1029| :- | :- | :- |

1027| `PreToolUse` | Yes | Blocks the tool call |1030| `PreToolUse` | Yes | Blocks the tool call |


1079 1082 

1080> [!NOTE]1083> [!NOTE]

1081>1084>

1082> Choose one approach per hook: either use exit codes alone for signaling, or exit 0 and print JSON for structured control. If you mix them, exit 2 keeps its [blocking effect](#exit-code-2-behavior-per-event), and Claude Code still reads the JSON fields, with the one elicitation exception noted under [Exit code 2](#exit-code-2).1085> Choose one approach per hook: either use exit codes alone for signaling, or exit 0 and print JSON for structured control. For what happens when you mix them, see [Exit code output](#exit-code-output).

1083 1086 

1084Print nothing but the JSON object to stdout. For a hook that isn't [async](#how-async-hooks-execute), other text there, such as a line your shell profile echoes at startup, keeps Claude Code from reading the object as JSON, and [Hook JSON has no effect](https://code.claude.com/docs/en/hooks-guide.md#hook-json-has-no-effect) shows how to find and silence that text.1087Print nothing but the JSON object to stdout. For a hook that isn't [async](#how-async-hooks-execute), other text there, such as a line your shell profile echoes at startup, keeps Claude Code from reading the object as JSON, and [Hook JSON has no effect](https://code.claude.com/docs/en/hooks-guide.md#hook-json-has-no-effect) shows how to find and silence that text.

1085 1088 


1200| Events | Decision pattern | Key fields |1203| Events | Decision pattern | Key fields |

1201| :- | :- | :- |1204| :- | :- | :- |

1202| UserPromptSubmit, UserPromptExpansion, PostToolUse, PostToolUseFailure, PostToolBatch, Stop, SubagentStop, ConfigChange, PreCompact | Top-level `decision` | `decision: "block"`, `reason`. Stop and SubagentStop also accept `hookSpecificOutput.additionalContext` for [non-error feedback that continues the conversation](#stop-decision-control) |1205| UserPromptSubmit, UserPromptExpansion, PostToolUse, PostToolUseFailure, PostToolBatch, Stop, SubagentStop, ConfigChange, PreCompact | Top-level `decision` | `decision: "block"`, `reason`. Stop and SubagentStop also accept `hookSpecificOutput.additionalContext` for [non-error feedback that continues the conversation](#stop-decision-control) |

1203| TeammateIdle, TaskCompleted | Exit code or `continue: false` | Exit code 2 blocks the action with stderr feedback. JSON `{"continue": false, "stopReason": "..."}` also stops the teammate entirely, matching `Stop` hook behavior; [TaskCompleted ignores it when the `TaskUpdate` tool triggered the event](#taskcompleted-decision-control) |1206| TeammateIdle, TaskCompleted | Exit code or top-level `decision` | Exit code 2 or `decision: "block"` keeps the teammate working or the task open. With `continue: false`, the teammate goes idle. [Claude Code ignores `continue: false` on a `TaskUpdate` call](#taskcompleted-decision-control) |

1204| TaskCreated | Exit code or top-level `decision` | Exit code 2 or `decision: "block"` [cancels the task](#taskcreated-decision-control) and returns the message to Claude. `continue: false` is ignored |1207| TaskCreated | Exit code or top-level `decision` | Exit code 2 or `decision: "block"` [cancels the task](#taskcreated-decision-control) and returns the message to Claude. `continue: false` is ignored |

1205| PreToolUse | `hookSpecificOutput` | `permissionDecision` (allow/deny/ask/defer), `permissionDecisionReason` |1208| PreToolUse | `hookSpecificOutput` | `permissionDecision` (allow/deny/ask/defer), `permissionDecisionReason` |

1206| PreModelSwitch | `hookSpecificOutput` or top-level `decision` | `permissionDecision` (allow/deny/ask), `permissionDecisionReason`. `decision: "block"` also [cancels the switch](#premodelswitch-decision-control) |1209| PreModelSwitch | `hookSpecificOutput` or top-level `decision` | `permissionDecision` (allow/deny/ask), `permissionDecisionReason`. `decision: "block"` also [cancels the switch](#premodelswitch-decision-control) |


1520* A [session-scoped scheduled task](https://code.claude.com/docs/en/scheduled-tasks.md) firing, including a `/loop` iteration1523* A [session-scoped scheduled task](https://code.claude.com/docs/en/scheduled-tasks.md) firing, including a `/loop` iteration

1521* A [background subagent](https://code.claude.com/docs/en/sub-agents.md#run-subagents-in-foreground-or-background) reporting back to the session that started it1524* A [background subagent](https://code.claude.com/docs/en/sub-agents.md#run-subagents-in-foreground-or-background) reporting back to the session that started it

1522* A [message another session sends](https://code.claude.com/docs/en/cross-session-messaging.md) to your main conversation1525* A [message another session sends](https://code.claude.com/docs/en/cross-session-messaging.md) to your main conversation

1523* The output of Claude's code in a [Code Mode](https://code.claude.com/docs/en/code-mode.md#code-output-withheld-by-a-hook) session, for `command`, `http`, and `mcp_tool` hooks, when code can run in the background1526* The output of code that Claude runs in a [Code Mode](https://code.claude.com/docs/en/code-mode.md#code-output-withheld-by-a-hook) session, for `command`, `http`, and `mcp_tool` hooks, when code can run in the background

1524 1527 

1525`UserPromptSubmit` hooks have a default timeout of 30 seconds for `command`, `http`, and `mcp_tool` types, shorter than the 600-second default for those types on most other events. Because this hook runs before every prompt and blocks model processing until it completes, a stuck hook stalls the session. If your hook needs more time, set the `timeout` field in the hook entry.1528`UserPromptSubmit` hooks have a default timeout of 30 seconds for `command`, `http`, and `mcp_tool` types, shorter than the 600-second default for those types on most other events. Because this hook runs before every prompt and blocks model processing until it completes, a stuck hook stalls the session. If your hook needs more time, set the `timeout` field in the hook entry.

1526 1529 


1605 1608 

1606#### UserPromptExpansion input1609#### UserPromptExpansion input

1607 1610 

1608In addition to the [common input fields](#common-input-fields), UserPromptExpansion hooks receive `expansion_type`, `command_name`, `command_args`, `command_source`, and the original `prompt` string. The `expansion_type` field is `slash_command` for skill and custom commands, or `mcp_prompt` for MCP server prompts.1611In addition to the [common input fields](#common-input-fields), UserPromptExpansion hooks receive `expansion_type`, `command_name`, `command_args`, `command_source`, and the `prompt` string. The `expansion_type` field is `slash_command` for skill and custom commands, or `mcp_prompt` for MCP server prompts.

1609 1612 

1610```json theme={null}1613```json theme={null}

1611{1614{


1615 "permission_mode": "default",1618 "permission_mode": "default",

1616 "hook_event_name": "UserPromptExpansion",1619 "hook_event_name": "UserPromptExpansion",

1617 "expansion_type": "slash_command",1620 "expansion_type": "slash_command",

1618 "command_name": "example-skill",1621 "command_name": "my-plugin:example-skill",

1619 "command_args": "arg1 arg2",1622 "command_args": "arg1 arg2",

1620 "command_source": "plugin",1623 "command_source": "plugin",

1621 "prompt": "/example-skill arg1 arg2"1624 "prompt": "/my-plugin:example-skill arg1 arg2"

1622}1625}

1623```1626```

1624 1627 


2633 "cwd": "/Users/...",2636 "cwd": "/Users/...",

2634 "hook_event_name": "Notification",2637 "hook_event_name": "Notification",

2635 "message": "Claude needs your permission",2638 "message": "Claude needs your permission",

2636 "title": "Permission needed",

2637 "notification_type": "permission_prompt"2639 "notification_type": "permission_prompt"

2638}2640}

2639```2641```


2804 2806 

2805#### TaskCompleted decision control2807#### TaskCompleted decision control

2806 2808 

2807TaskCompleted hooks support two ways to control task completion:2809With a TaskCompleted hook, you can keep the task open or let a teammate go idle:

2808 2810 

2809* **Exit code 2**: the task is not marked as completed and the stderr message is fed back to the model as feedback.2811* **Exit code 2**: the task is not marked as completed and the stderr message is fed back to the model as feedback.

2810* **JSON `{"continue": false, "stopReason": "..."}`**: when a teammate finishing its turn triggered the event, stops the teammate entirely, matching `Stop` hook behavior. The `stopReason` is shown to the user. When the `TaskUpdate` tool triggered the event, Claude Code ignores `continue: false`; exit code 2 still blocks the completion.2812* **JSON `{"decision": "block", "reason": "..."}`**: the task stays open. Claude receives `reason` and keeps working.

2813* **JSON `{"continue": false, "stopReason": "..."}`**: at the end of a teammate's turn, the teammate goes idle with the task still in progress, even if another of your TaskCompleted hooks blocks. The `stopReason` appears in the teammate's transcript. On a `TaskUpdate` call, Claude Code ignores `continue: false`.

2811 2814 

2812This example runs tests and blocks task completion if they fail:2815This example runs tests and blocks task completion if they fail:

2813 2816 


2939 2942 

2940| Field | Description |2943| Field | Description |

2941| :- | :- |2944| :- | :- |

2942| `error` | Error type: `rate_limit`, `overloaded`, `authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `billing_error`, `invalid_request`, `model_not_found`, `server_error`, `max_output_tokens`, `cloud_credential_error`, or `unknown` |2945| `error` | Error type: `rate_limit`, `authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `billing_error`, `invalid_request`, `model_not_found`, `server_error`, `max_output_tokens`, `cloud_credential_error`, or `unknown`. For an HTTP `529` overloaded response, the value is `server_error` |

2943| `error_details` | Additional details about the error, when available |2946| `error_details` | Additional details about the error, when available |

2944| `last_assistant_message` | The rendered error text shown in the conversation. Unlike `Stop` and `SubagentStop`, where this field holds Claude's conversational output, for `StopFailure` it contains the API error string itself, such as `"API Error: Rate limit reached"` |2947| `last_assistant_message` | The rendered error text shown in the conversation. Unlike `Stop` and `SubagentStop`, where this field holds Claude's conversational output, for `StopFailure` it contains the API error string itself, such as `"API Error: Rate limit reached"` |

2945 2948 


2987 2990 

2988#### TeammateIdle decision control2991#### TeammateIdle decision control

2989 2992 

2990TeammateIdle hooks support two ways to control teammate behavior:2993With a TeammateIdle hook, you can keep the teammate working or let it go idle:

2991 2994 

2992* **Exit code 2**: the teammate receives the stderr message as feedback and continues working instead of going idle.2995* **Exit code 2**: the teammate receives the stderr message as feedback and continues working.

2993* **JSON `{"continue": false, "stopReason": "..."}`**: stops the teammate entirely, matching `Stop` hook behavior. The `stopReason` is shown to the user.2996* **JSON `{"decision": "block", "reason": "..."}`**: the teammate receives `reason` and continues working.

2997* **JSON `{"continue": false, "stopReason": "..."}`**: the teammate [goes idle](https://code.claude.com/docs/en/agent-teams.md#start-your-first-agent-team) even if another of your TeammateIdle hooks blocks. The `stopReason` appears in the teammate's transcript.

2994 2998 

2995This example checks that a build artifact exists before allowing a teammate to go idle:2999This example checks that a build artifact exists before allowing a teammate to go idle:

2996 3000 


3889> }3893> }

3890> ```3894> ```

3891 3895 

3892To confirm the hook works, start Claude Code with `claude --debug` and give Claude a task that makes the server ask for the project key. No dialog appears, and the [debug log](#debug-hooks) has a line that ends with `Elicitation resolved by hook: {"action":"accept","content":{"project_key":"DOCS"}}`.3896To confirm the hook works, start Claude Code with `claude --debug` and give Claude a task that makes the server ask for the project key. No dialog appears, and the [debug log](#debug-hooks) has a line that contains `Elicitation resolved by hook:` and `accept`.

3893 3897 

3894### ElicitationResult3898### ElicitationResult

3895 3899 


4011* `WorktreeCreate`4015* `WorktreeCreate`

4012* `WorktreeRemove`4016* `WorktreeRemove`

4013 4017 

4014`SessionStart` and `Setup` support `command` and `mcp_tool` hooks, and [MCP tool hook fields](#mcp-tool-hook-fields) describes when their `mcp_tool` hooks run. They don't support `http`, `prompt`, or `agent` hooks.4018`Setup` supports only `command` hooks. `SessionStart` supports only `command` and `mcp_tool` hooks, and [MCP tool hook fields](#mcp-tool-hook-fields) describes when its `mcp_tool` hooks run.

4015 4019 

4016### How prompt-based hooks work4020### How prompt-based hooks work

4017 4021 


4079* `PostToolUse`: by default the turn ends and the reason appears in the chat as a warning line. Set `continueOnBlock: true` to feed the reason back to Claude and continue the turn instead4083* `PostToolUse`: by default the turn ends and the reason appears in the chat as a warning line. Set `continueOnBlock: true` to feed the reason back to Claude and continue the turn instead

4080* `PostToolBatch`, `UserPromptSubmit`, and `UserPromptExpansion`: the turn ends and the reason appears as a warning line. These events end the turn on `decision: "block"` regardless of `continue`4084* `PostToolBatch`, `UserPromptSubmit`, and `UserPromptExpansion`: the turn ends and the reason appears as a warning line. These events end the turn on `decision: "block"` regardless of `continue`

4081* `PostToolUseFailure` and `TaskCreated`: the reason is returned to Claude as a tool error and the turn continues, regardless of `continueOnBlock`4085* `PostToolUseFailure` and `TaskCreated`: the reason is returned to Claude as a tool error and the turn continues, regardless of `continueOnBlock`

4082* `TaskCompleted`: when it fires because a task is marked completed during a turn, the reason is returned to Claude as a tool error and the turn continues, regardless of `continueOnBlock`. When it fires because a teammate stops, it behaves like `TeammateIdle` and halts the teammate by default4086* `TaskCompleted` on a `TaskUpdate` call: Claude receives the reason as the tool result and the turn continues, regardless of `continueOnBlock`

4083* `TeammateIdle`: by default the teammate stops and the reason appears as a warning line. Set `continueOnBlock: true` to feed the reason back to the teammate and keep it working instead4087* `TeammateIdle`, and `TaskCompleted` at the end of a teammate's turn: by default the teammate goes idle and the reason appears in its transcript. Set `continueOnBlock: true` to send the reason to the teammate and keep it working

4084* `PermissionRequest`: `ok: false` has no effect. To deny an approval from a hook, use a [command hook](#command-hook-fields) returning `hookSpecificOutput.decision.behavior: "deny"`4088* `PermissionRequest`: `ok: false` has no effect. To deny an approval from a hook, use a [command hook](#command-hook-fields) returning `hookSpecificOutput.decision.behavior: "deny"`

4085* `PermissionDenied`: `ok: false` has no effect because the denial already happened. The only output this event reads is `hookSpecificOutput.retry`, which prompt and agent hooks can't set. They run on this event, but their output is discarded. Use a [command hook](#command-hook-fields) to return `retry`4089* `PermissionDenied`: `ok: false` has no effect because the denial already happened. The only output this event reads is `hookSpecificOutput.retry`, which prompt and agent hooks can't set. They run on this event, but their output is discarded. Use a [command hook](#command-hook-fields) to return `retry`

4086 4090 

hooks-guide.md +1 −1

Details

688| `SubagentStop` | agent type | same values as `SubagentStart` |688| `SubagentStop` | agent type | same values as `SubagentStart` |

689| `ConfigChange` | configuration source | `user_settings`, `project_settings`, `local_settings`, `policy_settings`, `skills` |689| `ConfigChange` | configuration source | `user_settings`, `project_settings`, `local_settings`, `policy_settings`, `skills` |

690| `DirectoryAdded` | how the directory was added | `slash_command`, `register_repo_root` |690| `DirectoryAdded` | how the directory was added | `slash_command`, `register_repo_root` |

691| `StopFailure` | error type | `rate_limit`, `overloaded`, `authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `billing_error`, `invalid_request`, `model_not_found`, `server_error`, `max_output_tokens`, `cloud_credential_error`, `unknown` |691| `StopFailure` | error type | `rate_limit`, `authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `billing_error`, `invalid_request`, `model_not_found`, `server_error`, `max_output_tokens`, `cloud_credential_error`, `unknown` |

692| `InstructionsLoaded` | load reason | `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact` |692| `InstructionsLoaded` | load reason | `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact` |

693| `Elicitation` | MCP server name | your configured MCP server names |693| `Elicitation` | MCP server name | your configured MCP server names |

694| `ElicitationResult` | MCP server name | same values as `Elicitation` |694| `ElicitationResult` | MCP server name | same values as `Elicitation` |

Details

124 124 

125* Your CLAUDE.md files125* Your CLAUDE.md files

126* The instructions of your [output style](https://code.claude.com/docs/en/output-styles.md)126* The instructions of your [output style](https://code.claude.com/docs/en/output-styles.md)

127* A note when a file Claude read earlier changes on disk127* A note that a file Claude edited earlier has since changed on disk

128* The commit and pull request attribution lines128* The commit and pull request attribution lines

129 129 

130To change or remove the attribution lines, set [`attribution`](https://code.claude.com/docs/en/settings-reference#attribution). To remove Claude Code's built-in commit and pull request instructions, set [`includeGitInstructions`](https://code.claude.com/docs/en/settings-reference#includegitinstructions) to `false`. For the other switches, see [Turn off the context your agent replaces](https://code.claude.com/docs/en/agent-sdk/modifying-system-prompts.md#turn-off-the-context-your-agent-replaces).130To change or remove the attribution lines, set [`attribution`](https://code.claude.com/docs/en/settings-reference#attribution). To remove Claude Code's built-in commit and pull request instructions, set [`includeGitInstructions`](https://code.claude.com/docs/en/settings-reference#includegitinstructions) to `false`. For the other switches, see [Turn off the context your agent replaces](https://code.claude.com/docs/en/agent-sdk/modifying-system-prompts.md#turn-off-the-context-your-agent-replaces).

Details

81| :- | :- | :- |81| :- | :- | :- |

82| Quick escape | `\` + `Enter` | Works in all terminals |82| Quick escape | `\` + `Enter` | Works in all terminals |

83| Option key | `Option+Enter` | After enabling [Option as Meta](https://code.claude.com/docs/en/terminal-config.md#enable-option-key-shortcuts-on-macos) on macOS |83| Option key | `Option+Enter` | After enabling [Option as Meta](https://code.claude.com/docs/en/terminal-config.md#enable-option-key-shortcuts-on-macos) on macOS |

84| Shift+Enter | `Shift+Enter` | Native in iTerm2, WezTerm, Ghostty, Kitty, Warp, Windows Terminal. For other terminals, see [Enter multiline prompts](https://code.claude.com/docs/en/terminal-config.md#enter-multiline-prompts) |84| Shift+Enter | `Shift+Enter` | Native in iTerm2, WezTerm, Ghostty, Kitty, Warp, Windows Terminal 1.25 or later. For other terminals, see [Enter multiline prompts](https://code.claude.com/docs/en/terminal-config.md#enter-multiline-prompts) |

85| Control sequence | `Ctrl+J` | Works in any terminal without configuration |85| Control sequence | `Ctrl+J` | Works in any terminal without configuration |

86| Paste mode | Paste directly | For code blocks, logs |86| Paste mode | Paste directly | For code blocks, logs |

87 87 

keybindings.md +1 −1

Details

110| :- | :- | :- |110| :- | :- | :- |

111| `chat:cancel` | Escape | Cancel current input |111| `chat:cancel` | Escape | Cancel current input |

112| `chat:clearInput` | Ctrl+L | Force a full screen redraw, preserving input and conversation |112| `chat:clearInput` | Ctrl+L | Force a full screen redraw, preserving input and conversation |

113| `chat:clearScreen` | Cmd+K | Same as `chat:clearInput`. See [Clear the conversation](https://code.claude.com/docs/en/fullscreen.md#clear-the-conversation) for how Cmd+K behaves on iTerm2 and Terminal.app |113| `chat:clearScreen` | Cmd+K | Same as `chat:clearInput`. See [Clear the conversation](https://code.claude.com/docs/en/fullscreen.md#clear-the-conversation) for how Cmd+K behaves on iTerm2 |

114| `chat:killAgents` | Ctrl+X Ctrl+K | Stop all running [background subagents](https://code.claude.com/docs/en/sub-agents.md#run-subagents-in-foreground-or-background) in this session and turn off [artifact auto-replies](https://code.claude.com/docs/en/artifacts.md#let-claude-reply-to-comments-on-its-own) for the rest of it. Press the shortcut twice within 3 seconds to confirm. You can press it while a background subagent's permission prompt is open |114| `chat:killAgents` | Ctrl+X Ctrl+K | Stop all running [background subagents](https://code.claude.com/docs/en/sub-agents.md#run-subagents-in-foreground-or-background) in this session and turn off [artifact auto-replies](https://code.claude.com/docs/en/artifacts.md#let-claude-reply-to-comments-on-its-own) for the rest of it. Press the shortcut twice within 3 seconds to confirm. You can press it while a background subagent's permission prompt is open |

115| `chat:cycleMode` | Shift+Tab\* | Cycle permission modes |115| `chat:cycleMode` | Shift+Tab\* | Cycle permission modes |

116| `chat:modelPicker` | Meta+P | Open model picker |116| `chat:modelPicker` | Meta+P | Open model picker |

Details

110 110 

111Two client-side settings change what Claude Code assumes for a model ID it doesn't recognize, whichever connection method the developer uses:111Two client-side settings change what Claude Code assumes for a model ID it doesn't recognize, whichever connection method the developer uses:

112 112 

113* **Context window**: Claude Code assumes a 1M token context window by default. To declare the real window, see [Correct the window for a gateway or custom model ID](https://code.claude.com/docs/en/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)113* **Context window**: Claude Code assumes a 1M token context window by default since v2.1.323. To declare the real window, see [Correct the window for a gateway or custom model ID](https://code.claude.com/docs/en/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)

114* **Capabilities**: to give a gateway alias the capabilities of the model behind it, map that model's Anthropic ID to your alias with a [`modelOverrides`](https://code.claude.com/docs/en/errors#unrecognized-model-id-on-a-request) entry in the settings you distribute. For where the `ANTHROPIC_DEFAULT_*_MODEL_SUPPORTED_CAPABILITIES` variables apply, see [feature pass-through](#feature-pass-through)114* **Capabilities**: to give a gateway alias the capabilities of the model behind it, map that model's Anthropic ID to your alias with a [`modelOverrides`](https://code.claude.com/docs/en/errors#unrecognized-model-id-on-a-request) entry in the settings you distribute. For where the `ANTHROPIC_DEFAULT_*_MODEL_SUPPORTED_CAPABILITIES` variables apply, see [feature pass-through](#feature-pass-through)

115 115 

116## Request headers116## Request headers


211 211 

212### Beta header and body field pairs212### Beta header and body field pairs

213 213 

214Capabilities that add body fields pair them with a beta header, and the pair travels together. A gateway that strips the header while passing the body, or forwards an Anthropic-format body to an upstream with a different schema, produces `400` errors. When both halves are absent together, the feature turns off quietly.214Capabilities that add body fields pair them with a beta header, and the pair travels together. A gateway that strips the header while passing the body, or forwards an Anthropic-format body to an upstream with a different schema, produces `400` errors.

215 215 

216A gateway that rewrites or redacts request bodies for content inspection breaks the pairing the same way stripping does, so inspect without modifying. The table notes where a feature deviates from the pairing.216A gateway that rewrites or redacts request bodies for content inspection breaks the pairing the same way stripping does, so inspect without modifying. The table notes where a feature deviates from the pairing.

217 217 

Details

173 173 

174To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](https://code.claude.com/docs/en/model-config#turn-off-1m-context).174To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](https://code.claude.com/docs/en/model-config#turn-off-1m-context).

175 175 

176If Claude Code can't match a deployment name to a model, it assumes a 1M window by default, so [set the real window](https://code.claude.com/docs/en/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id) if your deployed model accepts less.176If Claude Code can't match a deployment name to a model, it assumes a 1M window by default, so [set the real window](https://code.claude.com/docs/en/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id) if your deployed model accepts less. Before v2.1.323, Claude Code assumed 200K by default, so on those versions append `[1m]` to the name in your model variables if the model accepts 1M.

177 177 

178Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](https://code.claude.com/docs/en/model-config.md#pin-models-for-third-party-deployments) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.178Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](https://code.claude.com/docs/en/model-config.md#pin-models-for-third-party-deployments) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.

179 179 

model-config.md +1 −1

Details

1033By default, Claude Code treats a pinned ID as having the [1M context window](#extended-context), with no `[1m]` suffix needed, in these cases:1033By default, Claude Code treats a pinned ID as having the [1M context window](#extended-context), with no `[1m]` suffix needed, in these cases:

1034 1034 

1035* **An ID Claude Code matches to a model with a native 1M window, such as Opus 4.8 or Sonnet 5**: the ID matches when it contains the model's Anthropic API ID, as `us.anthropic.claude-opus-4-8` contains `claude-opus-4-8`, or when a [`modelOverrides`](#override-model-ids-per-version) entry maps the model to it1035* **An ID Claude Code matches to a model with a native 1M window, such as Opus 4.8 or Sonnet 5**: the ID matches when it contains the model's Anthropic API ID, as `us.anthropic.claude-opus-4-8` contains `claude-opus-4-8`, or when a [`modelOverrides`](#override-model-ids-per-version) entry maps the model to it

1036* **An ID Claude Code can't match to a model**: [set the real window](#correct-the-window-for-a-gateway-or-custom-model-id) if the model behind the ID accepts less1036* **An ID Claude Code can't match to a model**: [set the real window](#correct-the-window-for-a-gateway-or-custom-model-id) if the model behind the ID accepts less. Before v2.1.323, Claude Code assumed 200K by default, so on those versions append `[1m]` to the ID if the model accepts 1M.

1037 1037 

1038For a model that reaches 1M through its `[1m]` variant, such as Opus 4.6 or Sonnet 4.6, enable extended context by appending `[1m]` to the model ID in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`:1038For a model that reaches 1M through its `[1m]` variant, such as Opus 4.6 or Sonnet 4.6, enable extended context by appending `[1m]` to the model ID in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`:

1039 1039 

Details

446> export OTEL_RESOURCE_ATTRIBUTES="org.name=John%27s%20Organization"446> export OTEL_RESOURCE_ATTRIBUTES="org.name=John%27s%20Organization"

447> ```447> ```

448>448>

449> Wrapping values in quotes doesn't escape spaces. For example, `org.name="My Company"` results in the literal value `"My Company"` with the quotes included, not `My Company`.449> Wrapping values in quotes doesn't escape spaces.

450 450 

451### Attribute telemetry to Desktop SSH sessions451### Attribute telemetry to Desktop SSH sessions

452 452 

Details

597> * When Claude reads an [artifact someone else made](https://code.claude.com/docs/en/artifacts.md#read-an-artifact-shared-with-you), the approval cases listed in that section apply597> * When Claude reads an [artifact someone else made](https://code.claude.com/docs/en/artifacts.md#read-an-artifact-shared-with-you), the approval cases listed in that section apply

598> * A read from a [network path](https://code.claude.com/docs/en/permissions.md#network-paths) prompts you598> * A read from a [network path](https://code.claude.com/docs/en/permissions.md#network-paths) prompts you

599> 3. Everything else goes to the classifier, apart from [critical-path removals](#critical-paths) under their default handling. The connector tools and `requiresUserInteraction` MCP tools that prompt you directly in step 1 never reach the classifier either, so neither an org-required approval nor a consent step is auto-approved599> 3. Everything else goes to the classifier, apart from [critical-path removals](#critical-paths) under their default handling. The connector tools and `requiresUserInteraction` MCP tools that prompt you directly in step 1 never reach the classifier either, so neither an org-required approval nor a consent step is auto-approved

600> * With [Code Mode](https://code.claude.com/docs/en/code-mode.md#permission-checks) on, Claude's code goes to the classifier once before it runs, and the tool calls inside it don't. You can still block a call with a `deny` rule or require a prompt with an `ask` rule, but Claude can run Bash commands in [forms the rules don't match](https://code.claude.com/docs/en/permissions.md#bash-rule-limits)600> * With [Code Mode](https://code.claude.com/docs/en/code-mode.md#permission-checks) on, the code that Claude writes goes to the classifier once before it runs, and the tool calls inside it don't. You can still block a call with a `deny` rule or require a prompt with an `ask` rule, but Claude can run Bash commands in [forms the rules don't match](https://code.claude.com/docs/en/permissions.md#bash-rule-limits)

601> 4. If the classifier blocks, Claude receives the reason. In most sessions the reason names the rule the classifier matched, such as `[Data Exfiltration]`, rather than giving a written explanation; see [Review denials](https://code.claude.com/docs/en/auto-mode-config.md#review-denials)601> 4. If the classifier blocks, Claude receives the reason. In most sessions the reason names the rule the classifier matched, such as `[Data Exfiltration]`, rather than giving a written explanation; see [Review denials](https://code.claude.com/docs/en/auto-mode-config.md#review-denials)

602>602>

603> A [mod](https://code.claude.com/docs/en/plugins/mods/overview.md) you install that handles `tool.check` can also approve an action. For the cases where its approval doesn't get past your rules and hooks, see [Extend permissions with hooks](https://code.claude.com/docs/en/permissions.md#precedence-among-rules-hooks-and-mods).603> A [mod](https://code.claude.com/docs/en/plugins/mods/overview.md) you install that handles `tool.check` can also approve an action. For the cases where its approval doesn't get past your rules and hooks, see [Extend permissions with hooks](https://code.claude.com/docs/en/permissions.md#precedence-among-rules-hooks-and-mods).

Details

82| :- | :- |82| :- | :- |

83| `-s, --scope <scope>` | Installation scope: `user`, `project`, or `local`. Defaults to `user` |83| `-s, --scope <scope>` | Installation scope: `user`, `project`, or `local`. Defaults to `user` |

84| `--config <key=value>` | Set a [`userConfig`](https://code.claude.com/docs/en/plugins/manifest-reference) option the plugin's manifest declares. Repeat the flag for each option. A key written `<server>.<key>` sets a setting that a [bundled MCP server](https://code.claude.com/docs/en/plugins/components.md#include-a-packaged-mcpb-server) declares in its own `user_config` instead, for a bundle file shipped inside the plugin. The `<server>.<key>` form requires Claude Code v2.1.285 or later |84| `--config <key=value>` | Set a [`userConfig`](https://code.claude.com/docs/en/plugins/manifest-reference) option the plugin's manifest declares. Repeat the flag for each option. A key written `<server>.<key>` sets a setting that a [bundled MCP server](https://code.claude.com/docs/en/plugins/components.md#include-a-packaged-mcpb-server) declares in its own `user_config` instead, for a bundle file shipped inside the plugin. The `<server>.<key>` form requires Claude Code v2.1.285 or later |

85| `-y, --yes` | Accept the displayed install command without the `Run this command now?` prompt. Ignored when the command runs inside a Claude Code session, such as from the Bash tool or a hook. Requires Claude Code v2.1.229 or later |85| `-y, --yes` | Accept the displayed install command without the `Run this command now?` prompt. Ignored when the command runs inside a Claude Code session, such as from the Bash tool or a hook |

86| `--accept-command <sha256>` | Accept the displayed install command whose `sha256` a previous [`--json` run](#plugin-json-result) reported in `shownCommand`, in place of `-y`. Can't be combined with `-y`. See [Accept a displayed install command](#accept-a-displayed-install-command). Requires Claude Code v2.1.271 or later |86| `--accept-command <sha256>` | Accept the displayed install command whose `sha256` a previous [`--json` run](#plugin-json-result) reported in `shownCommand`, in place of `-y`. Can't be combined with `-y`. See [Accept a displayed install command](#accept-a-displayed-install-command). Requires Claude Code v2.1.271 or later |

87| `--json` | Print the result as one JSON object on the last line of stdout instead of the human-readable message, for use in scripts. See [JSON result format](#plugin-json-result). Requires Claude Code v2.1.268 or later |87| `--json` | Print the result as one JSON object on the last line of stdout instead of the human-readable message, for use in scripts. See [JSON result format](#plugin-json-result). Requires Claude Code v2.1.268 or later |

88| `--marketplace <source>` | Install `<plugin>`, given by its bare name, from the marketplace at `<source>`, adding the marketplace first if you haven't added it yet. See [Add a marketplace and install in one command](https://code.claude.com/docs/en/plugins/install.md#add-a-marketplace-and-install-in-one-command). Requires Claude Code v2.1.292 or later |88| `--marketplace <source>` | Install `<plugin>`, given by its bare name, from the marketplace at `<source>`, adding the marketplace first if you haven't added it yet. See [Add a marketplace and install in one command](https://code.claude.com/docs/en/plugins/install.md#add-a-marketplace-and-install-in-one-command). Requires Claude Code v2.1.292 or later |


261| Flag | Description |261| Flag | Description |

262| :- | :- |262| :- | :- |

263| `-s, --scope <scope>` | Scope to update: `user`, `project`, `local`, or `managed`. Auto-detected when omitted |263| `-s, --scope <scope>` | Scope to update: `user`, `project`, `local`, or `managed`. Auto-detected when omitted |

264| `-y, --yes` | Accept a changed install command from a [command-source](https://code.claude.com/docs/en/plugins/host-marketplace.md) plugin, without the prompt. Required when stdin or stdout isn't a TTY, unless you pass `--accept-command`. Requires Claude Code v2.1.229 or later |264| `-y, --yes` | Accept a changed install command from a [command-source](https://code.claude.com/docs/en/plugins/host-marketplace.md) plugin, without the prompt. Required when stdin or stdout isn't a TTY, unless you pass `--accept-command` |

265| `--accept-command <sha256>` | Accept the marketplace-declared command whose `sha256` a previous [`--json` run](#plugin-json-result) reported in `shownCommand`, in place of `-y`. Can't be combined with `-y`. Requires Claude Code v2.1.271 or later |265| `--accept-command <sha256>` | Accept the marketplace-declared command whose `sha256` a previous [`--json` run](#plugin-json-result) reported in `shownCommand`, in place of `-y`. Can't be combined with `-y`. Requires Claude Code v2.1.271 or later |

266| `--json` | Print the result as one JSON object on the last line of stdout, in the [same format as `plugin install --json`](#plugin-json-result). Requires Claude Code v2.1.268 or later |266| `--json` | Print the result as one JSON object on the last line of stdout, in the [same format as `plugin install --json`](#plugin-json-result). Requires Claude Code v2.1.268 or later |

267 267 


612 612 

613* `.claude-plugin/marketplace.json`, when it exists613* `.claude-plugin/marketplace.json`, when it exists

614* Otherwise `.claude-plugin/plugin.json`614* Otherwise `.claude-plugin/plugin.json`

615* Otherwise the component files, chosen by the directory's name. Validating component files without a manifest requires Claude Code v2.1.233 or later:615* Otherwise the component files, chosen by the directory's name:

616 * A directory named `skills`, `agents`, or `commands`: the files inside it616 * A directory named `skills`, `agents`, or `commands`: the files inside it

617 * A directory named `.claude`: the `skills`, `agents`, and `commands` directories inside it617 * A directory named `.claude`: the `skills`, `agents`, and `commands` directories inside it

618 * Any other directory: those three directories under its `.claude`618 * Any other directory: those three directories under its `.claude`

Details

142| `git-subdir` | `url`, `path`, `ref`, `sha` | One subdirectory of a git repository, fetched with a sparse checkout |142| `git-subdir` | `url`, `path`, `ref`, `sha` | One subdirectory of a git repository, fetched with a sparse checkout |

143| `npm` | `package`, `version`, `registry` | npm registry package or tarball link, fetched with your npm client and unpacked without running install scripts |143| `npm` | `package`, `version`, `registry` | npm registry package or tarball link, fetched with your npm client and unpacked without running install scripts |

144| `archive` | `url`, `sha256` | Zip archive over HTTPS |144| `archive` | `url`, `sha256` | Zip archive over HTTPS |

145| `command` | `command`, `timeout`, `mode` | Directory printed by a command Claude Code runs on the user's machine. Requires Claude Code v2.1.229 or later |145| `command` | `command`, `timeout`, `mode` | Directory printed by a command Claude Code runs on the user's machine |

146 146 

147The names `url` and `github` are also [marketplace source](#marketplace-sources) types, where `url` means a direct link to a `marketplace.json` file rather than a git repository. `git` exists only as a marketplace source, and `npm` exists as both. `git-subdir`, `archive`, and `command` exist only as plugin sources.147The names `url` and `github` are also [marketplace source](#marketplace-sources) types, where `url` means a direct link to a `marketplace.json` file rather than a git repository. `git` exists only as a marketplace source, and `npm` exists as both. `git-subdir`, `archive`, and `command` exist only as plugin sources.

148 148 

Details

375>375>

376> On v2.1.323 or later, a `ui.focus` hook needs a wider matcher to receive other mods' `$.ui.focus` calls. See [Hook other mods' drawings and controls](https://code.claude.com/docs/en/plugins/mods/events.md#hook-other-mods-drawings-and-controls).376> On v2.1.323 or later, a `ui.focus` hook needs a wider matcher to receive other mods' `$.ui.focus` calls. See [Hook other mods' drawings and controls](https://code.claude.com/docs/en/plugins/mods/events.md#hook-other-mods-drawings-and-controls).

377 377 

378This policy mod refuses any user's mod whose own code calls `$.process.run` or `$.process.spawn`. It also keeps an audit log, writing each tool call and each file a mod writes to the debug log. Because it runs first, the log records what was requested, before any user's mod changes it. Save it as `acme-guard/hooks/register.js`:378This policy mod stops any user's mod whose own code calls `$.process.run` or `$.process.spawn`, and lets the rest of the user's plugin load. It also keeps an audit log, writing each tool call and each file a mod writes to the debug log. Because it runs first, the log records what was requested, before any user's mod changes it. Save it as `acme-guard/hooks/register.js`:

379 379 

380```javascript acme-guard/hooks/register.js theme={null}380```javascript acme-guard/hooks/register.js theme={null}

381// The methods no user's mod may call, each spelled namespace.method381// The methods no user's mod may call, each spelled namespace.method


387 // Keep the calls in that mod's code that are on the blocked list387 // Keep the calls in that mod's code that are on the blocked list

388 const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))388 const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))

389 if (e.tier === 'user' && blocked.length > 0) {389 if (e.tier === 'user' && blocked.length > 0) {

390 // Returning refuse keeps the mod from loading, and the text is the reason390 // v2.1.326 or later: leave out the hooks module and load the rest of the plugin

391 if (e.provides) return next({ ...e, provides: { ...e.provides, modules: [] } })

392 // Earlier versions: refuse leaves out the hooks module, and the text is the reason

391 return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }393 return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }

392 }394 }

393 // Let every other mod load395 // Let every other mod load


410 412 

411The file registers three hooks:413The file registers three hooks:

412 414 

413* **`plugin.register`**: decides whether another mod loads. It refuses a user's mod that calls a blocked method and passes every other mod on.415* **`plugin.register`**: decides whether another mod loads. It stops a user's mod that calls a blocked method and passes every other mod on.

414* **`tool.call`**: writes a line such as `audit tool.call Bash` to the debug log for each tool call, and changes nothing416* **`tool.call`**: writes a line such as `audit tool.call Bash` to the debug log for each tool call, and changes nothing

415* **`fs.write`**: writes a line such as `audit fs.write by reader "/tmp/notes.md"` for each `$.fs.write` call another mod makes, and changes nothing. The mod's name comes first and the path is quoted, so a path that a mod picks can't pass for another field of the line.417* **`fs.write`**: writes a line such as `audit fs.write by reader "/tmp/notes.md"` for each `$.fs.write` call another mod makes, and changes nothing. The mod's name comes first and the path is quoted, so a path that a mod picks can't pass for another field of the line.

416 418 

417The `plugin.register` hook reads two fields of the event:419The `plugin.register` hook reads three fields of the event:

418 420 

419* **`e.tier`**: where the mod would run, one of `prepend`, `user`, `append`, or `builtin`. Every mod a person installs is `user`.421* **`e.tier`**: where the mod would run, one of `prepend`, `user`, `append`, or `builtin`. Every mod a person installs is `user`.

420* **`e.uses.calls`**: the mods API methods the mod calls, each written `namespace.method` such as `process.run`, without the `$.` that `claude plugin validate` prints422* **`e.uses.calls`**: the mods API methods the mod calls, each written `namespace.method` such as `process.run`, without the `$.` that `claude plugin validate` prints

423* **`e.provides`**: the plugin's parts by kind, such as `modules`. To load everything but the [hooks module](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself), pass `next` the event with `provides.modules` emptied. Requires Claude Code v2.1.326 or later.

421 424 

422When a user installs a mod that calls `$.process.run`, the mod doesn't load, and their debug log has a line that ends with `refused by acme-guard:` and your reason. The refusal also reaches the transcript in a [session that hot-reloads a plugin directory](https://code.claude.com/docs/en/plugins/mods/troubleshoot.md#find-out-why-a-mod-does-nothing).425When a user installs a mod that calls `$.process.run`, the mod doesn't load, and their debug log has a line that includes `hooks module left out by acme-guard`. The line also reaches the transcript in a [session that hot-reloads a plugin directory](https://code.claude.com/docs/en/plugins/mods/troubleshoot.md#find-out-why-a-mod-does-nothing). Before v2.1.326, look for `refused by acme-guard:` and your reason instead.

426 

427> [!NOTE]

428>

429> When you return `{ refuse }` on v2.1.326 or later, the whole plugin stays out, including its MCP servers and the hooks in its `hooks/hooks.json`. If you wrote a policy mod for an earlier version, add the example's `if (e.provides)` line ahead of each refusal that should stop only the mod. For a `.catch` handler, see [Refuse mods when your check fails](#refuse-mods-when-your-check-fails).

423 430 

424To block a call without refusing the whole mod, return `{ deny: 'your reason' }` from a hook on that call's name, after you [check who made the call](https://code.claude.com/docs/en/plugins/mods/reference.md#mods-api-calls).431To block a call without refusing the whole mod, return `{ deny: 'your reason' }` from a hook on that call's name, after you [check who made the call](https://code.claude.com/docs/en/plugins/mods/reference.md#mods-api-calls).

425 432 


431 438 

432#### Refuse mods when your check fails439#### Refuse mods when your check fails

433 440 

434If your `plugin.register` hook throws or exceeds its time limit, Claude Code skips the hook, so the check fails open and the mod it was checking loads. To fail closed and refuse users' mods, move the check into a named function and add a `.catch` handler that returns the refusal. This version of the file shows the `plugin.register` hook only, so keep the two audit hooks from the first version in `register`:441If your `plugin.register` hook throws or exceeds its time limit, Claude Code skips the hook, so the check fails open and the mod it was checking loads. To fail closed when the check throws, move it into a named function and add a `.catch` handler. This version of the file shows the `plugin.register` hook only, so keep the two audit hooks from the first version in `register`:

435 442 

436```javascript acme-guard/hooks/register.js theme={null}443```javascript acme-guard/hooks/register.js theme={null}

437const BLOCKED_CALLS = ['process.run', 'process.spawn']444const BLOCKED_CALLS = ['process.run', 'process.spawn']


440async function checkMod($, e, next) {447async function checkMod($, e, next) {

441 const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))448 const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))

442 if (e.tier === 'user' && blocked.length > 0) {449 if (e.tier === 'user' && blocked.length > 0) {

450 if (e.provides) return next({ ...e, provides: { ...e.provides, modules: [] } })

443 return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }451 return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }

444 }452 }

445 return next(e)453 return next(e)

446}454}

447 455 

448export function register(on) {456export function register(on) {

449 // The handler runs only when checkMod throws or exceeds its time limit457 // The handler runs when checkMod throws

450 on('plugin.register', checkMod).catch(async ($, e, next) => {458 on('plugin.register', checkMod).catch(async ($, e, next) => {

451 // Let your organization's mods and built-in mods load459 // Let your organization's mods and built-in mods load

452 if (e.tier !== 'user') return next(e)460 if (e.tier !== 'user') return next(e)

453 // Refuse the user's mod that couldn't be checked461 // Stop the unchecked mod, not its whole plugin

462 if (e.provides && !next.called) return next({ ...e, provides: { ...e.provides, modules: [] } })

454 return { refuse: 'Acme policy check failed, so this mod was not loaded' }463 return { refuse: 'Acme policy check failed, so this mod was not loaded' }

455 })464 })

456}465}

457```466```

458 467 

459With the handler in place, a mod that was being checked when the check threw or timed out doesn't load, and the refusal line carries the second reason, as in `refused by acme-guard: Acme policy check failed, so this mod was not loaded`. The handler passes every mod outside the `user` tier to `next(e)`, so a failed check doesn't stop the mods your organization lists. [Handle a hook that fails](https://code.claude.com/docs/en/plugins/mods/events.md#handle-a-hook-that-fails) covers `.catch` for other events.468With the handler in place, a user's mod doesn't load when the check throws. If the check throws after it calls `next`, the handler falls back to `refuse`. Don't rely on the handler for a check that exceeds its time limit.

469 

470The handler passes every mod outside the `user` tier to `next(e)`, so a failed check doesn't stop the mods your organization lists. [Handle a hook that fails](https://code.claude.com/docs/en/plugins/mods/events.md#handle-a-hook-that-fails) covers `.catch` for other events.

460 471 

461## Next steps472## Next steps

462 473 

Details

470At `tool.check` and `plugin.register`, a refusal returned after `next` resolved still holds, so return it without testing `next.called`:470At `tool.check` and `plugin.register`, a refusal returned after `next` resolved still holds, so return it without testing `next.called`:

471 471 

472* **`tool.check`**: return `{ decision: 'deny', reason: 'the reason' }`472* **`tool.check`**: return `{ decision: 'deny', reason: 'the reason' }`

473* **`plugin.register`**: return `{ refuse: 'the reason' }`, as [Refuse mods when your check fails](https://code.claude.com/docs/en/plugins/mods/admin.md#refuse-mods-when-your-check-fails) shows473* **`plugin.register`**: return `{ refuse: 'the reason' }`. On v2.1.326 or later, the other mod's whole plugin then stays out. To stop only the mod, see [Refuse mods when your check fails](https://code.claude.com/docs/en/plugins/mods/admin.md#refuse-mods-when-your-check-fails).

474 474 

475At `tool.call`, a `deny` returned after `next` resolved [withholds the result from Claude](#guard-or-change-a-tool-call).475At `tool.call`, a `deny` returned after `next` resolved [withholds the result from Claude](#guard-or-change-a-tool-call).

476 476 

Details

354* **`tier`**: call it once at the top of the test file, as in `tier('prepend')`, to load your mod as `prepend`, `append`, or `builtin`, its place in the [order mods run in](https://code.claude.com/docs/en/plugins/mods/events.md#the-order-mods-run-in). Without it, your mod loads as `user`.354* **`tier`**: call it once at the top of the test file, as in `tier('prepend')`, to load your mod as `prepend`, `append`, or `builtin`, its place in the [order mods run in](https://code.claude.com/docs/en/plugins/mods/events.md#the-order-mods-run-in). Without it, your mod loads as `user`.

355* **`plugins`**: pass `test` an options object ahead of the test body. Its `plugins` array holds mods you write inline, each with a `name` and a `register` function. To load one somewhere other than `user`, add `tier` to it.355* **`plugins`**: pass `test` an options object ahead of the test body. Its `plugins` array holds mods you write inline, each with a `name` and a `register` function. To load one somewhere other than `user`, add `tier` to it.

356 356 

357This test file loads the [policy mod from the admin page](https://code.claude.com/docs/en/plugins/mods/admin.md#enforce-a-policy-with-a-mod-of-your-own) first. It checks that the policy mod refuses a mod that starts a process and allows one that doesn't:357This test file loads the [policy mod from the admin page](https://code.claude.com/docs/en/plugins/mods/admin.md#enforce-a-policy-with-a-mod-of-your-own) first. It checks that the policy mod stops a mod that starts a process and allows one that doesn't:

358 358 

359```typescript acme-guard/tests/guard.test.ts theme={null}359```typescript acme-guard/tests/guard.test.ts theme={null}

360import { expect, test, tier } from 'claude-code/testing'360import { expect, test, tier } from 'claude-code/testing'


392 } catch (error) {392 } catch (error) {

393 message = error.message393 message = error.message

394 }394 }

395 expect(message).toBe('runner: refused by acme-guard: Acme policy: mods may not call process.run')395 // "hooks module left out" on v2.1.326 or later, "refused" on earlier versions

396 expect(message).toMatch(/^runner: (hooks module left out|refused) by acme-guard/)

396})397})

397 398 

398test('admits a mod that starts no process', { plugins: [reader] }, async ($, on) => {399test('admits a mod that starts no process', { plugins: [reader] }, async ($, on) => {


405 406 

406In your shell, run `claude plugin test` from the `acme-guard` directory. Both tests pass with the policy mod as the admin page shows it.407In your shell, run `claude plugin test` from the `acme-guard` directory. Both tests pass with the policy mod as the admin page shows it.

407 408 

408The kit loads every mod at the test's first call on `$`. When your mod refuses one, that call throws, and the message names the refused mod, the mod that refused it, and your reason. In the second test nothing is refused, so `reader` answers the tool call before it reaches the stub.409The kit loads every mod at the test's first call on `$`. When your mod stops one, that call throws, and the message names both mods. In the second test nothing is stopped, so `reader` answers the tool call before it reaches the stub.

409 410 

410## Next steps411## Next steps

411 412 

Details

4 4 

5# How Claude Code uses prompt caching5# How Claude Code uses prompt caching

6 6 

7> Claude Code manages prompt caching automatically. See why a model switch triggers a slow uncached turn, what `/compact` costs, why CLAUDE.md edits don't apply mid-session, and how to check your cache hit rate.7> See why a model switch triggers a slow uncached turn in Claude Code, what `/compact` costs, and how to check your prompt cache hit rate.

8 8 

9Prompt caching makes Claude Code faster and more cost-efficient. Without caching, the API would reprocess your full history on every turn. With caching, it reuses what it already processed, bills the re-read at the [cached token rate](https://platform.claude.com/docs/en/about-claude/pricing), and fully processes only what changed.9Prompt caching makes Claude Code faster and more cost-efficient. Without caching, the API would reprocess your full history on every turn. With caching, it reuses what it already processed, bills the re-read at the [cached token rate](https://platform.claude.com/docs/en/about-claude/pricing), and fully processes only what changed.

10 10 


207 207 

208## Actions that keep the cache208## Actions that keep the cache

209 209 

210These actions either append to the end of the conversation or don't touch the request at all. Some of them, such as editing CLAUDE.md, keep the cache for the same reason the change doesn't reach the running session until `/clear`, `/compact`, or a restart.210These actions either append to the end of the conversation or don't touch the request at all.

211 211 

212* [Editing files in your repository](#editing-files-in-your-repository)212* [Editing files in your repository](#editing-files-in-your-repository)

213* [Editing CLAUDE.md mid-session](#editing-claude-md-mid-session)213* [Editing CLAUDE.md mid-session](#editing-claude-md-mid-session)


220 220 

221### Editing files in your repository221### Editing files in your repository

222 222 

223File contents enter context only when Claude reads them, and reads append to the conversation. Editing a file Claude previously read does not retroactively change the earlier read in history. Instead, Claude Code appends a [`<system-reminder>`](https://code.claude.com/docs/en/glossary#system-reminder) noting the file changed, and Claude re-reads it if needed.223When you edit a source file Claude already read, the cached prefix stays intact, because your edit doesn't change the copy already in the conversation.

224 224 

225### Editing CLAUDE.md mid-session225### Editing CLAUDE.md mid-session

226 226 

227Your project-root and user-level CLAUDE.md files are read once at session start and held in memory. Editing them mid-session does not invalidate the cache, but the edit also doesn't apply. Claude keeps working with the version that was loaded at session start. The new content loads on the next `/clear`, `/compact`, or restart.227When you edit your project-root or user-level CLAUDE.md mid-session, the cached prefix stays intact. Claude Code reads these files at session start and holds them in memory. To reload them, run `/clear` or `/compact`, or restart Claude Code.

228 228 

229[Nested CLAUDE.md files in subdirectories](https://code.claude.com/docs/en/memory.md) and [rules with `paths:` frontmatter](https://code.claude.com/docs/en/memory#path-specific-rules) load later, on demand. Editing one yourself before it loads does take effect. After it loads, the content is part of the conversation history, so a mid-session edit doesn't retroactively change it.229[Nested CLAUDE.md files in subdirectories](https://code.claude.com/docs/en/memory.md) and [rules with `paths:` frontmatter](https://code.claude.com/docs/en/memory#path-specific-rules) load later, on demand. Editing one yourself before it loads takes effect. After it loads, the content is part of the conversation history, so a mid-session edit doesn't retroactively change it.

230 230 

231### Changing permission mode231### Changing permission mode

232 232 


250 250 

251[`/rewind`](https://code.claude.com/docs/en/checkpointing) truncates your conversation back to an earlier turn. The remaining history is the same content the cache was built from at that point, and the system prompt and project context layers are unchanged, so the next request hits the earlier cache entry. Every turn since then has read through that prefix, which kept the entry warm even if the original turn was longer ago than the TTL.251[`/rewind`](https://code.claude.com/docs/en/checkpointing) truncates your conversation back to an earlier turn. The remaining history is the same content the cache was built from at that point, and the system prompt and project context layers are unchanged, so the next request hits the earlier cache entry. Every turn since then has read through that prefix, which kept the entry warm even if the original turn was longer ago than the TTL.

252 252 

253Restoring file checkpoints alongside the conversation has no separate effect on the cache. File contents enter context only when Claude reads them, the same as [editing files in your repository](#editing-files-in-your-repository).253Restoring file checkpoints alongside the conversation has no separate effect on the cache.

254 254 

255## Resuming a session255## Resuming a session

256 256 

Details

126 126 

127### Stop a loop127### Stop a loop

128 128 

129* **[Self-paced loop](#let-claude-choose-the-interval)**: while the loop is waiting for its next iteration, press `Esc` to stop it. You can also stop it with `Ctrl+C` while Claude is idle, except in a [background session you've attached to](#detach-without-stopping-a-loop). A `Pending wakeup cancelled` notice confirms that the loop won't fire again.129* **[Self-paced loop](#let-claude-choose-the-interval)**: while the loop is waiting for its next iteration, press `Esc` on an empty prompt to stop it. You can also stop it with `Ctrl+C` while Claude is idle, except in a [background session you've attached to](#detach-without-stopping-a-loop). A `Pending wakeup cancelled` notice confirms that the loop won't fire again.

130* **[Fixed-interval loop](#run-on-a-fixed-interval)**: to stop a loop such as `/loop 5m`, ask Claude to cancel it, for example `cancel the deploy check loop`. `Esc` and `Ctrl+C` don't stop it, or any task you [scheduled by asking Claude directly](#manage-scheduled-tasks). A loop you don't cancel ends when [seven days elapse](#seven-day-expiry).130* **[Fixed-interval loop](#run-on-a-fixed-interval)**: to stop a loop such as `/loop 5m`, ask Claude to cancel it, for example `cancel the deploy check loop`. `Esc` and `Ctrl+C` don't stop it, or any task you [scheduled by asking Claude directly](#manage-scheduled-tasks). A loop you don't cancel ends when [seven days elapse](#seven-day-expiry).

131 131 

132In [self-paced mode](#let-claude-choose-the-interval), Claude can also end the loop on its own once the task is complete. Claude calls the [`ScheduleWakeup` tool](https://code.claude.com/docs/en/tools-reference) with `stop: true`, which cancels the pending wakeup immediately. If an iteration ends without either rescheduling or stopping, Claude Code schedules one fallback wakeup about 20 minutes later and ends the loop when that iteration doesn't reschedule either.132In [self-paced mode](#let-claude-choose-the-interval), Claude can also end the loop on its own once the task is complete. Claude calls the [`ScheduleWakeup` tool](https://code.claude.com/docs/en/tools-reference) with `stop: true`, which cancels the pending wakeup immediately. If an iteration ends without either rescheduling or stopping, Claude Code schedules one fallback wakeup about 20 minutes later and ends the loop when that iteration doesn't reschedule either.

Details

744Choose which version your sessions run and when it changes:744Choose which version your sessions run and when it changes:

745 745 

746* **Before you pin a version**: check [the Claude Code versions that models require](https://code.claude.com/docs/en/model-config.md#available-models) for every model your sessions use. If a model requires a newer version than the one your sessions run, the server rejects requests for that model with [Claude Code does not support this model](https://code.claude.com/docs/en/errors.md#claude-code-does-not-support-this-model).746* **Before you pin a version**: check [the Claude Code versions that models require](https://code.claude.com/docs/en/model-config.md#available-models) for every model your sessions use. If a model requires a newer version than the one your sessions run, the server rejects requests for that model with [Claude Code does not support this model](https://code.claude.com/docs/en/errors.md#claude-code-does-not-support-this-model).

747* **To hold a fleet on one version**: build the image with a pinned version, or on a bare host install a specific version and [disable auto-updates](https://code.claude.com/docs/en/setup.md#disable-auto-updates)747* **To hold a fleet on one version**: build the image with a pinned version, or on a bare host [install a specific version](https://code.claude.com/docs/en/setup.md#install-a-specific-version) and [disable auto-updates](https://code.claude.com/docs/en/setup.md#disable-auto-updates)

748* **To upgrade a fixed fleet**: read the [changelog](https://code.claude.com/docs/en/changelog.md) entries between your version and the one you're installing, then install the newer version or rebuild the image and restart the runners748* **To upgrade a fixed fleet**: read the [changelog](https://code.claude.com/docs/en/changelog.md) entries between your version and the one you're installing, then install the newer version or rebuild the image and restart the runners

749* **To upgrade on-demand runners**: read the [changelog](https://code.claude.com/docs/en/changelog.md) entries between your version and the one you're installing, then change the image your [`spawn-runner` hook](https://code.claude.com/docs/en/self-hosted-environments-configuration#the-spawn-runner-hook) starts. Each new runner gets the new version. A runner that's already up, including a standby runner that [`--min-idle`](https://code.claude.com/docs/en/self-hosted-environments-reference#orchestrator-cli-flags) started, keeps its version until it exits. Don't restart it, because its work order is single-use.749* **To upgrade on-demand runners**: read the [changelog](https://code.claude.com/docs/en/changelog.md) entries between your version and the one you're installing, then change the image your [`spawn-runner` hook](https://code.claude.com/docs/en/self-hosted-environments-configuration#the-spawn-runner-hook) starts. Each new runner gets the new version. A runner that's already up, including a standby runner that [`--min-idle`](https://code.claude.com/docs/en/self-hosted-environments-reference#orchestrator-cli-flags) started, keeps its version until it exits. Don't restart it, because its work order is single-use.

750* **If sessions start a different binary**: if you use [`--exec-path`](https://code.claude.com/docs/en/self-hosted-environments-reference#runner-cli-flags) or a [`command` hook](https://code.claude.com/docs/en/self-hosted-environments-configuration#command) to start a Claude Code binary other than the runner's own, sessions run that binary's version. Update that binary when you update the runner.750* **If sessions start a different binary**: if you use [`--exec-path`](https://code.claude.com/docs/en/self-hosted-environments-reference#runner-cli-flags) or a [`command` hook](https://code.claude.com/docs/en/self-hosted-environments-configuration#command) to start a Claude Code binary other than the runner's own, sessions run that binary's version. Update that binary when you update the runner.

Details

35 35 

36Install on the host before you start:36Install on the host before you start:

37 37 

38* **Claude Code v2.1.224 or later**, with any of the [standard install methods](https://code.claude.com/docs/en/setup.md). The runner is part of the standard `claude` binary, and earlier versions don't recognize the `self-hosted-runner` subcommand. A runner that serves Claude Tag sessions needs v2.1.229 or later and `python3` on its `PATH`, since the [hooks the control plane supplies](https://code.claude.com/docs/en/self-hosted-environments-configuration.md#how-each-session’s-config-is-assembled) for those sessions run `python3`. To pin the exact version your fleet runs, see [Install a specific version](https://code.claude.com/docs/en/setup.md#install-a-specific-version). For container images, see the Dockerfile in [Deploy to production](https://code.claude.com/docs/en/self-hosted-environments-deploy.md#build-the-runner-image).38* **Claude Code v2.1.224 or later**, with any of the [standard install methods](https://code.claude.com/docs/en/setup.md). The runner is part of the standard `claude` binary, and earlier versions don't recognize the `self-hosted-runner` subcommand. A runner that serves Claude Tag sessions needs v2.1.229 or later and `python3` on its `PATH`, since the [hooks the control plane supplies](https://code.claude.com/docs/en/self-hosted-environments-configuration.md#how-each-session’s-config-is-assembled) for those sessions run `python3`.

39 

40 To pin the exact version your fleet runs, see [Pin the version](https://code.claude.com/docs/en/self-hosted-environments-deploy.md#pin-the-version). For container images, see the Dockerfile in [Deploy to production](https://code.claude.com/docs/en/self-hosted-environments-deploy.md#build-the-runner-image).

39* **Git 2.24 or newer**. Some git options on the deploy page need newer versions; [Configure git](https://code.claude.com/docs/en/self-hosted-environments-deploy.md#configure-git) states each floor.41* **Git 2.24 or newer**. Some git options on the deploy page need newer versions; [Configure git](https://code.claude.com/docs/en/self-hosted-environments-deploy.md#configure-git) states each floor.

40 42 

41Confirm the host is ready:43Confirm the host is ready:

Details

79 79 

80The `--environment` and `--ref` dispatch flags require Claude Code v2.1.224 or later on the machine that runs the script, the same floor as the runner itself. With the hook in place and a runner started on this host, the test script:80The `--environment` and `--ref` dispatch flags require Claude Code v2.1.224 or later on the machine that runs the script, the same floor as the runner itself. With the hook in place and a runner started on this host, the test script:

81 81 

821. Creates a session on the test environment with `claude -p "<prompt>" --environment <environment-id> --output-format json`. Run the command from a git checkout so the CLI can auto-detect the repository from the `origin` remote. The optional `--ref <branch>` bases the session's checkout on a named ref instead of local HEAD. The command exits without waiting for Claude's reply. What it prints tells your script the outcome:821. Creates a session on the test environment with `claude -p "<prompt>" --environment <environment-id> --output-format json`. Run the command from a git checkout so the CLI can auto-detect the repository from the `origin` remote. The optional `--ref <branch>` bases the session's checkout on a named ref. The command exits without waiting for Claude's reply. What it prints tells your script the outcome:

83 * **Session created**: one line of JSON such as `{"ok":true,"session_id":"session_...","title":"...","url":"...","pool_id":"..."}`83 * **Session created**: one line of JSON such as `{"ok":true,"session_id":"session_...","title":"...","url":"...","pool_id":"..."}`

84 * **Session creation failed**: the line `{"ok":false,"error":"..."}`, and the command exits with status 184 * **Session creation failed**: the line `{"ok":false,"error":"..."}`, and the command exits with status 1

85 * **Some earlier errors**, such as cloud sessions being unavailable for your organization or a missing prompt: the error on stderr with no JSON line, and the command exits with status 185 * **Some earlier errors**, such as cloud sessions being unavailable for your organization or a missing prompt: the error on stderr with no JSON line, and the command exits with status 1


146 146 

147# 1. Create the session on the test environment. Run from a git checkout147# 1. Create the session on the test environment. Run from a git checkout

148# so the CLI can auto-detect the repo. --ref pins the checkout to a named148# so the CLI can auto-detect the repo. --ref pins the checkout to a named

149# ref regardless of local HEAD.149# ref.

150TURN1="e2e-probe-$(date +%s)-$$: say exactly 'ok: custom tools are reachable' and nothing else"150TURN1="e2e-probe-$(date +%s)-$$: say exactly 'ok: custom tools are reachable' and nothing else"

151EXPECT1="ok: custom tools are reachable"151EXPECT1="ok: custom tools are reachable"

152create_json=$(claude -p "$TURN1" --environment "$CLAUDE_TEST_ENVIRONMENT_ID" \152create_json=$(claude -p "$TURN1" --environment "$CLAUDE_TEST_ENVIRONMENT_ID" \

Details

927 927 

928Choose whether Claude Code uses the auto mode classifier to review shell commands in plan mode. With the default `true`, the classifier reviews each command during planning when auto mode is available and you see no prompt, except for [critical-path removals](https://code.claude.com/docs/en/permission-modes.md#critical-paths). Set `false` to get a permission prompt for every command outside the built-in read-only set. Appears in `/config` as **Use auto mode during plan**.928Choose whether Claude Code uses the auto mode classifier to review shell commands in plan mode. With the default `true`, the classifier reviews each command during planning when auto mode is available and you see no prompt, except for [critical-path removals](https://code.claude.com/docs/en/permission-modes.md#critical-paths). Set `false` to get a permission prompt for every command outside the built-in read-only set. Appears in `/config` as **Use auto mode during plan**.

929 929 

930* **Scope**: [`User, local, or managed`](#scopes). A repository can't turn it off for you.930* **Scope**: [`User, local, or managed`](#scopes).

931 * A `false` in any of these files or in `--settings` turns it off, unless you leave that user or local file out with an option such as [`--setting-sources`](https://code.claude.com/docs/en/cli-reference#cli-flags). Ignoring a left-out file requires Claude Code v2.1.314 or later931 * A `false` in any of these files or in `--settings` turns it off, unless you leave that user or local file out with an option such as [`--setting-sources`](https://code.claude.com/docs/en/cli-reference#cli-flags). Ignoring a left-out file requires Claude Code v2.1.314 or later

932* **Type**: Boolean932* **Type**: Boolean

933 * `true`: the same as unset; when auto mode is available, the classifier reviews shell commands during planning933 * `true`: the same as unset; when auto mode is available, the classifier reviews shell commands during planning


2685 2685 

2686### `autoScrollEnabled`2686### `autoScrollEnabled`

2687 2687 

2688Follow new output to the bottom of the conversation in [fullscreen rendering](https://code.claude.com/docs/en/fullscreen.md). Turn it off to stay where you scrolled while Claude keeps working; permission prompts still scroll into view.2688Follow new output to the bottom of the conversation in [fullscreen rendering](https://code.claude.com/docs/en/fullscreen.md).

2689 2689 

2690* **Scope**: [`Any file`](#scopes)2690* **Scope**: [`Any file`](#scopes)

2691* **Type**: Boolean2691* **Type**: Boolean


3868 3868 

3869Turn off the download of the [skills enabled for your claude.ai account](https://code.claude.com/docs/en/skills.md#how-synced-skills-behave). Claude Code downloads them into `~/.claude/skills/synced/` in [terminal sessions where you sign in with your claude.ai account](https://code.claude.com/docs/en/skills.md#where-synced-skills-load), interactive or non-interactive, and in Cowork and cloud sessions. Set `false` to stop that download and stop loading the skills it already synced. Claude Code honors only `false`: `true` is the same as unset and doesn't turn syncing on where it's otherwise off.3869Turn off the download of the [skills enabled for your claude.ai account](https://code.claude.com/docs/en/skills.md#how-synced-skills-behave). Claude Code downloads them into `~/.claude/skills/synced/` in [terminal sessions where you sign in with your claude.ai account](https://code.claude.com/docs/en/skills.md#where-synced-skills-load), interactive or non-interactive, and in Cowork and cloud sessions. Set `false` to stop that download and stop loading the skills it already synced. Claude Code honors only `false`: `true` is the same as unset and doesn't turn syncing on where it's otherwise off.

3870 3870 

3871* **Scope**: [`User, local, or managed`](#scopes), and files passed with `--settings`. A repository can't turn it off for you.3871* **Scope**: [`User, local, or managed`](#scopes), and files passed with `--settings`.

3872* **Type**: Boolean3872* **Type**: Boolean

3873 * `false`: Claude Code stops downloading synced skills and stops loading the ones already in `~/.claude/skills/synced/`. In user or managed settings, it also moves them to `~/.claude/skills/.trash/`3873 * `false`: Claude Code stops downloading synced skills and stops loading the ones already in `~/.claude/skills/synced/`. In user or managed settings, it also moves them to `~/.claude/skills/.trash/`

3874 * `true`: the same as unset3874 * `true`: the same as unset


3886 3886 

3887Turn off the download of the [plugins enabled for your claude.ai account](https://code.claude.com/docs/en/plugins/loading.md#synced-plugins). Claude Code downloads them into `~/.claude/plugins/synced/` at the start of terminal sessions where you sign in with your claude.ai account and in Cowork sessions, and loads each one as `<name>@synced`. Set `false` to stop that download and stop loading the plugins it already synced. Claude Code honors only `false`: `true` is the same as unset and doesn't turn syncing on where it's otherwise off. Requires Claude Code v2.1.273 or later.3887Turn off the download of the [plugins enabled for your claude.ai account](https://code.claude.com/docs/en/plugins/loading.md#synced-plugins). Claude Code downloads them into `~/.claude/plugins/synced/` at the start of terminal sessions where you sign in with your claude.ai account and in Cowork sessions, and loads each one as `<name>@synced`. Set `false` to stop that download and stop loading the plugins it already synced. Claude Code honors only `false`: `true` is the same as unset and doesn't turn syncing on where it's otherwise off. Requires Claude Code v2.1.273 or later.

3888 3888 

3889* **Scope**: [`User, local, or managed`](#scopes), and files passed with `--settings`. A repository can't turn it off for you.3889* **Scope**: [`User, local, or managed`](#scopes), and files passed with `--settings`.

3890* **Type**: Boolean3890* **Type**: Boolean

3891 * `false`: Claude Code stops downloading synced plugins and stops loading the ones already in `~/.claude/plugins/synced/`. In user or managed settings, it also moves them to `~/.claude/plugins/.trash/`3891 * `false`: Claude Code stops downloading synced plugins and stops loading the ones already in `~/.claude/plugins/synced/`. In user or managed settings, it also moves them to `~/.claude/plugins/.trash/`

3892 * `true`: the same as unset3892 * `true`: the same as unset

setup.md +8 −8

Details

40>40>

41> **macOS, Linux, WSL:**41> **macOS, Linux, WSL:**

42>42>

43> ```bash theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}43> ```bash theme={null}

44> curl -fsSL https://claude.ai/install.sh | bash44> curl -fsSL https://claude.ai/install.sh | bash

45> ```45> ```

46>46>


48>48>

49> **Windows PowerShell:**49> **Windows PowerShell:**

50>50>

51> ```powershell theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}51> ```powershell theme={null}

52> irm https://claude.ai/install.ps1 | iex52> irm https://claude.ai/install.ps1 | iex

53> ```53> ```

54>54>

55> **Windows CMD:**55> **Windows CMD:**

56>56>

57> ```batch theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}57> ```batch theme={null}

58> curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd58> curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

59> ```59> ```

60>60>


72 72 

73> [tab] Homebrew73> [tab] Homebrew

74>74>

75> ```bash theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}75> ```bash theme={null}

76> brew install --cask claude-code76> brew install --cask claude-code

77> ```77> ```

78>78>


84 84 

85> [tab] WinGet85> [tab] WinGet

86>86>

87> ```powershell theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}87> ```powershell theme={null}

88> winget install Anthropic.ClaudeCode88> winget install Anthropic.ClaudeCode

89> ```89> ```

90>90>


236 236 

237Set the minimum in `/config` to have Claude Code fill in your current version, or in your settings file to type the number yourself:237Set the minimum in `/config` to have Claude Code fill in your current version, or in your settings file to type the number yourself:

238 238 

239* **In `/config`**: switch **Auto-update channel** to stable, then select **Stay on current version**. If you switch back to latest in `/config`, Claude Code clears the minimum.239* **In `/config`**: switch **Auto-update channel** to stable, then select the option to stay on your current version. If you switch back to latest in `/config`, Claude Code clears the minimum.

240* **In your [settings file](https://code.claude.com/docs/en/settings.md)**: run `claude --version` in your shell, and set `minimumVersion` to the number at the start of the output. In the same edit, set `autoUpdatesChannel` to `"stable"`.240* **In your [settings file](https://code.claude.com/docs/en/settings.md)**: run `claude --version` in your shell, and set `minimumVersion` to the number at the start of the output. In the same edit, set `autoUpdatesChannel` to `"stable"`.

241 241 

242This `~/.claude/settings.json` switches an installation on version 2.1.323 to stable:242This `~/.claude/settings.json` switches an installation on version 2.1.323 to stable:


280claude update280claude update

281```281```

282 282 

283When an update installs, the command reports `Successfully updated from <old version> to version <new version>`. If you're already on the newest version, it reports `Claude Code is up to date (<version>)`. Installs managed by Homebrew, WinGet, or apk report `Claude is up to date!` instead.283When an update installs, the command prints a line that ends with `to version <new version>`. If you're already on the newest version, it reports `Claude Code is up to date (<version>)`. Installs managed by Homebrew, WinGet, or apk report `Claude is up to date!` instead.

284 284 

285## Advanced installation options285## Advanced installation options

286 286 

287These options are for version pinning, Linux package managers, npm, network storage, and verifying binary integrity.287These options are for installing a specific version, Linux package managers, npm, network storage, and verifying binary integrity.

288 288 

289### Install a specific version289### Install a specific version

290 290 

statusline.md +1 −1

Details

15* Work across multiple sessions and need to distinguish them15* Work across multiple sessions and need to distinguish them

16* Want git branch and status always visible16* Want git branch and status always visible

17 17 

18The status line renders in its own row above the built-in footer badges and does not replace them. With a custom status line configured, Claude Code stops showing most of the footer's keyboard hints, including `esc to interrupt`, the `? for shortcuts` fallback, and the `hold space to speak` [voice dictation](https://code.claude.com/docs/en/voice-dictation.md) hint. To add clickable link badges to the footer when an ID appears in the conversation, without writing a script, configure [`footerLinksRegexes`](https://code.claude.com/docs/en/settings-reference#footerlinksregexes) instead.18The status line renders in its own row above the built-in footer badges and doesn't replace them. With a custom status line configured, Claude Code stops showing some footer hints, such as `? for shortcuts` and the `hold space to speak` [voice dictation](https://code.claude.com/docs/en/voice-dictation.md) hint. To add clickable link badges to the footer when an ID appears in the conversation, without writing a script, configure [`footerLinksRegexes`](https://code.claude.com/docs/en/settings-reference#footerlinksregexes) instead.

19 19 

20Here's an example of a [multi-line status line](#display-multiple-lines) that displays git info on the first line and a color-coded context bar on the second.20Here's an example of a [multi-line status line](#display-multiple-lines) that displays git info on the first line and a color-coded context bar on the second.

21 21 

sub-agents.md +4 −4

Details

342 342 

343##### Check an `agents` directory before a session343##### Check an `agents` directory before a session

344 344 

345To find files in an `agents` directory whose frontmatter doesn't parse, run `claude plugin validate` against the directory, for example `.claude/agents` or `~/.claude/agents`. Claude Code checks only [the directory you name](https://code.claude.com/docs/en/plugins/cli-reference.md#validate-a-directory), and doesn't flag a file whose frontmatter parses but has no `name`. Requires Claude Code v2.1.233 or later.345To find files in an `agents` directory whose frontmatter doesn't parse, run `claude plugin validate` against the directory, for example `.claude/agents` or `~/.claude/agents`. Claude Code checks only [the directory you name](https://code.claude.com/docs/en/plugins/cli-reference.md#validate-a-directory), and doesn't flag a file whose frontmatter parses but has no `name`.

346 346 

347### Choose a model347### Choose a model

348 348 


868When automatic delegation isn't enough, you can request a subagent yourself. Three patterns escalate from a one-off suggestion to a session-wide default:868When automatic delegation isn't enough, you can request a subagent yourself. Three patterns escalate from a one-off suggestion to a session-wide default:

869 869 

870* **Natural language**: name the subagent in your prompt; Claude decides whether to delegate870* **Natural language**: name the subagent in your prompt; Claude decides whether to delegate

871* **@-mention**: guarantees the subagent runs for one task871* **@-mention**: tells Claude to run the subagent for one task

872* **Session-wide**: the whole session runs as that subagent via the `--agent` flag or the `agent` setting872* **Session-wide**: the whole session runs as that subagent via the `--agent` flag or the `agent` setting

873 873 

874For natural language, there's no special syntax. Name the subagent and Claude typically delegates:874For natural language, there's no special syntax. Name the subagent and Claude typically delegates:


878Have the code-reviewer subagent look at my recent changes878Have the code-reviewer subagent look at my recent changes

879```879```

880 880 

881**@-mention the subagent.** Type `@` and pick the subagent from the typeahead, the same way you @-mention files. This ensures that specific subagent runs rather than leaving the choice to Claude:881**@-mention the subagent.** Type `@` and pick the subagent from the typeahead, the same way you @-mention files:

882 882 

883```text wrap theme={null}883```text wrap theme={null}

884@"code-reviewer (agent)" look at the auth changes884@"code-reviewer (agent)" look at the auth changes

885```885```

886 886 

887Your full message still goes to Claude, which writes the subagent's task prompt based on what you asked. The @-mention controls which subagent Claude invokes, not what prompt it receives.887Your full message still goes to Claude, which writes the subagent's task prompt based on what you asked.

888 888 

889Subagents provided by an enabled [plugin](https://code.claude.com/docs/en/plugins/overview.md) appear in the typeahead under their scoped name, such as `my-plugin:code-reviewer` or `my-plugin:review:security` when the plugin [organizes agents into subfolders](#choose-the-subagent-scope). Named background subagents currently running in the session also appear in the typeahead, showing their status next to the name.889Subagents provided by an enabled [plugin](https://code.claude.com/docs/en/plugins/overview.md) appear in the typeahead under their scoped name, such as `my-plugin:code-reviewer` or `my-plugin:review:security` when the plugin [organizes agents into subfolders](#choose-the-subagent-scope). Named background subagents currently running in the session also appear in the typeahead, showing their status next to the name.

890 890 

Details

26 26 

27| Terminal | Shift+Enter for newline |27| Terminal | Shift+Enter for newline |

28| :- | :- |28| :- | :- |

29| Ghostty, Kitty, iTerm2, WezTerm, Warp, Windows Terminal | Works without setup |29| Ghostty, Kitty, iTerm2, WezTerm, Warp, Windows Terminal 1.25 or later | Works without setup |

30| Other terminals that support the kitty keyboard protocol, such as foot and Alacritty 0.16 or later | Works without setup. Requires Claude Code v2.1.269 or later |30| Other terminals that support the kitty keyboard protocol, such as foot and Alacritty 0.16 or later | Works without setup. Requires Claude Code v2.1.269 or later |

31| VS Code, Cursor, Devin Desktop, Alacritty before 0.16, Zed | Run `/terminal-setup` once |31| VS Code, Cursor, Devin Desktop, Alacritty before 0.16, Zed | Run `/terminal-setup` once |

32| gnome-terminal, JetBrains IDEs such as PyCharm and Android Studio | Not available; use Ctrl+J or `\` then Enter |32| gnome-terminal, Windows Terminal before 1.25, JetBrains IDEs such as PyCharm and Android Studio | Not available; use Ctrl+J or `\` then Enter |

33 33 

34For VS Code, Cursor, Devin Desktop, Alacritty before 0.16, and Zed, `/terminal-setup` writes a Shift+Enter keybinding into the terminal's configuration file. On the first run you see a confirmation such as `Installed VSCode terminal Shift+Enter key binding`. Existing bindings are left in place; if you see a message such as `VSCode terminal Shift+Enter key binding already configured`, no change was made. Run `/terminal-setup` directly in the host terminal rather than inside tmux or screen, since it needs to write to the host terminal's configuration.34For VS Code, Cursor, Devin Desktop, Alacritty before 0.16, and Zed, `/terminal-setup` writes a Shift+Enter keybinding into the terminal's configuration file. On the first run you see a confirmation such as `Installed VSCode terminal Shift+Enter key binding`. Existing bindings are left in place; if you see a message such as `VSCode terminal Shift+Enter key binding already configured`, no change was made. Run `/terminal-setup` directly in the host terminal rather than inside tmux or screen, since it needs to write to the host terminal's configuration.

35 35 


140set -as terminal-features 'xterm*:extkeys'140set -as terminal-features 'xterm*:extkeys'

141```141```

142 142 

143To send notifications from a visible pane to the outer terminal, keep the `allow-passthrough` line and set [`preferredNotifChannel`](https://code.claude.com/docs/en/settings-reference#preferrednotifchannel) to `"iterm2"`, `"kitty"`, or `"ghostty"`. With this sample, a pane in a window you aren't viewing sends none. The `extended-keys` lines let tmux distinguish Shift+Enter from plain Enter so the newline shortcut works.143To use Shift+Enter, keep the last two lines, then detach from tmux, attach again, and restart Claude Code. To send notifications from a visible pane to the outer terminal, keep the `allow-passthrough` line and set [`preferredNotifChannel`](https://code.claude.com/docs/en/settings-reference#preferrednotifchannel) to `"iterm2"`, `"kitty"`, or `"ghostty"`. With this sample, a pane in a window you aren't viewing sends none.

144 144 

145A [mod's `Image`](https://code.claude.com/docs/en/plugins/mods/reference#elements) needs the `allow-passthrough` and `focus-events` lines, along with the other [requirements for drawing inside tmux](https://code.claude.com/docs/en/plugins/mods/gallery.md#draw-an-image-inside-tmux). After you add the lines, also detach from tmux, attach again, and restart Claude Code.145A [mod's `Image`](https://code.claude.com/docs/en/plugins/mods/reference#elements) needs the `allow-passthrough` and `focus-events` lines, along with the other [requirements for drawing inside tmux](https://code.claude.com/docs/en/plugins/mods/gallery.md#draw-an-image-inside-tmux). After you add the lines, also detach from tmux, attach again, and restart Claude Code.

146 146 


216> | `text` | Default foreground text |216> | `text` | Default foreground text |

217> | `inverseText` | Text drawn on top of a colored background, such as status badges |217> | `inverseText` | Text drawn on top of a colored background, such as status badges |

218> | `inactive` | Secondary text such as hints, timestamps, and disabled items |218> | `inactive` | Secondary text such as hints, timestamps, and disabled items |

219> | `subtle` | Faint borders and de-emphasized secondary text |219> | `subtle` | Faint borders, dividers, and symbols |

220> | `suggestion` | Autocomplete suggestions and selection highlight in pickers |220> | `suggestion` | Autocomplete suggestions and selection highlight in pickers |

221> | `permission` | Dialog borders, including permission prompts and pickers |221> | `permission` | Dialog borders, including permission prompts and pickers |

222> | `remember` | Memory and `CLAUDE.md` indicators |222> | `remember` | Memory and `CLAUDE.md` indicators |

Details

726* Newer models can overwrite a file they never read this session under the same conditions as [read-before-edit](#edit-tool-behavior): reading it wouldn't need a permission prompt and the Read tool is available.726* Newer models can overwrite a file they never read this session under the same conditions as [read-before-edit](#edit-tool-behavior): reading it wouldn't need a permission prompt and the Read tool is available.

727* Jupyter notebooks, and files Claude has read only partially with a [`PARTIAL view` notice](#large-files), require the read on every model.727* Jupyter notebooks, and files Claude has read only partially with a [`PARTIAL view` notice](#large-files), require the read on every model.

728 728 

729This constraint doesn't apply to new files. Before v2.1.228, every model required the read before overwriting an existing file.729This constraint doesn't apply to new files.

730 730 

731Viewing the file with Bash also satisfies this requirement under the same rules described in [Edit tool behavior](#edit-tool-behavior).731Viewing the file with Bash also satisfies this requirement under the same rules described in [Edit tool behavior](#edit-tool-behavior).

732 732 

Details

624The connection dropped while downloading the update (attempt 3/3: aborted). Check your network — proxies sometimes cut off large downloads.624The connection dropped while downloading the update (attempt 3/3: aborted). Check your network — proxies sometimes cut off large downloads.

625```625```

626 626 

627The text in parentheses names which attempt failed and the underlying network error. `claude update` precedes the message with `Error: Failed to install native update` on stderr.627The text in parentheses names which attempt failed and the underlying network error. `claude update` precedes the message with `Failed to install native update`.

628 628 

629A download that stays connected but doesn't finish within 10 minutes fails with `Download timed out: exceeded the total deadline` instead. Claude Code doesn't retry a timed-out download, because a connection too slow to finish inside the deadline won't finish on an immediate retry either. The steps below apply to both messages.629A download that stays connected but doesn't finish within 10 minutes fails with `Download timed out: exceeded the total deadline` instead. Claude Code doesn't retry a timed-out download, because a connection too slow to finish inside the deadline won't finish on an immediate retry either. The steps below apply to both messages.

630 630 


647 647 

648Take the step that matches the value in parentheses in your message:648Take the step that matches the value in parentheses in your message:

649 649 

650* **A value that starts with `sidecar_fetch_`**: run the same command again from your shell. `claude update` succeeded if it prints a line that starts with `Successfully updated from`, and `claude install` succeeded if it prints `Claude Code successfully installed!`.650* **A value that starts with `sidecar_fetch_`**: run the same command again from your shell. `claude update` succeeded if it prints a line that ends with `to version <new version>`, and `claude install` succeeded if it prints `Claude Code successfully installed!`.

651* **Any other value**: try the same command again later651* **Any other value**: try the same command again later

652 652 

653With any value, if the message repeats, [report the problem](#still-stuck) and include the full message.653With any value, if the message repeats, [report the problem](#still-stuck) and include the full message.

Details

121 121 

122### Copied text doesn't reach your local clipboard over SSH122### Copied text doesn't reach your local clipboard over SSH

123 123 

124When Claude Code runs on a remote machine over SSH, it can't run a clipboard tool on your local machine. Outside tmux, when you select text in [fullscreen rendering](https://code.claude.com/docs/en/fullscreen.md) or run `/copy`, Claude Code sends the text to your terminal as an OSC 52 escape sequence instead. Your terminal decides whether to put it on your clipboard. `/copy` reports `Copied to clipboard` whether or not the text arrived, and outside tmux the selection notice reads `sent N chars via OSC 52`.124When Claude Code runs on a remote machine over SSH, it can't run a clipboard tool on your local machine. Outside tmux, when you select text in [fullscreen rendering](https://code.claude.com/docs/en/fullscreen.md) or run `/copy`, Claude Code sends the text to your terminal as an OSC 52 escape sequence instead. Your terminal decides whether to put it on your clipboard.

125 125 

126Some terminals don't act on OSC 52. iTerm2 ignores it until you turn on **Settings > General > Selection > Applications in terminal may access clipboard**, and macOS Terminal.app doesn't support it.126Some terminals don't act on OSC 52. iTerm2 ignores it until you turn on **Settings > General > Selection > Applications in terminal may access clipboard**, and macOS Terminal.app doesn't support it. Neither the `/copy` message nor the `sent N chars via OSC 52` notice confirms that the text arrived.

127 127 

128To get the text without OSC 52:128To get the text without OSC 52:

129 129 

worktrees.md +0 −2

Details

206 206 

207This fetch never waits for input in your terminal. If git or ssh would ask for a password, a key passphrase, or confirmation of a new SSH host, the fetch fails instead and Claude Code exits with an `Error creating worktree: Failed to fetch PR/MR #<number>` message. A key that `ssh-agent` holds still works, so load your key there and run `git fetch` once by hand to record a new host before you start.207This fetch never waits for input in your terminal. If git or ssh would ask for a password, a key passphrase, or confirmation of a new SSH host, the fetch fails instead and Claude Code exits with an `Error creating worktree: Failed to fetch PR/MR #<number>` message. A key that `ssh-agent` holds still works, so load your key there and run `git fetch` once by hand to record a new host before you start.

208 208 

209Before v2.1.233, Claude Code accepted only `#<number>` and GitHub-style pull request URLs for `--worktree`, and always fetched `pull/<number>/head`.

210 

211### Copy gitignored files into worktrees209### Copy gitignored files into worktrees

212 210 

213A worktree is a fresh checkout, so untracked files like `.env` or `.env.local` from your main repository are not present. To copy them automatically when Claude creates a worktree, add a `.worktreeinclude` file to your project root.211A worktree is a fresh checkout, so untracked files like `.env` or `.env.local` from your main repository are not present. To copy them automatically when Claude creates a worktree, add a `.worktreeinclude` file to your project root.