Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 163 additions & 163 deletions content/.metadata.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions content/en/docs/claude-code/admin-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ By default, WSL reads only the Linux file path at `/etc/claude-code`. To extend

Whichever mechanism you choose, managed values take precedence over user and project settings, apart from a few security-sensitive [exceptions](/docs/en/settings#exceptions-to-managed-settings-precedence). Array settings such as `permissions.allow` and `permissions.deny` merge entries from all sources, so developers can extend managed lists but not remove from them. For `fallbackModel` and `availableModels`, the managed value replaces lower layers rather than merging.

See [Server-managed settings](/docs/en/server-managed-settings) and [Settings files and precedence](/docs/en/settings#settings-files).

### WSL sessions in Claude Code Desktop

On Windows, [Claude Code Desktop can run Code sessions inside a WSL 2 distribution](/docs/en/desktop-wsl). The session's Claude Code process runs inside the distribution, so it resolves managed settings through the WSL discovery path above: Windows-only sources don't reach it unless `wslInheritsWindowsSettings: true` is deployed.
Expand Down
10 changes: 4 additions & 6 deletions content/en/docs/claude-code/agent-sdk/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,14 +649,12 @@ To confirm the hook fires, point the webhook URL at an endpoint you can watch an

### Forward notifications to Slack

Use `Notification` hooks to receive system notifications from the agent and forward them to external services. Notifications fire for event types such as:
Use `Notification` hooks to receive system notifications from the agent and forward them to external services. In SDK sessions, Claude Code runs this hook for the following notification types:

* `permission_prompt` when Claude needs permission
* `idle_prompt` when Claude is waiting for input
* `auth_success` when authentication completes
* `elicitation_dialog`, `elicitation_complete`, and `elicitation_response` for user-prompt elicitation flows
* [`permission_prompt`](/docs/en/hooks#notification) once a permission request has waited about six seconds on your [`canUseTool` callback](/docs/en/agent-sdk/user-input). Requires TypeScript Agent SDK v0.3.233 or later, or Python Agent SDK v0.2.139 or later
* `elicitation_complete` and `elicitation_response` for user-prompt elicitation flows

In headless SDK sessions, only the elicitation events `elicitation_complete` and `elicitation_response` fire this hook; the other types are emitted by interactive UI that SDK sessions don't run. Permission requests, for example, go to the `canUseTool` callback instead.
Claude Code emits the other types, such as `idle_prompt`, `auth_success`, and `elicitation_dialog`, from interactive UI that SDK sessions don't run.

Each notification includes a `message` field with a human-readable description and optionally a `title`.

Expand Down
2 changes: 1 addition & 1 deletion content/en/docs/claude-code/agent-sdk/session-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ When the store returns the transcript, the SDK writes it into a temporary config

The SDK also seeds the temporary directory with files from your real config directory. What it copies differs by language:

* **TypeScript**: credentials, `.claude.json`, and your user `settings.json`. From `settings.json` it strips the three keys that misbehave under a temporary config directory: `enabledPlugins`, `extraKnownMarketplaces`, and any `CLAUDE_CONFIG_DIR` in the file's `env` block. Auth configured in settings, such as [`apiKeyHelper`](/docs/en/settings#available-settings), works when you resume from the store. Before Agent SDK v0.3.222, the TypeScript SDK copied only credentials and `.claude.json`.
* **TypeScript**: credentials, `.claude.json`, and your user `settings.json`. From `settings.json` it strips the keys that misbehave under a temporary config directory: `enabledPlugins`, `extraKnownMarketplaces`, its [`additionalMarketplaces`](/docs/en/settings#extraknownmarketplaces) alias, and any `CLAUDE_CONFIG_DIR` in the file's `env` block. Before Agent SDK v0.3.232, the SDK didn't strip the alias. Auth configured in settings, such as [`apiKeyHelper`](/docs/en/settings#available-settings), works when you resume from the store. Before Agent SDK v0.3.222, the TypeScript SDK copied only credentials and `.claude.json`.
* **Python**: credentials and `.claude.json` only, so an app that authenticates through `apiKeyHelper` in your user `settings.json` fails with `Not logged in` when resuming from a store. An `apiKeyHelper` in managed or project settings still works, because Claude Code reads those files from locations that `CLAUDE_CONFIG_DIR` doesn't affect.

When the store has nothing for the session, the SDK runs under your real config directory instead, and the outcome depends on which option you passed:
Expand Down
99 changes: 97 additions & 2 deletions content/en/docs/claude-code/agent-sdk/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,9 @@ The receipt is a snapshot taken at the moment the interrupt is processed, and on

### `SDKControlGetContextUsageResponse`

Return type of [`getContextUsage()`](#query-object). This is the same payload the `/context` command renders in an interactive session, so alongside the token counts it carries display fields such as `color`, `gridRows`, and `percentage` that `/context` uses to draw its usage grid.
Return type of [`getContextUsage()`](#query-object). This is the same payload Claude Code renders for the `/context` command in an interactive session, so alongside the token counts it carries display fields such as `color` and `gridRows` that Claude Code uses to draw the `/context` usage grid.

When you send `/context` as a prompt instead of calling the method, Claude Code attaches an [`SDKContextUsage`](#sdkcontextusage) payload to the `context_usage` field of the assistant message that delivers the result. That field requires Agent SDK v0.3.232 or later.

```typescript theme={null}
type SDKControlGetContextUsageResponse = {
Expand Down Expand Up @@ -764,7 +766,9 @@ Read token attribution from the collection fields:
* `memoryFiles` lists each loaded memory file with its cost.
* `skills.skillFrontmatter` attributes the skill listing's tokens to each included skill. The per-skill counts measure each skill's listing entry as Claude Code actually sends it, which can be shorter than the skill's full frontmatter. Compare `skills.totalSkills` with `skills.includedSkills` to see whether every discovered skill made it into the listing.

`totalTokens` is the session's current context usage, and `maxTokens` is the window that usage is measured against. That window is the model's context window, or the lower auto-compaction window when one applies. Claude Code leaves the optional `deferredBuiltinTools`, `systemTools`, and `systemPromptSections` diagnostics unset, so expect them to be absent even though the type declares them.
`totalTokens` is the session's current context usage, and `maxTokens` is the window that usage is measured against. That window is the model's context window, or the lower auto-compaction window when one applies. `rawMaxTokens` carries the same value as `maxTokens`, and `percentage` is `totalTokens` as a rounded percentage of that window.

Claude Code leaves the optional `deferredBuiltinTools`, `systemTools`, and `systemPromptSections` diagnostics unset, so expect them to be absent even though the type declares them.

### `SDKControlReadFileResponse`

Expand Down Expand Up @@ -1144,6 +1148,7 @@ type SDKAssistantMessage = {
error?: SDKAssistantMessageError;
aborted?: true;
timestamp?: string;
context_usage?: SDKContextUsage;
};
```

Expand All @@ -1155,6 +1160,8 @@ The `message` field is a [`BetaMessage`](https://platform.claude.com/docs/en/api

`timestamp` is the ISO 8601 time when the message's content finished generating on the process that produced it. The value comes from that machine's clock, so use it for display only and don't order messages by it. One API turn can produce several assistant messages that share a `message.id`, each with its own `timestamp`. When the field is absent, fall back to the time you received the message.

`context_usage` is a structured copy of the `/context` report, typed as [`SDKContextUsage`](#sdkcontextusage), and requires Agent SDK v0.3.232 or later. When you send `/context` as a prompt, Claude Code delivers the report as an assistant message whose `message.content` holds the markdown table, and attaches `context_usage` to that same message. Claude Code doesn't set the field on any other assistant message, and earlier versions deliver the `/context` table without it, so read the breakdown from the field when it's present and fall back to the markdown text when it isn't.

### `SDKUserMessage`

User input message.
Expand Down Expand Up @@ -1464,6 +1471,94 @@ type SDKPermissionDenial = {
};
```

### `SDKContextUsage`

Structured form of the `/context` report, carried as `context_usage` on the [`SDKAssistantMessage`](#sdkassistantmessage) that delivers a `/context` result. Agent SDK v0.3.232 and later export the type. Unlike [`SDKControlGetContextUsageResponse`](#sdkcontrolgetcontextusageresponse), it carries only the data needed to render the usage breakdown, without display fields such as `color` and `gridRows`.

```typescript theme={null}
type SDKContextUsage = {
model: string;
total_tokens: number;
raw_max_tokens: number;
percentage: number;
over_limit?: {
tokens_over: number;
kind: "hard_limit" | "compaction_window";
};
categories: SDKContextUsageCategory[];
mcp_tools: {
name: string;
server_name: string;
tokens: number;
}[];
memory_files: {
path: string;
type: string;
tokens: number;
}[];
agents: {
agent_type: string;
source: string;
tokens: number;
}[];
skills?: {
name: string;
source: string;
plugin_name?: string;
tokens: number;
}[];
};
```

The table lists what Claude Code puts in each field. The fields from `model` through `over_limit` describe the session as a whole, and the collection fields attribute tokens to individual items.

| Field | Type | Description |
| ---------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model` | `string` | The main loop's model Claude Code computed the usage for, not a subagent's |
| `total_tokens` | `number` | Claude Code's estimate of the tokens in use. Not clamped to the window, so it can exceed `raw_max_tokens` when the session is over the limit |
| `raw_max_tokens` | `number` | The model's context window, or the lower [auto-compact window](/docs/en/model-config#context-window-and-auto-compaction) when one applies, such as one you set or the 200K boundary Claude Code applies to some models with a 1M-token window. Claude Code measures `total_tokens` against this window |
| `percentage` | `number` | `total_tokens` as a rounded percentage of `raw_max_tokens`, so it can exceed 100 when the session is over the limit |
| `over_limit` | `object` | Present only when `total_tokens` exceeds `raw_max_tokens`. `tokens_over` is the amount over, and `kind` says how Claude Code resolved the window |
| `categories` | [`SDKContextUsageCategory`](#sdkcontextusagecategory)`[]` | One entry per row of the usage-by-category breakdown |
| `mcp_tools` | `object[]` | Tokens attributed to each MCP tool, with its wire name, such as `mcp__linear__create_issue`, and its `server_name` |
| `memory_files` | `object[]` | Tokens attributed to each loaded memory file, with its `path` and a source label such as `Project` or `User` in `type` |
| `agents` | `object[]` | Tokens attributed to each custom subagent definition, with a source identifier such as `projectSettings`, `userSettings`, or `plugin`. Built-in subagents aren't listed |
| `skills` | `object[]` | Tokens attributed to each skill in the skill listing, with a source identifier and, for plugin skills, the plugin's name in `plugin_name`. Absent when no skills contribute tokens |

`over_limit.kind` records how Claude Code resolved the window, not whether the API accepts the next request:

* `hard_limit`: the window is what Claude Code believes to be the model's own limit, past which the API refuses requests
* `compaction_window`: the window is a compaction-policy window, which may or may not coincide with the model's limit

Claude Code evolves the type additively, adding new data as optional fields rather than reshaping existing ones. Read the fields you know and ignore any you don't recognize.

### `SDKContextUsageCategory`

One row of the `/context` usage-by-category breakdown.

```typescript theme={null}
type SDKContextUsageCategory = {
name: string;
tokens: number;
kind: "used" | "free" | "buffer" | "deferred";
};
```

The table lists what Claude Code puts in each field of a row.

| Field | Type | Description |
| -------- | -------- | -------------------------------------------------------------------------------------------------------- |
| `name` | `string` | The row's display name as `/context` prints it, such as `Messages`. Classify rows by `kind`, not by name |
| `tokens` | `number` | The row's token count. Rows can carry zero tokens |
| `kind` | `string` | What the row represents: `used`, `free`, `buffer`, or `deferred` |

Each `kind` value says what the row's tokens are:

* `used`: content that occupies the context window
* `free`: the remaining window
* `buffer`: the compaction reserve
* `deferred`: tool schemas Claude Code holds out of the window and excludes from the usage calculation, listed for awareness

### `SDKMessageOrigin`

Provenance of a user-role message. This appears as `origin` on [`SDKUserMessage`](#sdkusermessage) and is forwarded onto the corresponding [`SDKResultMessage`](#sdkresultmessage) so you can tell what triggered a given turn.
Expand Down
7 changes: 1 addition & 6 deletions content/en/docs/claude-code/claude-apps-gateway-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,7 @@ upstreams:
auth:
api_key: ${ANTHROPIC_API_KEY}

# Per-upstream model IDs are keyed on the upstream's `name:`; an upstream
# without a `name:` defaults to its provider string (e.g. `bedrock`). For a
# built-in Claude model, an upstream you leave out of the map still serves it
# with that provider's default ID; list the upstream to override the ID, for
# example with a provisioned-throughput ARN. Only a custom `id` that isn't a
# built-in model skips the upstreams missing from its map.
# Per-upstream model IDs are keyed on the upstream's `name:`.
models:
- id: claude-opus-4-8
label: Claude Opus 4.8
Expand Down
Loading
Loading