Changes on
48 changes detected
--- a/admin.md
+++ b/admin.md
@@ -83,6 +83,41 @@
None of these controls sandboxes a mod. A mod you allow runs as the user, with the user’s access to files, processes, and the network.
+###
+
+
+
+Know which hooks of a user’s mod don’t run
+
+Where the built-in guard loads, a hook that a user’s mod registers on one of these events never runs, and `/plugin` tells that user so in a note. In the [`session.append`](</docs/en/plugins/mods/reference#session>) rows, `door` is the kind of stored row the hook is filtered to.
+
+Hook on| What the event is
+---|---
+[`classic.<Event>`](</docs/en/plugins/mods/events#hook-the-settings-hook-events>), such as `classic.Stop`| A [settings hook event](</docs/en/hooks#hook-events>)
+[`prompt.compose`](</docs/en/plugins/mods/reference#prompts-and-what-claude-reads>)| The system prompt’s list of sections
+`prompt.section`| One section of the system prompt
+`prompt.context`| The context sent with a conversation’s first message
+`prompt.attachment`| A message Claude Code adds for Claude, such as a reminder
+`skill.prompt`| A skill’s text as it’s expanded for Claude
+`attribution.text`| Commit or pull request attribution text
+[`session.compact`](</docs/en/plugins/mods/reference#session>)| A compaction of the conversation
+`settings.read`| A read of settings, such as a mod’s `$.settings.read` call
+`session.append{door=attachment}`| The stored row for a message Claude Code adds for Claude
+`session.append{door=hook-context}`| The stored row for context from a settings hook
+`session.append{door=compaction}`| The stored rows for a compaction’s summary and boundary
+
+The guard also passes over a user’s hooks in some other cases, such as the descriptions of your organization’s tools, on [`tool.describe`](</docs/en/plugins/mods/reference#tools>), and the stored row for a skill’s text. `/plugin` shows no note for those. If a hook on another event does nothing, see [Find out why a mod does nothing](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>). The note appears in the plugin’s details and in the **Errors** tab of `/plugin`. It requires Claude Code v2.1.299 or later. It names each hook from the table as the mod registered it, as in this example:
+
+ Its hooks on classic.Stop, prompt.section do not run here: where an organization manages Claude Code, these events pass over the plugins you install
+ Only a plugin that counts as your organization's own runs hooks on these events. An administrator sets that up in managed settings
+
+To let these hooks run, change managed settings in one of two ways:
+
+ * **Run the mod as your organization’s** : install the mod so that it counts as yours. Its hooks on these events then run, and the guard stays loaded for every other mod. The mod turns on for everyone who receives these settings, and it has to sit in a directory you place on each machine. If you list it in `prependPlugins`, keep `sec-default@builtin` in the list.
+ * **Remove the guard** : leave `sec-default@builtin` out of `prependPlugins`. An empty list, `"prependPlugins": []`, is enough. You lose the whole guard, not only these events. A user’s mod can then do what the guard otherwise stops it from doing, and the guard’s options don’t apply.
+
+If you deliver a list without the guard through [server-managed settings](</docs/en/server-managed-settings#fetch-and-caching-behavior>), the guard stays loaded until the server confirms the settings for the session. To confirm either change on a machine that runs v2.1.299 or later, open `/plugin` in a session there and check that the note is gone. A `session.append` hook with no `door` filter still runs and gets no note, but the stored rows in the table don’t reach it.
+
##
@@ -128,7 +163,7 @@
`$.prompt.submit`| Submits a prompt, and can send it as the user’s own words
`$.session.send`| Sends a message that another session’s, subagent’s, or [teammate’s](</docs/en/agent-teams>) Claude reads
-In the `hooks:` line, [`tool.call`](</docs/en/plugins/mods/reference#tools>) and [`prompt.submit`](</docs/en/plugins/mods/reference#prompts-and-what-claude-reads>) mean the mod sees every tool call and every prompt, and can change them. [`session.append`](</docs/en/plugins/mods/reference#session>) means the mod can rewrite each row of the conversation before it’s stored. [`ui.render{component=AskUserQuestion}`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) means the mod can redraw the dialog Claude uses to ask the user a question. `tool.check` means the mod can approve or deny a tool call before a permission prompt appears. Know what happens by default lists which of your rules and hooks take precedence over its answer.
+In the `hooks:` line, [`tool.call`](</docs/en/plugins/mods/reference#tools>) and [`prompt.submit`](</docs/en/plugins/mods/reference#prompts-and-what-claude-reads>) mean the mod sees every tool call and every prompt, and can change them. [`session.append`](</docs/en/plugins/mods/reference#session>) means the mod can rewrite each row of the conversation before it’s stored, apart from the rows the guard passes over. [`ui.render{component=AskUserQuestion}`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) means the mod can redraw the dialog Claude uses to ask the user a question. `tool.check` means the mod can approve or deny a tool call before a permission prompt appears. Know what happens by default lists which of your rules and hooks take precedence over its answer.
##
--- a/admin-setup.md
+++ b/admin-setup.md
@@ -82,7 +82,7 @@
[Sandboxing](</docs/en/sandboxing>)| OS-level filesystem and network isolation with domain allowlists| `sandbox.enabled`, `sandbox.network.allowedDomains`
[Managed policy CLAUDE.md](</docs/en/memory#deploy-organization-wide-claude-md>)| Organization-wide behavioral guidance for Claude rather than a client-enforced rule| File at the managed policy path
[MCP server control](</docs/en/managed-mcp>)| Restrict which MCP servers users can add or connect to, deploy a fixed set, or provide remote servers to every user alongside their own| `allowedMcpServers`, `deniedMcpServers`, `allowManagedMcpServersOnly`, `managedMcpServers`, or a deployed `managed-mcp.json` file
-[Plugin marketplace control](</docs/en/plugins/org#restrict-what-users-can-install>)| Restrict which marketplace sources users can add and install from, reject the CLI flags that sideload plugins, agents, and MCP servers for a single run, block [`command` plugin sources](</docs/en/plugins/marketplace-reference#command-plugin-source>), and allowlist which marketplaces’ plugins can be suggested| `strictKnownMarketplaces`, `blockedMarketplaces`, `disableSideloadFlags`, `disableCommandPluginSources`, `pluginSuggestionMarketplaces`
+[Plugin marketplace control](</docs/en/plugins/org#restrict-what-users-can-install>)| Restrict which marketplace sources users can add and install from, and reject the CLI flags that sideload plugins, agents, and MCP servers for a single run. Block [`command` plugin sources](</docs/en/plugins/marketplace-reference#command-plugin-source>), and allowlist which marketplaces’ plugins can be suggested in the terminal| `strictKnownMarketplaces`, `blockedMarketplaces`, `disableSideloadFlags`, `disableCommandPluginSources`, `pluginSuggestionMarketplaces`
[Customization lockdown](</docs/en/settings-reference#strictpluginonlycustomization>)| Block skills, agents, hooks, and MCP servers from user and project sources, so they can only come from plugins or managed settings. Locking skills also stops the [skills your developers enable on claude.ai](</docs/en/skills#where-synced-skills-load>) from syncing| `strictPluginOnlyCustomization`
[Disable claude.ai sync](</docs/en/settings-reference#syncclaudeaiskills>)| Stop Claude Code from loading the [skills](</docs/en/skills#how-synced-skills-behave>) and [plugins](</docs/en/plugins/loading#synced-plugins>) your developers enable on claude.ai. If you turn off Skills for your organization on claude.ai, Claude Code stops syncing both, and on v2.1.273 or later it also removes the ones it already synced. To stop either one without turning Skills off, set its key to `false` in managed settings| `syncClaudeAiSkills`, `syncClaudeAiPlugins`
[Hook restrictions](</docs/en/settings-reference#allowmanagedhooksonly>)| Restrict which hooks run and restrict HTTP hook URLs; see [what runs under `allowManagedHooksOnly`](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>) for the full effect list| `allowManagedHooksOnly`, `allowedHttpHookUrls`
--- a/agent-loop.md
+++ b/agent-loop.md
@@ -247,9 +247,9 @@
`"default"`| Tool calls that need approval and aren’t covered by allow rules trigger your `canUseTool` callback; no callback means deny| Interactive applications with a custom approval callback
`"acceptEdits"`| Auto-approves file edits and common filesystem commands (`mkdir`, `touch`, `mv`, `cp`, etc.); other Bash commands follow default rules| You trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory
`"plan"`| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback| You want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made
-`"dontAsk"`| Never prompts. Tools pre-approved by [permission rules](</docs/en/settings-reference#permission-settings>) run, and so do calls that need no approval in `default` mode, such as file reads inside your working directories. Every call that would otherwise prompt is denied, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). `AskUserQuestion`, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>), and [reads from network paths](</docs/en/permissions#network-paths>) are denied even if you’ve allowed them| You want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent
+`"dontAsk"`| Never prompts. Tools pre-approved by [permission rules](</docs/en/settings-reference#permission-settings>) run, and so do calls that need no approval in `default` mode, such as file reads inside your working directories. Every call that would otherwise prompt is denied, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). A few calls, such as [reads from network paths](</docs/en/permissions#network-paths>), are denied even if you’ve allowed them. For the list, see [Don’t ask mode](</docs/en/agent-sdk/permissions#don%E2%80%99t-ask-mode-dontask>)| Headless agents with nobody to approve calls
`"auto"`| Uses a model classifier to review actions such as shell commands and network requests, allowing or blocking each one it reviews. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and the decision order| Autonomous agents that still want safety guardrails on tool use
-`"bypassPermissions"`| Runs all allowed tools without asking, except tools matched by an explicit [`ask` rule](</docs/en/settings-reference#permission-settings>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction. The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply. See [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) for the precedence order. In the TypeScript SDK, also requires `allowDangerouslySkipPermissions: true` in `options`. Can’t be used when running as root on Unix. Use only in isolated environments where the agent’s actions can’t affect systems you care about| CI, containers, or other isolated environments
+`"bypassPermissions"`| Runs tool calls without asking for approval, including calls to tools you didn’t list in `allowedTools`. A few calls still go to your `canUseTool` callback, listed under [Bypass permissions mode](</docs/en/agent-sdk/permissions#bypass-permissions-mode-bypasspermissions>). In the TypeScript SDK, also requires `allowDangerouslySkipPermissions: true` in `options`. Can’t be used when running as root on Unix. Use only in isolated environments where the agent’s actions can’t affect systems you care about| CI, containers, or other isolated environments
For interactive applications, use `"default"` with a tool approval callback to surface approval prompts. For autonomous agents on a dev machine, `"acceptEdits"` auto-approves file edits and common filesystem commands (`mkdir`, `touch`, `mv`, `cp`, etc.) while still gating other `Bash` commands behind allow rules. Reserve `"bypassPermissions"` for CI, containers, or other isolated environments. See [Permissions](</docs/en/agent-sdk/permissions>) for full details.
--- a/agent-teams.md
+++ b/agent-teams.md
@@ -176,7 +176,7 @@
Assign and claim tasks
-The shared task list coordinates work across the team. The lead creates tasks and teammates work through them. Tasks have three states: pending, in progress, and completed. Tasks can also depend on other tasks: a pending task with unresolved dependencies cannot be claimed until those dependencies are completed. Agents [without the Task tools](</docs/en/tools-reference#task-tool-availability>) coordinate through messages instead of the shared task list. The lead can assign tasks explicitly, or teammates can self-claim:
+The shared task list coordinates work across the team. The lead creates tasks and teammates work through them. Tasks have three states: pending, in progress, and completed. A task can also depend on other tasks and shows as blocked in the task list until they’re completed. Teammates don’t self-claim a blocked task, but you or the lead can still assign it. Agents [without the Task tools](</docs/en/tools-reference#task-tool-availability>) coordinate through messages instead of the shared task list. The lead can assign tasks explicitly, or teammates can self-claim:
* **Lead assigns** : tell the lead which task to give to which teammate
* **Self-claim** : after finishing a task, a teammate picks up the next unassigned, unblocked task on its own
--- a/agent-view.md
+++ b/agent-view.md
@@ -186,7 +186,12 @@
* A finished session: its result
* A working session: its full status sentence
-Any pull requests linked to the session are listed next. For a session that’s waiting on you, a line such as `waiting 3m` below them shows how long it has been waiting, and it’s the only time shown in the panel. The age at the right edge of the row is a different number: it counts from when the session started. Most of the time the peek panel is enough and you don’t need to open the full transcript. Type a reply in the peek panel and press `Enter` to send it to that session. Prefix a reply with `!` to send a Bash command instead. What happens to the reply depends on the session and on what you send:
+Any pull requests linked to the session are listed next. One more line appears below them for a session that’s waiting on you or running in safe mode:
+
+ * A line such as `waiting 3m`: how long the session has been waiting on you. The age at the right edge of the row is a different number: it counts from when the session started
+ * `safe mode · customizations are off`: this session runs with [your customizations turned off](</docs/en/debug-your-config#test-against-a-clean-configuration>) because you started it from your shell with `claude --bg --safe-mode`. You can leave it as it is. To continue the conversation with your customizations back on, run `claude stop <id>` and then [`claude --resume`](</docs/en/sessions#resume-a-session>), both in your shell
+
+Most of the time the peek panel is enough and you don’t need to open the full transcript. Type a reply in the peek panel and press `Enter` to send it to that session. Prefix a reply with `!` to send a Bash command instead. What happens to the reply depends on the session and on what you send:
* A session that’s working: `/model`, `/effort`, `/rename`, and `/usage` run right away. Other replies join the session’s [message queue](</docs/en/interactive-mode#queue-messages-while-claude-works>) instead of interrupting the response, and take effect [when queued input does](</docs/en/interactive-mode#when-claude-code-sends-what-you-queued>). Other [commands](</docs/en/commands>) wait for the turn to end, even ones that run as soon as you type them at a session’s own prompt
* A reply that is exactly `/stop`: stops the session at once instead of being delivered to it, whether the session is working or waiting on you
@@ -414,7 +419,13 @@
What carries over when you background
-Backgrounding starts a fresh process that resumes from the saved conversation, and in-flight background work moves to it. Running background shell commands, backgrounded subagents, dynamic workflows, scheduled tasks you created with [`/loop`](</docs/en/scheduled-tasks>), and Claude’s [automatic replies to artifact comments](</docs/en/artifacts#let-claude-reply-to-comments-on-its-own>) all carry over and keep running there. A subagent moves together with everything it started, so it carries over only when all of that work can move too. When a [dynamic workflow](</docs/en/workflows>) still has subagents running, Claude Code asks before backgrounding with the `Background this session?` dialog, which says how many subagents would restart. Choose `Stay` to let them finish first. If you confirm, Claude Code replays the run in the background session: subagents that were still running start over from the beginning, so the tokens they used so far are spent again. See [Resume after a pause](</docs/en/workflows#resume-after-a-pause>) for which completed subagents return their saved results and which run again. Claude Code stops background work that can’t carry over, such as a running [monitor](</docs/en/tools-reference#monitor-tool>), and stops a backgrounded subagent that owns a monitor along with it. When any such work is running, Claude Code shows the `Background this session?` dialog so you can confirm before it stops the work. Once in the background, the session can start new subagents, monitors, and background commands, and those keep running across later detach and reattach. Configuration flags from the original launch carry through to the backgrounded session, so its MCP servers, settings, and fallback model remain in effect:
+When you background the session, each kind of in-flight background work either carries over to the background session, continues only when Claude relaunches it there, or stops:
+
+ * **Carries over** : running background shell commands, backgrounded subagents, scheduled tasks you created with [`/loop`](</docs/en/scheduled-tasks>), and Claude’s [automatic replies to artifact comments](</docs/en/artifacts#let-claude-reply-to-comments-on-its-own>) keep running in the background session. A subagent moves together with everything it started, so it carries over only when all of that work can move too.
+ * **Continues only when Claude relaunches it** : a running [dynamic workflow](</docs/en/workflows>). If the workflow hasn’t continued when you check on the background session, ask Claude to relaunch it.
+ * **Stops** : work that can’t move to the background session, such as a running [monitor](</docs/en/tools-reference#monitor-tool>). When any such work is running, Claude Code shows the `Background this session?` dialog so you can confirm before it stops the work. A backgrounded subagent that owns a monitor stops along with the monitor.
+
+Once in the background, the session can start new subagents, monitors, and background commands, and those keep running across later detach and reattach. Configuration flags from the original launch carry through to the backgrounded session, so its MCP servers, settings, and fallback model remain in effect:
* `--mcp-config` and `--strict-mcp-config`
* `--settings`
@@ -425,6 +436,10 @@
* `--allow-dangerously-skip-permissions`
Directories you added during the session with [`/add-dir`](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) also carry through. Carrying `--allow-dangerously-skip-permissions` keeps `bypassPermissions` reachable in the backgrounded session, but it doesn’t grant anything new: the mode still needs your [acceptance of the bypass disclaimer](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) on record.
+
+##### Dynamic workflows when you background
+
+If a [dynamic workflow](</docs/en/workflows>) hasn’t continued after you backgrounded its session, ask Claude to [relaunch the workflow](</docs/en/workflows#resume-after-you-leave-the-session>). The run continues only when Claude relaunches it in the background session, and Claude Code can ask you to approve that relaunch first. The session’s conversation shows a notice that the workflow `could not be resumed`. When Claude relaunches the workflow, any of its subagents that were still running when you backgrounded the session start over and spend their tokens again. If you press `←` or run `/background` while any are still running, the `Background this session?` dialog says how many. To let them finish first, choose `Stay`.
###
@@ -741,7 +756,7 @@
* **After an auto-update** : the supervisor restarts itself onto the new version and moves idle sessions over in the background. Sessions that are working, waiting on you, or attached aren’t interrupted.
* **The supervisor itself stops** , for example because its process was ended from outside Claude Code: on macOS and Linux, your sessions stop unless a new supervisor connects within about a minute. To start one, run `claude agents` in your shell. After that minute, see Keep sessions running after the supervisor stops.
-When a session’s process stops or restarts, the background shell commands, dynamic workflows, and background subagents Claude started in it carry over to its next process; running monitors and shell commands a subagent started stop with the process. Deleting the session stops everything it carried over. To stop all of it with the process instead, set [`CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF`](</docs/en/env-vars#variables>) to `1`. The supervisor and its sessions authenticate with the same stored credentials as your interactive sessions. For which settings and shell variables reach a session, including `PATH`, see Settings and provider. For gateway endpoints, see LLM gateway.
+When a session’s process stops or restarts, the background shell commands and background subagents Claude started in it carry over to its next process. A dynamic workflow continues only when Claude relaunches it. Running monitors and shell commands a subagent started stop with the process. If you delete the session, everything it carried over stops. To stop all of it with the process instead, set [`CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF`](</docs/en/env-vars#variables>) to `1`. The supervisor and its sessions authenticate with the same stored credentials as your interactive sessions. For which settings and shell variables reach a session, including `PATH`, see Settings and provider. For gateway endpoints, see LLM gateway.
####
@@ -808,10 +823,10 @@
Backgrounding shows a `Background this session?` dialog
-If you press `←` to background the current session and Claude Code shows a `Background this session?` dialog, the session has in-flight background work that backgrounding would stop, restart, or leave running unattended, and Claude Code asks before it does any of those:
+When you press `←` to background a session, a `Background this session?` dialog means the session has in-flight background work that would stop, be interrupted, or keep running unattended:
* **Work that can’t move** : the session has work that can’t move to the background session, such as a running [monitor](</docs/en/tools-reference#monitor-tool>). The dialog names the background work Claude Code would stop and, separately, counts the tasks that carry over.
- * **A workflow with running subagents** : a [dynamic workflow](</docs/en/workflows>) still has subagents running. The workflow itself carries over, but its running subagents restart from the beginning, and the dialog says how many.
+ * **A workflow with running subagents** : a [dynamic workflow](</docs/en/workflows>) still has subagents running. Those subagents stop if you background anyway, and the dialog says how many. They start over from the beginning when Claude relaunches the workflow in the background session.
* **Automatic artifact replies** : Claude is [replying to comments on an artifact on its own](</docs/en/artifacts#let-claude-reply-to-comments-on-its-own>). Those replies continue in the background session, and the dialog says so.
Run `/tasks` to see everything that’s running, then confirm to background anyway or choose `Stay` to let the work finish first. See What carries over when you background for which kinds of work carry over and which Claude Code stops.
@@ -1083,7 +1098,7 @@
v2.1.200| An older Claude Code version that rewrites the session list in `roster.json` preserves fields written by a newer version, matching the existing `state.json` guarantee, so sessions started by the newer version keep accepting input after the supervisor restarts. When you open a session that has stopped responding, the supervisor restarts its process and the session continues the interrupted response from where it left off. Agent view applies a `--plugin-dir` flag placed after `agents` to its own subagent and skill autocomplete in the dispatch input as well as dispatched sessions.
v2.1.199| A background session whose process exits before it finishes starting on a low-memory host shows `possibly low memory — free some up and retry` in its row status instead of only the bare exit reason. Backgrounding a session with `←` or `/background` carries its `/color` over to the new row.
v2.1.198| Agent view sends a notification through `preferredNotifChannel` when a background session needs input, finishes, or fails, and fires the `Notification` hook with the `agent_needs_input` or `agent_completed` type. `←` and `/exit` inside `claude attach <id>` return to agent view instead of exiting to the shell; `Ctrl+Z` returns to the shell. A background session that isolated its work in a worktree commits, pushes its own isolated branch, never `main` or `master`, and opens a draft pull request when it finishes instead of asking first. `/login` runs in agent view and opens the sign-in dialog. The `Background work is running` exit dialog offers `Move to background and exit`. The exit handoff also covers background subagents, which resume from their transcript on the next wake instead of being reported as failed. `claude --bg` combined with `-p` or `--print` is rejected with an error. The background session host requests macOS Local Network permission on first LAN access instead of failing with `connect: no route to host`.
-v2.1.196| A single `←` press backgrounds a foreground session; earlier versions required two presses, with a footer hint and a confirm. `--dangerously-skip-permissions` passed to `claude agents` shows the bypass disclaimer instead of being silently dropped. Interactive sessions you never named carry a default name such as `my-app-3f` in session listings and `claude agents --json`. Background shell commands and dynamic workflows survive the session’s process being stopped, restarted, or updated, including on Windows; set `CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF=1` to turn the handoff off. A transcript misread as empty on restart is renamed with an `.orphaned-` suffix instead of deleted.
+v2.1.196| A single `←` press backgrounds a foreground session; earlier versions required two presses, with a footer hint and a confirm. `--dangerously-skip-permissions` passed to `claude agents` shows the bypass disclaimer instead of being silently dropped. Interactive sessions you never named carry a default name such as `my-app-3f` in session listings and `claude agents --json`. Background shell commands survive the session’s process being stopped, restarted, or updated, including on Windows; set `CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF=1` to turn the handoff off. A transcript misread as empty on restart is renamed with an `.orphaned-` suffix instead of deleted.
v2.1.195| In-flight background work carries over when you background a session on Windows too. The `Completed` group fills the remaining vertical space and the header compacts on short terminals. An older Claude Code version no longer drops newer sessions’ `state.json` fields or hides those sessions from `claude agents`. Attaching to a stopped session switches immediately instead of showing a blank screen for up to five seconds. A supervisor that can’t accept connections exits and releases its lock on its own.
v2.1.191| `claude --bg` with an `--agent` name that doesn’t match any of your subagents fails the launch: the session exits immediately with an `--agent '<name>' not found` error instead of running with the default agent.
v2.1.174| Background sessions no longer inherit gateway endpoint variables such as `ANTHROPIC_BASE_URL` from the supervisor’s launch shell; the supervisor supplies a fresh credential snapshot to pre-warmed workers, fixing spurious `Could not resolve authentication method` errors.
--- a/anthropic-marketplaces.md
+++ b/anthropic-marketplaces.md
@@ -33,7 +33,7 @@
The demo marketplace in `anthropics/claude-code`
-If a tutorial or an older set of instructions tells you to run `/plugin marketplace add anthropics/claude-code`, that adds the demo marketplace, named `claude-code-plugins`. It isn’t the official marketplace. Most of the demo marketplace’s plugins are also in the official marketplace under the same names. For example, `code-review`, `feature-dev`, `commit-commands`, and `security-guidance` are in both. Install those from `claude-plugins-official` so you don’t have two copies installed.
+If a tutorial or an older set of instructions tells you to run `/plugin marketplace add anthropics/claude-code`, that adds the demo marketplace, named `claude-code-plugins`. It isn’t the official marketplace. Most of the demo marketplace’s plugins are also in the official marketplace under the same names. For example, `code-review`, `feature-dev`, and `commit-commands` are in both. Install those from `claude-plugins-official` so you don’t have two copies installed.
##
Show diff (1198 lines)
--- a/best-practices.md
+++ b/best-practices.md
@@ -1,593 +1,605 @@
-Claude Code is an agentic coding environment. Unlike a chatbot that answers questions and waits, Claude Code can read your files, run commands, make changes, and autonomously work through problems while you watch, redirect, or step away entirely. This changes how you work. Instead of writing code yourself and asking Claude to review it, you describe what you want and Claude figures out how to build it. Claude explores, plans, and implements. But this autonomy still comes with a learning curve. Claude works within certain constraints you need to understand. This guide covers patterns that have proven effective across Anthropic’s internal teams and for engineers using Claude Code across various codebases, languages, and environments. For how the agentic loop works, see [How Claude Code works](</docs/en/how-claude-code-works>).
-
-* * *
-
-Most best practices are based on one constraint: Claude’s context window fills up fast, and performance degrades as it fills. Claude’s context window holds your entire conversation, including every message, every file Claude reads, and every command output. However, this can fill up fast. A single debugging session or codebase exploration might generate and consume tens of thousands of tokens. This matters since LLM performance degrades as context fills. When the context window is getting full, Claude may start “forgetting” earlier instructions or making more mistakes. The context window is the most important resource to manage. To see how a session fills up in practice, [watch an interactive walkthrough](</docs/en/context-window>) of what loads at startup and what each file read costs. Track context usage continuously with a [custom status line](</docs/en/statusline>), and see [Reduce token usage](</docs/en/costs#reduce-token-usage>) for strategies on reducing token usage.
-
-* * *
-
-##
-
-
-
-Give Claude a way to verify its work
-
-Give Claude a check it can run: tests, a build, a screenshot to compare. It’s the difference between a session you watch and one you walk away from.
-
-Claude stops when the work looks done. Without a check it can run, “looks done” is the only signal available, and you become the verification loop: every mistake waits for you to notice it. Give Claude something that produces a pass or fail, and the loop closes on its own. Claude does the work, runs the check, reads the result, and iterates until the check passes. The check is anything that returns a signal Claude can read in the conversation: a test suite, a build exit code, a linter, a script that diffs output against a fixture, or a [browser screenshot](</docs/en/chrome>) compared against a design. Run [`/verify`](</docs/en/skills#run-and-verify-your-app>) yourself after Claude’s check passes to confirm the change against the running app.
-
-Strategy| Before| After
+Claude Code is built in a way that, in most cases, your first plain prompt in a fresh session already does the right thing, without any setup on your part. For example:
+
+ * To let commands run safely without you approving each one, new terminal and VS Code sessions start in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), where a classifier reviews anything risky before it runs.
+ * To keep your main conversation focused while independent work happens in parallel, Claude delegates to subagents and checks in only when it has to.
+ * To keep a long session going without you managing it, your conversation is compacted automatically before the context window fills.
+
+This page covers what to do when the defaults aren’t enough. That usually happens when your project has knowledge, rules, or constraints that Claude can’t see from the code alone:
+
+ * A deploy process that lives in someone’s head
+ * A file that must never be read
+ * A check that has to pass before anything counts as done
+ * A budget you need to stay under
+
+No default can know those things about your project, so this is where a small amount of setup on your side pays off. When a session doesn’t go the way you expected, it’s almost always one of these:
+
+ * Claude built something different from what you had in mind, or it has to rediscover the same fact at the start of every session. It’s missing information it can’t get from reading the repo. See Tell Claude what it can’t see.
+ * Claude said it was done and it wasn’t quite, usually because it had no way to check its own work. See Give Claude a check to run.
+ * Claude did something that must never happen in this repo, or skipped a step that must always happen. A prompt alone can’t guarantee either of those. See Enforce the rules that can’t have exceptions.
+ * Claude got it right, but it took more time, tokens, or permission prompts than the task was worth. See Change a default.
+
+Let Claude run without you applies the same four points to unattended runs, and What you can stop doing lists the advice that current models have made unnecessary.
+
+Setup for a whole team is on a separate page: [Set up Claude Code for your organization](</docs/en/admin-setup>).
+
+##
+
+
+
+Deterministic and non-deterministic instructions
+
+Every instruction you give Claude Code is one of these:
+
+ 1. Non-deterministic: you write the instruction, and Claude (the model) reads it. This can be your prompt, `CLAUDE.md`, or a skill. The model then decides what to do with this information. It usually follows your commands, and current models are good at understanding your intent without much context, but there’s no _guarantee_ that it’ll follow your instructions. It can still decide not to do things, or do other things.
+ 2. Deterministic: you configure the instruction, and Claude Code (the harness) _has_ to execute this. This can be a hook, a deny rule, or a managed setting. Claude Code applies this every time, no matter what the model decided to do.
+
+Most things in Claude Code come in both forms:
+
+| Non-deterministic (Claude decides)| Deterministic (Claude Code enforces)
---|---|---
-**Provide verification criteria**| _”implement a function that validates email addresses"_| _"write a validateEmail function. example test cases:[user@example.com](<mailto:user@example.com>) is true, invalid is false, [user@.com](<mailto:user@.com>) is false. run the tests after implementing”_
-**Verify UI changes visually**| _”make the dashboard look better"_| _"[paste screenshot] implement this design. take a screenshot of the result and compare it to the original. list differences and fix them”_
-**Address root causes, not symptoms**| _”the build is failing"_| _"the build fails with this error: [paste error]. fix it and verify the build succeeds. address the root cause, don’t suppress the error”_
-
-Once the check exists, decide how hard it gates the stop:
-
- * **In one prompt** : ask Claude to run the check and iterate in the same message, as in the table above.
- * **Across a session** : set the check as a [`/goal` condition](</docs/en/goal>). A separate evaluator re-checks it after every turn and Claude keeps working until the goal resolves. If Claude stalls, Claude Code eventually stops the run with the goal still set — see [how /goal evaluation works](</docs/en/goal#how-evaluation-works>).
- * **As a deterministic gate** : a [Stop hook](</docs/en/hooks#stop>) runs your check as a script and blocks the turn from ending until it passes. [Stop input](</docs/en/hooks#stop-input>) covers the cap on consecutive blocks.
- * **By a second opinion** : a [verification subagent](</docs/en/sub-agents>) or a [dynamic workflow](</docs/en/workflows>) that checks its own findings has a fresh model try to refute the result, so the agent doing the work isn’t the one grading it.
-
-Each step trades setup for attention. The prompt version works on any task today. The `/goal` and Stop hook versions are what let an unattended run finish correctly without you. Have Claude show evidence rather than asserting success: the test output, the command it ran and what it returned, or a screenshot of the result. Reviewing evidence is faster than re-running the verification yourself, and it works for sessions you weren’t watching.
-
-* * *
-
-##
-
-
-
-Explore first, then plan, then code
-
-Separate research and planning from implementation to avoid solving the wrong problem.
-
-Letting Claude jump straight to coding can produce code that solves the wrong problem. Use [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) to separate exploration from execution. The recommended workflow has four phases:
-
-1
-
-Explore
-
-Enter plan mode by pressing `Shift+Tab` until the status bar shows `⏸ plan mode on`, or start the session with `claude --permission-mode plan`. Claude reads files and answers questions without making changes.
-
-claude (plan mode)
-
- read /src/auth and understand how we handle sessions and login.
- also look at how we manage environment variables for secrets.
-
-2
-
-Plan
-
-Ask Claude to create a detailed implementation plan.
-
-claude (plan mode)
-
- I want to add Google OAuth. What files need to change?
- What's the session flow? Create a plan.
-
-Press `Ctrl+G` to open the plan in your text editor for direct editing before Claude proceeds.
-
-3
-
-Implement
-
-Switch out of plan mode by approving the plan or pressing `Shift+Tab`, then let Claude code, verifying against its plan.
-
-claude
-
- implement the OAuth flow from your plan. write tests for the
- callback handler, run the test suite and fix any failures.
-
-4
-
-Commit
-
-Ask Claude to commit with a descriptive message and create a PR.
-
-claude
-
- commit with a descriptive message and open a PR
-
-Plan mode is useful, but also adds overhead.For tasks where the scope is clear and the fix is small (like fixing a typo, adding a log line, or renaming a variable) ask Claude to do it directly.Planning is most useful when you’re uncertain about the approach, when the change modifies multiple files, or when you’re unfamiliar with the code being modified. If you could describe the diff in one sentence, skip the plan.
-
-* * *
-
-##
-
-
-
-Provide specific context in your prompts
-
-The more precise your instructions, the fewer corrections you’ll need.
-
-Claude can infer intent, but it can’t read your mind. Reference specific files, mention constraints, and point to example patterns.
-
-Strategy| Before| After
----|---|---
-**Scope the task.** Specify which file, what scenario, and testing preferences.| _”add tests for foo.py"_| _"write a test for foo.py covering the edge case where the user is logged out. avoid mocks.”_
-**Point to sources.** Direct Claude to the source that can answer a question.| _”why does ExecutionFactory have such a weird api?"_| _"look through ExecutionFactory’s git history and summarize how its api came to be”_
-**Reference existing patterns.** Point Claude to patterns in your codebase.| _”add a calendar widget"_| _"look at how existing widgets are implemented on the home page to understand the patterns. HotDogWidget.php is a good example. follow the pattern to implement a new calendar widget that lets the user select a month and paginate forwards/backwards to pick a year. build from scratch without libraries other than the ones already used in the codebase.”_
-**Describe the symptom.** Provide the symptom, the likely location, and what “fixed” looks like.| _”fix the login bug"_| _"users report that login fails after session timeout. check the auth flow in src/auth/, especially token refresh. write a failing test that reproduces the issue, then fix it”_
-
-Vague prompts can be useful when you’re exploring and can afford to course-correct. A prompt like `"what would you improve in this file?"` can surface things you wouldn’t have thought to ask about.
-
-###
-
-
-
-Provide rich content
-
-Use `@` to reference files, paste screenshots/images, or pipe data directly.
-
-You can provide rich data to Claude in several ways:
-
- * **Reference files with`@`** instead of describing where code lives. Claude reads the file before responding.
- * **Paste images directly**. Copy/paste or drag and drop images into the prompt.
- * **Give URLs** for documentation and API references. Use `/permissions` to allowlist frequently used domains.
- * **Pipe in data** by running `cat error.log | claude -p "explain this error"` to send file contents directly.
- * **Let Claude fetch what it needs**. Tell Claude to pull context itself using Bash commands, MCP tools, or by reading files.
-
-* * *
-
-##
-
-
-
-Configure your environment
-
-A few setup steps make Claude Code significantly more effective across all your sessions. For a full overview of extension features and when to use each one, see [Extend Claude Code](</docs/en/features-overview>).
-
-###
-
-
-
-Write an effective CLAUDE.md
-
-Run `/init` to generate a starter CLAUDE.md file based on your current project structure, then refine over time.
-
-CLAUDE.md is a special file that Claude reads at the start of every conversation. Include Bash commands, code style, and workflow rules. This gives Claude persistent context it can’t infer from code alone. There’s no required format for CLAUDE.md files, but keep it short and human-readable. For example:
+What to do| Your prompt, `CLAUDE.md`, skills Claude picks up itself| Hooks, and which skills only you can start
+What it can touch| Auto mode’s classifier| Deny rules, the sandbox in [strict mode](</docs/en/sandboxing#turn-off-the-retry-with-strict-sandbox-mode>), managed settings
+When it’s done| A request for evidence, `/goal`, `/code-review`| Tests, typecheck, a `Stop` hook, CI
+How much it spends| Effort level, Claude’s own pace| `--max-turns` or [`--max-budget-usd`](</docs/en/cli-reference>) with `-p`, a [spend limit](</docs/en/costs>) you’ve set
+Who has the last word| Claude’s summary of what it did| Branch protection, a person who approves the merge
+
+Most of the time, you want Claude to decide. Almost every guideline has exceptions, and current models are good at reading the code in front of them and judging whether a guideline fits the situation. With the actual code in front of it, Claude is usually better placed to make that call than a rule you wrote in advance. The deterministic kind is for when you want to make sure certain things _always_ happen (or never happen), no matter what the model decides. This doesn’t have to be anything dramatic. Auto mode already [blocks the dramatic things](</docs/en/permission-modes#what-the-classifier-blocks-by-default>), like a production deploy or a force push over someone’s work. It’s usually something specific to _your_ project, and it can be as niche as you want it to be:
+
+ * Never edit the generated client in `src/gen/`
+ * Always run the license-header script after creating a file
+
+You could’ve written either of these as a line in `CLAUDE.md` or in your prompt, and Claude would follow it nearly every time. But no matter how strongly you word it, whether Claude follows that line on a given turn is still Claude’s call.
+
+If you keep adding emphasis to a `CLAUDE.md` line and Claude still misses it, that’s a sign the line belongs in a hook. The reverse holds too: if you have hooks for things that are only preferences, delete them and let Claude decide.
+
+##
+
+
+
+Tell Claude what it can’t see
+
+Only write down what Claude can’t find by reading the repo, or what it would otherwise spend time rediscovering every session.
+
+Claude starts every task by reading your code, and current models are _very_ good at this. They’ll find your file layout, your conventions, your test framework, and how existing components are built, usually faster than you could explain them. That means Claude already knows most of what you might be tempted to write down for it. What it can’t find is the information that was never in the repo:
+
+ * A decision your team made in a meeting
+ * A deploy process that lives in one person’s head
+ * The environment variable your integration tests need
+
+There’s also information that _is_ in the repo but takes a few minutes of digging to find, and Claude has to redo that digging at the start of every session. A good test before you write anything down for Claude:
+
+ 1. Could it find this by reading the code?
+ 2. Would it actually go and look?
+
+If both are yes, leave it out.
+
+###
+
+
+
+Write a specific prompt
+
+A specific prompt helps for the same reason, because it gives Claude information it doesn’t already have. If you name the file, describe the symptom, and say what “fixed” looks like up front, you usually save yourself a round of corrections later. The same goes for a preference between two reasonable approaches: Claude can’t read that from the code, so if you care which one it picks, say so up front.
+
+Instead of| Try
+---|---
+ _”fix the login bug"_| _"users report login fails after the session times out. look at token refresh in src/auth/, write a failing test that reproduces it, then fix it"_
+_"add a calendar widget"_| _"follow the pattern in HotDogWidget.php and build a calendar widget that lets you pick a month and page between years. no new libraries”_
+
+If you already have the thing Claude needs, hand it over instead of describing it:
+
+ * A file: type `@` and the path to [include the file contents](</docs/en/common-workflows#reference-files-and-directories>) in your message.
+ * An image: paste the screenshot of the design or the error into the prompt.
+ * Command output: pipe it in from your shell with `cat error.log | claude -p "what's going on here"`.
+
+Phrases like `think step by step` or `be thorough` are ordinary prompt text rather than keywords. The main control for how hard Claude thinks is the [effort level](</docs/en/model-config#adjust-effort-level>), which Change the model and effort covers. Wording like that can still nudge Claude within its effort setting, but it won’t lift it past it. One phrase that does still help is `be ambitious`. Claude tends to read a request conservatively and build the smallest thing that satisfies it, since it can’t see how much you were hoping for. When you want the fuller version, with the edge cases handled and the natural follow-on included, say so:
+
+ build the settings page from the mockup. be ambitious: empty and error states, the save flow wired up, keyboard navigation, not just the layout
+
+That’s telling Claude about scope, which only you know, rather than how hard to think. And when you’re exploring rather than fixing something specific, a vague prompt like `what would you improve in this file?` is completely fine. You’ll correct a bit more as you go, and that’s the trade-off.
+
+###
+
+
+
+Brainstorm with Claude first
+
+When you don’t know exactly what you want yet, you don’t have to work it all out before you prompt. Ask Claude to interview you instead:
+
+ I want to add rate limiting to the public API but haven't thought it through yet. Interview me until you could write the spec, then write it to SPEC.md.
+
+Claude comes back with multiple-choice questions about the parts you haven’t pinned down: per-user versus per-key limits, what happens to requests over the limit, what’s out of scope. It keeps asking until the answers add up to a spec. Once `SPEC.md` exists, start a fresh session to build from it, so the build begins with a clean context and a written definition of done. It’s also the file you’ll point the reviewer at later, in Give Claude a check to run.
+
+###
+
+
+
+Keep CLAUDE.md short
+
+Claude Code loads [`CLAUDE.md`](</docs/en/memory>) into every session, which means every line in it takes a little of Claude’s attention on _every_ task, whether it’s relevant or not. That’s why the file works best when it only holds what Claude couldn’t work out from the code itself:
+
+ * How to confirm work in this repo: the exact test, typecheck, and lint commands, and how to run a single test file
+ * Places where the code is misleading: an old pattern that’s everywhere but that new code must not copy, or a directory that looks unused but isn’t
+ * Decisions that aren’t in the repo: which error helper the team settled on, how deploys work, what needs a migration review
+ * Anything you’ve had to correct twice already
+
+A `CLAUDE.md` that passes that test stays short:
CLAUDE.md
- # Code style
- - Use ES modules (import/export) syntax, not CommonJS (require)
- - Destructure imports when possible (eg. import { foo } from 'bar')
-
- # Workflow
- - Be sure to typecheck when you're done making a series of code changes
- - Prefer running single tests, and not the whole test suite, for performance
-
-Run `/context` to confirm Claude loaded the file. CLAUDE.md is loaded every session, so only include things that apply broadly. For domain knowledge or workflows that are only relevant sometimes, use [skills](</docs/en/skills>) instead. Claude loads them on demand without bloating every conversation. Keep it concise. For each line, ask: _“Would removing this cause Claude to make mistakes?”_ If not, cut it. Bloated CLAUDE.md files cause Claude to ignore your actual instructions!
-
-✅ Include| ❌ Exclude
----|---
-Bash commands Claude can’t guess| Anything Claude can figure out by reading code
-Code style rules that differ from defaults| Standard language conventions Claude already knows
-Testing instructions and preferred test runners| Detailed API documentation (link to docs instead)
-Repository etiquette (branch naming, PR conventions)| Information that changes frequently
-Architectural decisions specific to your project| Long explanations or tutorials
-Developer environment quirks (required env vars)| File-by-file descriptions of the codebase
-Common gotchas or behaviors that aren’t self-evident| Self-evident practices like “write clean code”
-
-If Claude keeps doing something you don’t want despite having a rule against it, the file is probably too long and the rule is getting lost. If Claude asks you questions that are answered in CLAUDE.md, the phrasing might be ambiguous. Treat CLAUDE.md like code: review it when things go wrong, prune it regularly, and test changes by observing whether Claude’s behavior actually shifts. For a checked-in CLAUDE.md, run [`/doctor`](</docs/en/commands#all-commands>) and Claude proposes cuts for content it can derive from the codebase. If Claude keeps skipping one instruction, add emphasis such as “IMPORTANT” to that line alone. If you emphasize many lines, none of them stands out. Check CLAUDE.md into git so your team can contribute. The file compounds in value over time. CLAUDE.md files can import additional files using `@path/to/import` syntax. For import rules and where CLAUDE.md files can live, see [CLAUDE.md files](</docs/en/memory#claude-md-files>).
-
-###
-
-
-
-Configure permissions
-
-To get fewer prompts without giving up control, pre-approve the tools you trust with `/permissions` and let sandboxed commands run without asking with `/sandbox`. Switch to Manual mode when you want to approve edits and commands yourself.
-
-With Claude Code v2.1.283 or later, auto mode is the [built-in starting permission mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for interactive terminal and VS Code sessions: a separate classifier model reviews most actions instead of you and blocks only what looks risky, such as scope escalation, unknown infrastructure, or hostile-content-driven actions. On earlier versions, auto mode is the built-in starting permission mode only on Pro, Max, and Team plans. In Manual mode, Claude Code asks before actions that might modify your system: file writes, Bash commands, MCP tools. That’s safe but tedious. After the tenth approval you’re clicking through rather than reviewing. Two tools cut those interruptions in Manual mode and apply in auto mode as well:
-
- * **Permission allowlists** : permit specific tools you know are safe, like `npm run lint` or `git commit`
- * **Sandboxing** : enable OS-level isolation that restricts filesystem and network access, allowing Claude to work more freely within defined boundaries
-
-Read more about [permission modes](</docs/en/permission-modes>), [permission rules](</docs/en/permissions>), and [sandboxing](</docs/en/sandboxing>).
-
-###
-
-
-
-Use CLI tools
-
-Tell Claude Code to use CLI tools like `gh`, `aws`, `gcloud`, and `sentry-cli` when interacting with external services.
-
-CLI tools are the most context-efficient way to interact with external services. If you use GitHub, install the `gh` CLI. Claude knows how to use it for creating issues, opening pull requests, and reading comments. Without `gh`, Claude can still use the GitHub API, but unauthenticated requests often hit rate limits. Claude is also effective at learning CLI tools it doesn’t already know. Try prompts like `Use 'foo-cli-tool --help' to learn about foo tool, then use it to solve A, B, C.`
-
-###
-
-
-
-Connect MCP servers
-
-Run `claude mcp add` with a server name and URL or command to connect external tools like Notion, Figma, or your database. For example: `claude mcp add --transport http notion https://mcp.notion.com/mcp`.
-
-With [MCP servers](</docs/en/mcp>), you can ask Claude to implement features from issue trackers, query databases, analyze monitoring data, integrate designs from Figma, and automate workflows.
-
-###
-
-
-
-Set up hooks
-
-Use hooks for actions that must happen every time with zero exceptions.
-
-[Hooks](</docs/en/hooks-guide>) run scripts automatically at specific points in Claude’s workflow. Unlike CLAUDE.md instructions which are advisory, hooks are deterministic and guarantee the action happens. Claude can write hooks for you. Try prompts like _“Write a hook that runs eslint after every file edit”_ or _“Write a hook that blocks writes to the migrations folder.”_ Edit `.claude/settings.json` directly to configure hooks by hand, and run `/hooks` to browse what’s configured.
-
-###
-
-
-
-Create skills
-
-Create `SKILL.md` files in `.claude/skills/` to give Claude domain knowledge and reusable workflows.
-
-[Skills](</docs/en/skills>) extend Claude’s knowledge with information specific to your project, team, or domain. Claude applies them automatically when relevant, or you can invoke them directly with `/skill-name`. Create a skill by adding a directory with a `SKILL.md` to `.claude/skills/`:
-
-.claude/skills/api-conventions/SKILL.md
+ # Commands
+ - Install: pnpm install
+ - Run one test file: pnpm vitest run path/to/file.test.ts
+ - Typecheck: pnpm tsc --noEmit
+
+ # Conventions
+ - Use the error helpers in src/lib/errors.ts, never throw raw strings
+ - src/legacy/ is still live but don't copy its patterns into new code
+
+ # Gotchas
+ - Integration tests need DATABASE_URL set, see .env.example
+
+In a session, run `/context` to confirm that Claude loaded the file. Notice that the typecheck line is only the command. Claude needs to know the command so it can check its own work as it goes. If you also want Claude Code to _enforce_ a passing typecheck before Claude finishes, that’s a job for a `Stop` hook. A line like `Always typecheck before you finish` in this file works most of the time, not every time. You don’t have to write the file from scratch:
+
+ * `/init` generates a starting version from your codebase. From there the work is mostly removing lines. The [memory guide](</docs/en/memory#write-effective-instructions>) recommends staying under 200.
+ * `/doctor` suggests cuts for anything Claude can [already work out from the code](</docs/en/memory#my-claude-md-is-too-large>).
+ * `/doctor prompt-audit` flags instructions that were written for older models, point at files that no longer exist, or [contradict each other](</docs/en/memory#audit-your-instruction-files>).
+
+Your personal preferences go in `CLAUDE.local.md` instead of `CLAUDE.md`, and you add that file to `.gitignore` so it stays out of the repo.
+
+If Claude keeps ignoring a line that _is_ in `CLAUDE.md`, adding IMPORTANT probably won’t fix it. Either the file has grown long enough that the line gets lost, or the line is a rule that can’t have exceptions, in which case it belongs in a hook.
+
+###
+
+
+
+Scope rules to one part of the codebase
+
+If a rule only matters in one part of the codebase, put it in [`.claude/rules/`](</docs/en/memory#path-specific-rules>) with a `paths:` filter so it only loads when Claude is actually working there. For example, this `.claude/rules/api.md` loads for TypeScript files under `src/api/`:
+
+.claude/rules/api.md
---
- name: api-conventions
- description: REST API design conventions for our services
+ paths:
+ - "src/api/**/*.ts"
---
- # API Conventions
- - Use kebab-case for URL paths
- - Use camelCase for JSON properties
- - Always include pagination for list endpoints
- - Version APIs in the URL path (/v1/, /v2/)
-
-Skills can also define repeatable workflows you invoke directly:
-
-.claude/skills/fix-issue/SKILL.md
+ - Validate request bodies with the zod schemas in src/api/schemas/, don't hand-roll checks
+ - Every new endpoint needs an entry in openapi.yaml, CI fails without it
+
+###
+
+
+
+Put team procedures in skills
+
+A more capable model knows more about engineering, but not how _your_ team does a release, what your incident runbook says, or how you want API docs written. That kind of knowledge goes in a [skill](</docs/en/skills>): a procedure or a piece of team knowledge saved at `.claude/skills/<name>/SKILL.md`. Skills are also lighter on context than `CLAUDE.md` for this kind of thing. For a skill Claude can start on its own, it sees the name and description in every session, but only [reads the full file](</docs/en/skills#skill-content-lifecycle>) when the task calls for it. A long release procedure sitting in a skill doesn’t weigh on your unrelated bug fix the way it would in `CLAUDE.md`.
+
+The `CLAUDE.md` rule applies to skills too: only write down what Claude can’t find on its own.
+
+For a workflow with side effects, like actually cutting that release, add `disable-model-invocation: true`. Claude then [can’t start the skill on its own](</docs/en/skills#control-who-invokes-a-skill>), and it only runs when you type `/release` yourself. Saved as `.claude/skills/release/SKILL.md`, it could look like this:
+
+.claude/skills/release/SKILL.md
---
- name: fix-issue
- description: Fix a GitHub issue
+ name: release
+ description: Cut a new release. Bumps the version, writes the changelog entry, tags it and pushes the tag so CI can publish.
disable-model-invocation: true
---
- Analyze and fix the GitHub issue: $ARGUMENTS.
-
- 1. Use `gh issue view` to get the issue details
- 2. Understand the problem described in the issue
- 3. Search the codebase for relevant files
- 4. Implement the necessary changes to fix the issue
- 5. Write and run tests to verify the fix
- 6. Ensure code passes linting and type checking
- 7. Create a descriptive commit message
- 8. Push and create a PR
-
-Run `/fix-issue 1234` to invoke it. Use `disable-model-invocation: true` for workflows with side effects that you want to trigger manually.
-
-###
-
-
-
-Create custom subagents
-
-Define specialized assistants in `.claude/agents/` that Claude can delegate to for isolated tasks.
-
-[Subagents](</docs/en/sub-agents>) run in their own context with their own set of allowed tools. They’re useful for tasks that read many files or need specialized focus without cluttering your main conversation.
-
-.claude/agents/security-reviewer.md
+ 1. Make sure you're on main with a clean tree. If not, stop and ask.
+ 2. Run `pnpm changeset version` and commit the result.
+ 3. Summarize the PRs merged since the last tag into CHANGELOG.md, one line each, user-facing changes only.
+ 4. Tag `v<new version>` and push the tag. CI publishes from there, never publish from your machine.
+
+###
+
+
+
+Connect the tools Claude needs
+
+Some of what Claude can’t see lives in another system entirely, like your issue tracker or your error dashboard. If that system has a CLI, that’s usually the easiest way in. With `gh` installed and signed in, for example, Claude will open pull requests and read review comments without any explanation from you. For a CLI it hasn’t seen before, pointing it at `--help` is enough. For systems without a CLI, there’s [MCP](</docs/en/mcp>). You add a server from your shell:
+
+ claude mcp add --transport http notion https://mcp.notion.com/mcp
+
+The server then shows up under `/mcp` inside a session. Connected servers add their tool names and instructions to the context even when you’re not using them, so it’s worth [turning off the ones you don’t need](</docs/en/mcp#disable-a-server-without-removing-it>) there. And if you work in a typed language, a [code intelligence plugin](</docs/en/plugins/code-intelligence>) lets Claude jump straight to a definition instead of reading through many files to find it.
+
+##
+
+
+
+Give Claude a check to run
+
+Claude stops when the work looks done. If it has nothing to run that tells it whether the work actually _is_ done, “looks done” is all it has to go on. In practice that makes you the test suite, and every mistake sits there until you happen to notice it. If you give it something that comes back pass or fail, Claude can close that loop itself. It makes the change, runs the check, and if something broke it reads the output and fixes it before running the check again.
+
+Give Claude something it can run that comes back pass or fail. Once it has that, it can keep going on its own and you don’t have to watch.
+
+The check can be almost anything, as long as Claude can read the result:
+
+ * A test file
+ * A build’s exit code
+ * A linter
+ * A script that diffs output against a fixture
+ * A [browser screenshot](</docs/en/chrome>) next to the mockup
+
+If your repo already has one of these, the single most useful line in your `CLAUDE.md` is the command that runs it. How strict you make the check is up to you. The options go from Claude deciding for itself all the way to Claude Code enforcing it:
+
+ * In the prompt: `run the auth tests after, and keep going until they pass`. Claude decides for itself when it’s satisfied. This works for any task, today, with no setup.
+ * As a goal: [`/goal all tests in tests/auth pass and lint is clean`](</docs/en/goal>) sets a condition that a separate model checks against the conversation after every turn, and Claude keeps going until it’s met. You rarely need this in the session yourself. It matters for long background runs, where Claude sometimes ends a turn with a progress summary while items are still open, and the goal sends it back.
+ * As a Stop hook: a [`Stop` hook](</docs/en/hooks#stop>) runs your script whenever Claude tries to end its turn, and sends Claude back to work if the script exits with code 2. This one is enforced by Claude Code (the harness), so the turn doesn’t end until the typecheck passes or the [block limit](</docs/en/hooks#stop-input>) is reached. There’s an example further down.
+ * By someone who didn’t write the code: in the terminal, [`/code-review`](</docs/en/code-review-local>) reviews the diff in a fresh subagent that never saw your conversation. It isn’t swayed by the reasoning that produced the code.
+
+Whichever option you use, ask Claude for _evidence_ : the command it ran and its output, or the screenshot. “All tests pass” on its own tells you very little, and reading the output is faster than rerunning the check yourself. For a session you weren’t watching, it’s also the only evidence you have.
+
+Once Claude says it’s done, you can also run [`/verify`](</docs/en/skills#run-and-verify-your-app>) in the session, which has Claude build and run the app and look at the result. That catches the kind of problem that tests and typechecks miss.
+
+###
+
+
+
+Review against your spec
+
+If you’d rather have the review check the work against your plan than hunt for bugs in general, write the review prompt yourself:
+
+ use a subagent to review the rate limiter diff against SPEC.md, check every requirement is implemented and the listed edge cases have tests, report gaps that affect correctness and skip style
+
+Don’t drop the `skip style` part of that prompt. A reviewer that’s asked to find problems will always find _something_. If you fix every finding, you end up with extra abstraction layers and tests for cases that can’t happen.
+
+###
+
+
+
+Enforce the check with a Stop hook
+
+The `Stop` hook version of the typecheck rule is a few lines in `.claude/settings.json`. Exit code 2 is what blocks the stop. Whatever the command prints to stderr goes back to Claude as the reason it can’t finish yet, which is why the compiler output is redirected there:
+
+.claude/settings.json
+
+ {
+ "hooks": {
+ "Stop": [
+ {
+ "hooks": [
+ { "type": "command", "command": "pnpm tsc --noEmit 1>&2 || exit 2" }
+ ]
+ }
+ ]
+ }
+ }
+
+To see it work, ask Claude for a change that breaks a type: instead of finishing, it gets the compiler errors back and keeps going until `tsc` passes. If the hook blocks [eight stops in a row](</docs/en/hooks#stop-input>) with no tool call between them, Claude Code overrides the next block and ends the turn. To raise the cap, set [`CLAUDE_CODE_STOP_HOOK_BLOCK_CAP`](</docs/en/env-vars>).
+
+##
+
+
+
+Enforce the rules that can’t have exceptions
+
+If something has to happen every time, make it a hook, a deny rule, or a managed setting. `CLAUDE.md` is for guidelines, and Claude is allowed to decide a guideline doesn’t apply.
+
+Take three rules you might have in `CLAUDE.md` today: `Never read .env`, `Always run the formatter after editing`, `Don't touch the migrations folder`. Claude will follow these almost every time. For the few where “almost” isn’t good enough, move them out of `CLAUDE.md` and into configuration that Claude Code (the harness) applies itself. From then on, the outcome doesn’t depend on what the model remembers or decides.
+
+###
+
+
+
+Enforce steps with hooks
+
+[Hooks](</docs/en/hooks-guide>) run something of yours at fixed points in Claude’s loop: before or after a tool call, when Claude tries to stop, when a session starts, and so on. That something can be:
+
+ * A shell command (the usual case)
+ * A POST to an HTTP endpoint
+ * A tool call on one of your MCP servers
+ * A [`prompt` or `agent` hook](</docs/en/hooks#hook-handler-fields>), which lets a model decide
+
+A `prompt` or `agent` hook asks _another model_ to decide, so it isn’t deterministic either. For real enforcement, use a `command` or `http` hook, and add [`onFailure: "block"`](</docs/en/hooks#block-the-action-when-a-hook-fails>) if the action should also be stopped when the hook itself crashes or times out. For a hook that scans commits for secrets, say, you’d rather block the commit than let it through unscanned while the scanner is down. Here’s the formatter rule as a `PostToolUse` hook. It runs after every `Edit` or `Write`, and whether Claude remembers the rule no longer matters, because Claude isn’t the one running it:
+
+.claude/settings.json
+
+ {
+ "hooks": {
+ "PostToolUse": [
+ {
+ "matcher": "Edit|Write",
+ "hooks": [
+ { "type": "command", "command": "npx prettier --write --ignore-unknown \"$(jq -r '.tool_input.file_path')\"" }
+ ]
+ }
+ ]
+ }
+ }
+
+To check the hook, ask Claude to add a badly indented line to a file Prettier formats. The saved file comes back with the indentation fixed. The migrations rule becomes a [`PreToolUse` hook](</docs/en/hooks-guide#block-edits-to-protected-files>) that exits with code 2 for any path under `migrations/`. You don’t have to write it yourself: `write a hook that blocks edits to the migrations folder` works as a prompt, and `/hooks` shows the result. Don’t overdo it, though: a hook is for a rule with _zero_ exceptions, and `Prefer named exports` has plenty, so that one stays in `CLAUDE.md`.
+
+###
+
+
+
+Limit access with permission rules and the sandbox
+
+[Permission rules](</docs/en/permissions>) decide what Claude is allowed to run, read, and fetch. `deny` rules hold in every permission mode, including auto and `bypassPermissions`, which is exactly why the `.env` rule belongs there:
+
+.claude/settings.json
+
+ {
+ "permissions": {
+ "allow": ["Bash(pnpm tsc --noEmit)"],
+ "ask": ["Bash(git push *)"],
+ "deny": ["Read(./.env)", "Read(./.env.local)", "Read(./secrets/**)"]
+ }
+ }
+
+With this saved, asking Claude what’s in `.env` fails, through the `Read` tool and through `cat .env` alike. Rules match tool calls, not intent, so it’s worth knowing where the edges are:
+
+ * The `Read` rule _does_ catch `cat .env`, because Claude Code recognizes the [common file-reading commands](</docs/en/permissions#read-and-edit>).
+ * It won’t catch a script that opens the file.
+ * A `WebFetch` deny rule for a domain does nothing about `curl` to that same domain, unless the sandbox is on.
+
+For an OS-level limit on filesystem or network access, turn on the [sandbox](</docs/en/sandboxing>) with `/sandbox` in a session. It confines Claude’s shell commands on macOS, Linux, and WSL2 and [picks up your `Read` deny rules and `WebFetch(domain:...)` rules](</docs/en/sandboxing#permission-rules>) too, so for anything security-related you want both. By default Claude can still ask to retry a blocked command outside the sandbox, and that request goes through the normal permission flow. [Strict sandbox mode](</docs/en/sandboxing#turn-off-the-retry-with-strict-sandbox-mode>), in the `/sandbox` **Overrides** tab, turns that retry off.
+
+Auto mode is a classifier model judging each action rather than a hard rule. It’s good at that, but like any judgment call it can be wrong. You can also tune what it treats as risky, and your org can turn it off entirely, so your “never” rules belong in deny rules or hooks.
+
+###
+
+
+
+Choose who a rule applies to
+
+Where a rule lives decides who it applies to:
+
+ * `.claude/settings.local.json` and `~/.claude/settings.json` are yours alone. When you select **Yes, and don’t ask again** for a command, Claude Code saves that rule to the local file.
+ * `.claude/settings.json` and the hooks in it belong to the repo. Once you commit them, they apply to everyone who works in the repo. Its deny rules apply right away. Its `allow` rules wait until each person accepts the [trust dialog](</docs/en/permissions#what-runs-before-you-trust-a-folder>) for that folder, and [workspace trust](</docs/en/hooks#workspace-trust>) also decides when its hooks start running on their machine.
+ * [Managed settings](</docs/en/managed-settings>) belong to the organization. They come from the admin console, MDM, or a `managed-settings.json` file, and no personal settings file can override them, which makes them the only place for a security team’s policy. If you are the person who sets them, see [Set up Claude Code for your organization](</docs/en/admin-setup>).
+
+Whatever the scope, keep the enforced set small. Every hook and deny rule will occasionally fire when it shouldn’t, and someone has to maintain each one. If you ever find yourself at forty of them, most are probably preferences that Claude could have weighed on its own.
+
+##
+
+
+
+Change a default
+
+The defaults are good enough to leave alone until a task costs more time, tokens, or interruptions than it should. When that happens, run `/usage` in the session to see where it went.
+
+A new session already makes a handful of decisions for you:
+
+ * Interactive terminal and VS Code sessions start in auto mode.
+ * It runs [Claude Opus 5.5 at medium effort](</docs/en/model-config#default-model-setting>) on most plans and providers.
+ * It delegates work to subagents when it sees a reason to.
+ * It compacts the conversation as it grows.
+
+Most of the time you never think about these. When a task does cost more than it should, one of these four is usually why.
+
+###
+
+
+
+Change the permission mode
+
+Both ends of the permission range have a cost:
+
+ * **Manual mode** : you approve every edit and every command that isn’t read-only yourself. Safe, but after the tenth prompt you start approving without reading, and nothing moves while you’re away from the keyboard.
+ * **`bypassPermissions`** : approves everything your deny and ask rules don’t cover, which only makes sense in a disposable container.
+
+[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sits between the two, and it’s what interactive terminal and VS Code sessions [start in](</docs/en/permission-modes#which-mode-a-session-starts-in>). Claude works without stopping for routine approvals, and a separate classifier model checks actions in [a fixed order](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) before they run. It concentrates on [the things you’d want a person to stop](</docs/en/permission-modes#what-the-classifier-blocks-by-default>):
+
+ * `curl | bash`
+ * Production deploys and migrations
+ * Force pushes over other people’s work
+ * Sensitive data sent to external endpoints
+ * Actions that look driven by content Claude read rather than by you
+
+When it does block something, you get a notification and the action shows up under **Recently denied** in `/permissions`, where you can retry it with a manual approval. After [three blocks in a row](</docs/en/permission-modes#when-auto-mode-falls-back>) (or twenty in total), auto mode pauses and goes back to asking you. None of this replaces your deterministic controls, because it runs _after_ them. Deny and ask rules and `PreToolUse` hooks apply before the classifier sees anything, so a deny rule blocks in auto mode exactly like it does everywhere else. The sandbox still confines the [shell commands it wraps](</docs/en/sandboxing#what-runs-outside-the-sandbox>).
+
+You can also say `don't push until I've reviewed` in the conversation, and the classifier [treats that as a block signal](</docs/en/permission-modes#boundaries-you-state-in-conversation>). It’s still a model reading the transcript, and the sentence can get lost when the conversation compacts, so anything that matters belongs in a deny rule.
+
+The opposite problem is the classifier repeatedly stopping something that’s routine in your setup. Rather than approving it manually every time, add it to `autoMode.allow` or describe your trusted infrastructure in the [auto mode configuration](</docs/en/auto-mode-config>). It’s plain English rather than patterns, and [`/auto-mode-setup`](</docs/en/auto-mode-config#generate-environment-entries>) can draft the `environment` part for you from your project and recent sessions:
+
+~/.claude/settings.json
+
+ {
+ "autoMode": {
+ "environment": [
+ "$defaults",
+ "Source control: github.com/example-org and every repo under it",
+ "Trusted internal domains: *.internal.example.com"
+ ],
+ "allow": [
+ "$defaults",
+ "Deploying to the staging namespace is fine, it's isolated from production and resets nightly"
+ ]
+ }
+ }
+
+Keep `"$defaults"` in every list you set, because without it your entries _replace_ that list’s built-in rules instead of adding to them. For `environment` and `allow` you’d lose the built-in context and exceptions, and a `soft_deny` list without it drops the built-in blocks on force pushes and production deploys.The `autoMode` block also has to live in `~/.claude/settings.json` rather than the project, because the classifier ignores `autoMode` in project settings.
+
+If you’d rather see every edit and command before it happens, `Shift+Tab` in the session cycles through the permission modes, Manual included, or start with `claude --permission-mode manual` from your shell. And if Manual then asks too often, `/fewer-permission-prompts` scans your recent transcripts for common read-only Bash and MCP calls and adds them to an allowlist in `.claude/settings.json`.
+
+###
+
+
+
+Change the model and effort
+
+[Effort](</docs/en/model-config#adjust-effort-level>) is the main control for how long Claude thinks, and it replaces most of what people used to do with prompt wording. Claude Opus 5.5, Sonnet 5.5, and Haiku 5.5 default to `medium`, which is plenty for everyday feature work with a clear scope. The times you’d move it, with `/effort` in the session:
+
+ * Raise it with `/effort high` or `/effort xhigh` when getting it right depends on cases that are quick to overlook. Think of a bug in code you didn’t write, a flaky test, or a schema change where Claude has to find every reader of the old shape. Claude then checks more edge cases and verifies more of its work before answering, which is where the extra time and tokens go.
+ * Lower it with `/effort low` when you’re going back and forth quickly and reviewing each result anyway: brainstorming, a first sketch, a rename across a few files. Claude gets you a starting point sooner, and since you’re steering every step, the extra deliberation wouldn’t have changed much besides the wait.
+ * Save `max` for a hard problem you want Claude to work through without you, like hunting for a security vulnerability. On ordinary tasks it tends to overthink, so you pay more for an answer that may be no better than `high` would have given you.
+ * When only the next message needs it, like one tricky question in the middle of otherwise routine work, put [`ultrathink`](</docs/en/model-config#use-ultrathink-for-one-off-deep-reasoning>) in that prompt instead of changing the setting.
+
+For the model itself, the default Opus 5.5 handles most coding well and Sonnet costs less on routine work. [Claude Fable 5.1](</docs/en/model-config#work-with-fable>) is there when you select it explicitly with `/model fable`, and Haiku is a good fit for subagents doing simple jobs. [Model configuration](</docs/en/model-config>) has the full list per plan and provider.
+
+###
+
+
+
+Know what subagents cost
+
+Claude delegates to [subagents](</docs/en/sub-agents>) on its own:
+
+ * Broad codebase searches go to the built-in Explore agent.
+ * Side tasks get [forked](</docs/en/sub-agents#fork-the-current-conversation>) while fork mode is on (the default).
+ * The subagents it starts run in the background by default, so your main conversation keeps moving.
+
+You rarely need to ask for any of this, but it helps to know what you’re getting and what it costs. Subagents pay off in these situations:
+
+ * Running independent pieces of work at the same time, so the whole task finishes sooner
+ * Keeping long output, like a full test run or a wide search, out of your main conversation, where it would otherwise ride along for the rest of the session
+ * Getting a reviewer that hasn’t seen how the code was written
+ * Giving a task fewer tools than the main session has, like a reviewer that can read but not edit
+
+What they cost you is mostly tokens, since every subagent sends its own requests and they count against the same usage as your main conversation. Sometimes it’s time as well: a fresh subagent first has to gather context your conversation already had, so it can end up _slower_ than doing the task where you are. And by default it’s the same model (or a smaller one) on the same task. You get parallelism or a fresh pair of eyes out of it, but not a smarter answer. To spend less on them:
+
+ * Set [`model: haiku`](</docs/en/sub-agents#choose-a-model>) in a subagent’s definition if its work is simple, like collecting the files that import a module or checking links in the docs. That kind of job doesn’t need the bigger model, and Haiku costs a lot less per request.
+ * Ask for short summaries back, so twenty results don’t fill your context anyway.
+ * Check `/usage` to see what share of your usage each subagent type takes, so you can tell which ones are earning their cost.
+ * Give a custom subagent in `.claude/agents/` only `tools: Read, Grep, Glob`. Now it’s a reviewer that can’t edit anything, and that limit is enforced by Claude Code rather than requested in a prompt.
+
+That reviewer is one short file, `.claude/agents/reviewer.md`:
+
+.claude/agents/reviewer.md
---
- name: security-reviewer
- description: Reviews code for security vulnerabilities
- tools: Read, Grep, Glob, Bash
- model: opus
+ name: reviewer
+ description: Reviews changed files against the spec they were built from. Use after implementing a feature, before opening the PR.
+ tools: Read, Grep, Glob
---
- You are a senior security engineer. Review code for:
- - Injection vulnerabilities (SQL, XSS, command injection)
- - Authentication and authorization flaws
- - Secrets or credentials in code
- - Insecure data handling
-
- Provide specific line references and suggested fixes.
-
-Tell Claude to use subagents explicitly: _“Use a subagent to review this code for security issues.”_
-
-###
-
-
-
-Install plugins
-
-Run `/plugin` to browse the marketplace. Plugins add skills, tools, and integrations without configuration.
-
-[Plugins](</docs/en/plugins/overview>) bundle skills, hooks, subagents, and MCP servers into a single installable unit from the community and Anthropic. If you work with a typed language, install a [code intelligence plugin](</docs/en/plugins/code-intelligence>) to give Claude precise symbol navigation and automatic error detection after edits. For guidance on choosing between skills, subagents, hooks, and MCP, see [Extend Claude Code](</docs/en/features-overview#match-features-to-your-goal>).
-
-* * *
-
-##
-
-
-
-Communicate effectively
-
-Ask Claude the questions you’d ask another engineer, and for larger features have Claude interview you and write a spec before you start implementing.
-
-###
-
-
-
-Ask codebase questions
-
-Ask Claude questions you’d ask a senior engineer.
-
-When onboarding to a new codebase, use Claude Code for learning and exploration. You can ask Claude the same sorts of questions you would ask another engineer:
-
- * How does logging work?
- * How do I make a new API endpoint?
- * What does `async move { ... }` do on line 134 of `foo.rs`?
- * What edge cases does `CustomerOnboardingFlowImpl` handle?
- * Why does this code call `foo()` instead of `bar()` on line 333?
-
-Using Claude Code this way is an effective onboarding workflow, improving ramp-up time and reducing load on other engineers. No special prompting required: ask questions directly.
-
-###
-
-
-
-Let Claude interview you
-
-For larger features, have Claude interview you first. Start with a minimal prompt and ask Claude to interview you using the `AskUserQuestion` tool.
-
-Claude asks about things you might not have considered yet, including technical implementation, UI/UX, edge cases, and tradeoffs. Replace `[brief description]` with your feature before sending the prompt.
-
- I want to build [brief description]. Interview me in detail using the AskUserQuestion tool.
-
- Ask about technical implementation, UI/UX, edge cases, concerns, and tradeoffs. Don't ask obvious questions, dig into the hard parts I might not have considered.
-
- Keep interviewing until we've covered everything, then write a complete spec to SPEC.md.
-
-Once the spec is complete, start a fresh session to execute it. The new session has clean context focused entirely on implementation, and you have a written spec to reference. The most useful specs are self-contained: they name the files and interfaces involved, state what is out of scope, and end with an end-to-end verification step that proves the feature works. Time spent making the spec precise pays off more than time spent watching the implementation.
-
-* * *
-
-##
-
-
-
-Manage your session
-
-Conversations are persistent and reversible. Use this to your advantage!
-
-###
-
-
-
-Course-correct early and often
-
-Correct Claude as soon as you notice it going off track.
-
-The best results come from tight feedback loops. Though Claude occasionally solves problems perfectly on the first attempt, correcting it quickly generally produces better solutions faster.
-
- * **`Esc`** : stop Claude mid-action with the `Esc` key. Context is preserved, so you can redirect.
- * **`Esc + Esc` or `/rewind`**: press `Esc` twice or run `/rewind` to open the rewind menu and restore previous conversation and code state, or summarize from a selected message.
- * **`"Undo that"`** : have Claude revert its changes.
- * **`/clear`** : reset context between unrelated tasks. Long sessions with irrelevant context can reduce performance.
-
-If you’ve corrected Claude more than twice on the same issue in one session, the context is cluttered with failed approaches. Run `/clear` and start fresh with a more specific prompt that incorporates what you learned. A clean session with a better prompt almost always outperforms a long session with accumulated corrections.
-
-###
-
-
-
-Manage context aggressively
-
-Run `/clear` between unrelated tasks to reset context.
-
-Claude Code automatically compacts conversation history when you approach context limits, which preserves important code and decisions while freeing space. During long sessions, Claude’s context window can fill with irrelevant conversation, file contents, and commands. This can reduce performance and sometimes distract Claude.
-
- * Use `/clear` frequently between tasks to reset the context window entirely
- * When auto compaction triggers, Claude summarizes what matters most, including code patterns, file states, and key decisions
- * For more control, run `/compact <instructions>`, like `/compact Focus on the API changes`
- * To compact only part of the conversation, use `Esc + Esc` or `/rewind`, select a message checkpoint, and choose **Summarize from here** or **Summarize up to here**. The first condenses messages from that point forward while keeping earlier context intact; the second condenses earlier messages while keeping recent ones in full. See [the rewind menu’s summarize options](</docs/en/checkpointing#rewind-and-summarize>).
- * Customize compaction behavior in CLAUDE.md with instructions like `"When compacting, always preserve the full list of modified files and any test commands"` to ensure critical context survives summarization
- * For questions that don’t need to stay in context, use [`/btw`](</docs/en/interactive-mode#side-questions-with-%2Fbtw>). The answer never enters conversation history, so you can check a detail without growing context.
-
-###
-
-
-
-Use subagents for investigation
-
-Delegate research with `"use subagents to investigate X"`. They explore in a separate context, keeping your main conversation clean for implementation.
-
-Since context is your fundamental constraint, use subagents to keep research out of it. When Claude researches a codebase it reads lots of files, all of which consume your context. Subagents run in separate context windows and report back summaries:
-
- Use subagents to investigate how our authentication system handles token
- refresh, and whether we have any existing OAuth utilities I should reuse.
-
-You can also use subagents for verification after Claude implements something. See Add an adversarial review step.
-
-###
-
-
-
-Rewind with checkpoints
-
-Every prompt you send that starts a turn creates a checkpoint. You can restore conversation, code, or both to any previous checkpoint.
-
-Claude automatically snapshots files before each change so a checkpoint can restore them. Double-tap `Escape` or run `/rewind` to open the rewind menu. You can restore conversation only, restore code only, restore both, or summarize from a selected message. See [Checkpointing](</docs/en/checkpointing>) for details. Instead of carefully planning every move, you can tell Claude to try something risky. If it doesn’t work, rewind and try a different approach. Checkpoints are saved with the conversation, so you can close your terminal, resume the session later, and still rewind.
-
-Checkpoints only track changes made through Claude’s file editing tools. Changes made through Bash commands or external processes are not captured. This isn’t a replacement for git.
-
-###
-
-
-
-Resume conversations
-
-Name sessions with `/rename` and treat them like branches: each workstream gets its own persistent context.
-
-Claude Code saves conversations locally, so when a task spans multiple sittings you don’t have to re-explain the context. Run [`claude --continue`](</docs/en/sessions#resume-a-session>) to pick up where you left off, or `claude --resume` to choose from a list. Give sessions descriptive names like `oauth-migration` so you can find them later. See [Manage sessions](</docs/en/sessions>) for the full set of resume, branch, and naming controls.
-
-* * *
-
-##
-
-
-
-Automate and scale
-
-Once you’re effective with one Claude, multiply your output with parallel sessions, non-interactive mode, and fan-out patterns.
-
-###
-
-
-
-Run non-interactive mode
-
-Use `claude -p "prompt"` in CI, pre-commit hooks, or scripts. Add `--output-format stream-json --verbose` for streaming JSON output.
-
-With `claude -p "your prompt"`, you can run Claude non-interactively, without an interactive prompt. The run still creates a resumable session unless you pass `--no-session-persistence`. [Non-interactive mode](</docs/en/headless>) is how you integrate Claude into CI pipelines, pre-commit hooks, or any automated workflow. The output formats let you parse results programmatically: plain text, JSON, or streaming JSON.
-
- # One-off queries
- claude -p "Explain what this project does"
-
- # Structured output for scripts
- claude -p "List all API endpoints" --output-format json
-
- # Streaming for real-time processing
- claude -p "Analyze this log file" --output-format stream-json --verbose
-
-The first command prints plain text. The `json` format returns a single JSON object with a `result` field. The `stream-json` format prints one JSON object per line, starting with an init event.
-
-###
-
-
-
-Run multiple Claude sessions
-
-Run multiple Claude sessions in parallel to speed up development, run isolated experiments, or start complex workflows.
-
-Pick the parallel approach that fits how much coordination you want to do yourself, and add messaging when the sessions need to pass findings between them:
-
- * [Worktrees](</docs/en/worktrees>): run separate CLI sessions in isolated git checkouts so edits don’t collide
- * [Cross-session messaging](</docs/en/cross-session-messaging>): let the sessions you run yourself pass findings to each other
- * [Desktop app](</docs/en/desktop#work-in-parallel-with-sessions>): manage multiple local sessions visually, optionally each in its own worktree
- * [Use Claude Code in the cloud](</docs/en/claude-code-on-the-web>): run sessions on Anthropic-managed infrastructure by default
- * [Agent view](</docs/en/agent-view>): research preview. Run `claude agents` to dispatch sessions that keep running in the background and watch them from one screen
- * [Agent teams](</docs/en/agent-teams>): experimental and disabled by default. Automated coordination of multiple sessions with shared tasks, messaging, and a team lead
-
-Beyond parallelizing work, multiple sessions enable quality-focused workflows. A fresh context improves code review since Claude won’t be biased toward code it just wrote. For example, use a Writer/Reviewer pattern:
-
-Session A (Writer)| Session B (Reviewer)
+ You're reviewing code you didn't write. Compare the changed files against the spec you're given,
+ check that every requirement is implemented and the listed edge cases have tests,
+ and report only the gaps that affect correctness. Skip style.
+
+Ask Claude to `have the reviewer compare the rate limiter against SPEC.md` and the gaps come back into your session, where Claude can fix them.
+
+###
+
+
+
+Keep cost and context down
+
+With a 1M-token window on most current models and compaction near the top of it, you’ll rarely run out of context. You can still _pay_ for context you don’t need, though. Every request sends the whole conversation, so a session that’s collected three unrelated tasks re-reads all three on every turn of the fourth. That’s [discounted while the cache is warm](</docs/en/costs#why-usage-climbs-in-a-long-session>) and full price once it expires. [`/usage`](</docs/en/costs>) is the first place to look. On Pro, Max, Team, and Enterprise it breaks your usage down by skill, subagent, plugin, and MCP server. It also flags patterns like long context or frequent cache misses once one of them passes 10% of your usage. From there, the usual fixes:
+
+ * `/clear` between unrelated tasks. It costs nothing, and it means the next task doesn’t keep paying for the previous one’s history. `/clear oauth-migration` names the session you’re leaving, so you can come back to it later.
+ * `/compact` with a focus, like `/compact keep the API changes and the test commands`. On a long session `/compact` is itself a big request, since it reads the whole conversation to summarize it, and even more so once the cache has expired.
+ * Keep an eye on background work: a `/loop`, a goal’s check after every turn, and Claude’s own subagents all keep sending requests while you aren’t typing.
+
+The [prompt cache](</docs/en/prompt-caching>) lasts about an hour on a subscription and five minutes on an API key, cloud provider, or usage credits. Subagents get five minutes unless you change it.On the one-hour cache, a session past about 200K tokens that sits idle is compacted shortly before the cache expires, so after lunch you continue from a summary. If you don’t need the history at all, a fresh session still costs less.
+
+##
+
+
+
+Steer the session
+
+Watch the first minute, press `Esc` the moment Claude drifts, and after two failed corrections run `/clear` and write a better prompt instead of a third.
+
+No amount of configuration replaces watching the first minute and stepping in when Claude heads somewhere you didn’t intend. There are only a few controls for that, and they’re worth knowing by heart:
+
+ * `Esc` stops Claude mid-action and keeps everything up to that point, so you can redirect without losing work.
+ * `/rewind`, or `Esc` twice on an empty prompt, opens the [rewind menu](</docs/en/checkpointing#rewind-and-summarize>), where you roll the code, the conversation, or both back to an earlier prompt. That makes it low-risk to try the bolder approach first and rewind if it doesn’t work out. The same menu can also summarize part of the conversation when it has gone stale.
+ * `/clear` starts over. If you’ve corrected the same thing twice and it’s still wrong, a third correction mostly adds to a conversation that already contains two failed attempts for Claude to keep re-reading. `/clear` plus one new prompt that folds in what you learned works better almost every time.
+
+Checkpoints cover the files Claude edited with its own file tools in your main conversation, so a file that only a Bash command touched [isn’t restored](</docs/en/checkpointing#bash-command-changes-not-tracked>). They work alongside git rather than replacing it.
+
+Two smaller ones: [`/btw`](</docs/en/interactive-mode#side-questions-with-%2Fbtw>) answers a quick question without adding anything to the history. And for work that spans several days, `/rename oauth-migration` in the session names it, so that [`claude --resume oauth-migration`](</docs/en/sessions#resume-by-session-id-or-name>) from your shell picks it back up later, checkpoints included. `claude --continue` resumes the most recent one.
+
+##
+
+
+
+Let Claude run without you
+
+Before a run goes unattended, make sure it knows what done looks like, can check its own work, and can only touch what it should. Give it a cap on turns or spend, and have a person approve the result at the end.
+
+Everything on this page matters a little more once you’re not around to catch mistakes. While you’re watching, Claude missing some piece of context isn’t a big deal: you notice within a message or two and tell it. In a run you started before going to bed, nobody tells it, and you find out the next morning that it spent the whole night building on the wrong assumption. Before you leave a task running on its own, it’s worth going through these five questions with that specific task in mind:
+
+ 1. Does it know what done looks like? A goal condition, a spec file, or a failing test it has to turn green.
+ 2. Can it check its own work? The test suite, a `Stop` hook, some kind of review step.
+ 3. What’s it allowed to touch? Permission rules, `dontAsk`, the sandbox, a worktree, the one branch it may push to.
+ 4. What stops it? `--max-turns`, `--max-budget-usd`, a spend limit.
+ 5. Where does the result go, and who signs off? A PR, a comment, or a summary, and then a person approving the merge, the deploy, or anything else you can’t take back.
+
+Once it’s going, Claude will carry a long task through on its own. The parts that stay with you are starting it, deciding what “done” means this time, and approving the merge at the end.
+
+###
+
+
+
+Run Claude from a script
+
+[`claude -p "prompt"`](</docs/en/headless>) runs once and exits, which is how Claude Code ends up in CI jobs, git hooks, and shell loops. In a script you’ll almost always want a few more flags:
+
+ * [`--bare`](</docs/en/headless#start-faster-with-bare-mode>) skips hooks, skills, plugins, MCP servers, and `CLAUDE.md` files, the repo’s as well as the machine’s, so the run does the same thing wherever it runs. It also never touches your claude.ai login: auth comes from `ANTHROPIC_API_KEY`, an `apiKeyHelper` in the file you pass with `--settings`, or your cloud provider’s credentials.
+ * `--append-system-prompt`, `--mcp-config`, and `--settings` pass in whatever the run _does_ need, explicitly.
+ * `--allowedTools` pre-approves its tools, and [`--permission-mode dontAsk`](</docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode>) refuses anything else that would have prompted.
+ * `--output-format json` gives you a single result object to parse, and `stream-json` with `--verbose` streams events as they happen.
+
+Put together, that looks like this:
+
+ for file in $(cat files.txt); do
+ claude --bare -p "Migrate $file to the new logger API and commit. Reply OK or FAIL." \
+ --allowedTools "Read,Edit,Bash(git add *),Bash(git commit *)" \
+ --permission-mode dontAsk \
+ --max-turns 20
+ done
+
+When a run finishes, Claude replies `OK` or `FAIL`, and a run that hits the turn limit exits with an error instead. Try it on three files first, see what goes wrong, fix the prompt, then run the rest. Auto mode works with `-p` too if you pass `--permission-mode auto`. In a non-interactive run, a classifier block denies that one action and Claude carries on, and repeated blocks don’t pause the run the way they do in a terminal. Read [how the thresholds apply there](</docs/en/permission-modes#repeated-block-thresholds>) before you rely on it.
+
+###
+
+
+
+Start runs on a schedule or an event
+
+Once a run is going, Claude can handle the rest by itself. The one thing it can’t do is decide to _start_ , so something has to: you, a timer, or an event like a failed CI check or a new PR. Inside an open session that’s [`/loop`](</docs/en/scheduled-tasks#run-a-prompt-repeatedly-with-%2Floop>), which repeats a prompt on an interval:
+
+ /loop 15m check CI on this branch, and if it's red pull the failing job's log, fix it and push
+
+Each run is another turn in the same session, so don’t leave one going in a long conversation. For anything that should happen while your laptop is closed, [`/schedule`](</docs/en/routines#create-from-the-cli>) sets up a [cloud scheduled task](</docs/en/routines>) that runs on a timer. It needs a claude.ai login rather than an API key. You can add a GitHub-event trigger by asking Claude, or an API trigger at [claude.ai/code/routines](<https://claude.ai/code/routines>).
+
+Before you leave a cloud scheduled task running, protect `main` with a [GitHub branch rule the task can’t bypass](</docs/en/routines#repositories-and-branch-permissions>). And watch the first few runs of anything new before trusting it unattended.
+
+###
+
+
+
+Run sessions in parallel
+
+When you have separate pieces of work going at once, give each its own checkout so the edits can’t collide. [`claude -w feature-auth`](</docs/en/worktrees#start-claude-in-a-worktree>) starts a session in a new worktree, the [desktop app](</docs/en/desktop#work-in-parallel-with-sessions>) runs several of these side by side, and [cloud sessions](</docs/en/claude-code-on-the-web>) run them in the cloud instead of on your machine. A worktree is a fresh checkout, which means gitignored files like `.env` aren’t there and dependencies aren’t installed. For the first, list the gitignored files you need in a [`.worktreeinclude`](</docs/en/worktrees#copy-gitignored-files-into-worktrees>) at the repo root (same syntax as `.gitignore`) and Claude Code copies them into every worktree it creates:
+
+.worktreeinclude
+
+ .env
+ .env.local
+ config/dev-credentials.json
+
+Keep it to small files: it copies rather than links, so `node_modules` in there would mean a full copy per worktree. For large directories there’s the [`worktree.symlinkDirectories`](</docs/en/settings-reference#worktree-symlinkdirectories>) setting, or keep the install command in `CLAUDE.md` so Claude runs it whenever it starts in a new checkout. You rarely have to clean any of this up yourself:
+
+ * When you exit an unnamed worktree session, Claude Code [removes the worktree](</docs/en/worktrees#clean-up-worktrees>) if there’s nothing in it. For a named session, or one with changes, it asks what to do.
+ * Subagent worktrees disappear when the subagent finishes without changes.
+ * Subagent and background-session worktrees that do get left behind are swept once they’re older than `cleanupPeriodDays` and hold no work.
+
+A `claude -p --worktree` run is one you clean up yourself, since it exits without asking. Remove those with `git worktree remove <path>`, and if git refuses because the worktree is locked, `git worktree unlock <path>` first.
+
+For one big mechanical change across many files, [`/batch migrate every handler to the v2 response helpers`](</docs/en/commands>) splits the work into 5 to 30 units and shows you the plan. Then it runs each unit in its own worktree and opens a PR for it. From your shell, [`claude agents`](</docs/en/agent-view>) (still a research preview) gives you one screen for everything running in the background on your machine. A second session is also the easiest independent reviewer you can get. One session writes the rate limiter, another reviews `@src/middleware/rateLimiter.ts` without having watched it being written, and you paste the findings back into the first. Same idea as `/code-review`, with you carrying the messages.
+
+##
+
+
+
+What you can stop doing
+
+Every one of these was good advice when it was written. Most were workarounds for something the model couldn’t reliably do yet, and the models have since caught up. If a few are still habits, here’s why it’s safe to drop them.
+
+The old advice| Why it’s gone
---|---
-`Implement a rate limiter for our API endpoints`|
-| `Review the rate limiter implementation in @src/middleware/rateLimiter.ts. Look for edge cases, race conditions, and consistency with our existing middleware patterns.`
-`Here's the review feedback: [Session B output]. Address these issues.`|
-
-You can do something similar with tests: have one Claude write tests, then another write code to pass them.
-
-###
-
-
-
-Fan out across files
-
-Loop through tasks calling `claude -p` for each. Use `--allowedTools` to pre-approve tools for batch operations.
-
-For large migrations or analyses, you can distribute work across many parallel Claude invocations. Run [`/batch <instruction>`](</docs/en/commands#all-commands>) to have Claude split the change across 5 to 30 subagents. Each subagent works in its own worktree. To drive the fan-out from your own script instead, loop over `claude -p`:
-
-1
-
-Generate a task list
-
-Have Claude write the list of files that need migrating to a file, so the loop in the next step can read it, with a prompt like `list all 2,000 Python files that need migrating and save the list to files.txt`
-
-2
-
-Write a script to loop through the list
-
- for file in $(cat files.txt); do
- claude -p "Migrate $file from Python 2 to Python 3. Return OK or FAIL." \
- --allowedTools "Edit,Bash(git commit *)" \
- --permission-mode dontAsk
- done
-
-3
-
-Test on a few files, then run on all of them
-
-Refine your prompt based on what goes wrong with the first 2-3 files, then run on the full set. The `--allowedTools` flag pre-approves the tools the migration needs. [`--permission-mode dontAsk`](</docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode>) denies anything else that would need approval, which matters when you’re running unattended, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve some of those calls.
-
-You can also integrate Claude into existing data/processing pipelines:
-
- claude -p "<your prompt>" --output-format json | your_command
-
-###
-
-
-
-Run autonomously with auto mode
-
-For uninterrupted execution with background safety checks, use [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). A classifier model reviews commands before they run, blocking scope escalation, unknown infrastructure, and hostile-content-driven actions while letting routine work proceed without prompts.
-
- claude --permission-mode auto -p "fix all lint errors"
-
-When the classifier repeatedly blocks actions in a non-interactive run with the `-p` flag, Claude Code doesn’t stop the run. See [when auto mode falls back](</docs/en/permission-modes#when-auto-mode-falls-back>) for what happens instead and for the thresholds.
-
-###
-
-
-
-Add an adversarial review step
-
-Before treating a task as done, have a subagent review the diff in a fresh context and report gaps.
-
-The longer Claude works unattended, the more an independent check matters before you count the work as done. A reviewer running in a fresh [subagent](</docs/en/sub-agents>) context sees only the diff and the criteria you give it, not the reasoning that produced the change, so it evaluates the result on its own terms. For a correctness check, run the bundled [`/code-review` skill](</docs/en/commands>), which reviews the current diff for bugs in a fresh subagent and returns findings to the session. To check the diff against your plan instead, write the review prompt yourself. Name the work to check, the plan to check it against, and what counts as a finding:
-
- Use a subagent to review the rate limiter diff against PLAN.md. Check that
- every requirement is implemented, the listed edge cases have tests, and
- nothing outside the task's scope changed. Report gaps, not style preferences.
-
-Because the reviewer runs as a subagent, the implementing session receives the gaps directly and can fix them and re-review without you copying findings between windows.
-
-A reviewer prompted to find gaps will usually report some, even when the work is sound, because that is what it was asked to do. Chasing every finding leads to over-engineering: extra abstraction layers, defensive code, and tests for cases that can’t happen. Tell the reviewer to flag only gaps that affect correctness or the stated requirements, and treat the rest as optional.
-
-* * *
-
-##
-
-
-
-Avoid common failure patterns
-
-These are common mistakes. Recognizing them early saves time:
-
- * **The kitchen sink session.** You start with one task, then ask Claude something unrelated, then go back to the first task. Context is full of irrelevant information.
-
-> **Fix** : `/clear` between unrelated tasks.
-
- * **Correcting over and over.** Claude does something wrong, you correct it, it’s still wrong, you correct again. Context is polluted with failed approaches.
-
-> **Fix** : After two failed corrections, `/clear` and write a better initial prompt incorporating what you learned.
-
- * **The over-specified CLAUDE.md.** If your CLAUDE.md is too long, Claude ignores half of it because important rules get lost in the noise.
-
-> **Fix** : Ruthlessly prune. If Claude already does something correctly without the instruction, delete it or convert it to a hook.
-
- * **The trust-then-verify gap.** Claude produces a plausible-looking implementation that doesn’t handle edge cases.
-
-> **Fix** : Always provide verification (tests, scripts, screenshots). If you can’t verify it, don’t ship it.
-
- * **The infinite exploration.** You ask Claude to “investigate” something without scoping it. Claude reads hundreds of files, filling the context.
-
-> **Fix** : Scope investigations narrowly or use subagents so the exploration doesn’t consume your main context.
-
-* * *
-
-##
-
-
-
-Develop your intuition
-
-The patterns in this guide aren’t set in stone. They’re starting points that work well in general, but might not be optimal for every situation. Sometimes you _should_ let context accumulate because you’re deep in one complex problem and the history is valuable. Sometimes you should skip planning and let Claude figure it out because the task is exploratory. Sometimes a vague prompt is exactly right because you want to see how Claude interprets the problem before constraining it. Pay attention to what works. When Claude produces great output, notice what you did: the prompt structure, the context you provided, the mode you were in. When Claude struggles, ask why. Was the context too noisy? The prompt too vague? The task too big for one pass? Over time, you’ll develop intuition that no guide can capture. You’ll know when to be specific and when to be open-ended, when to plan and when to explore, when to clear context and when to let it accumulate.
+The context window is your main constraint, manage it aggressively| Most current models have a 1M-token window and compaction happens on its own, so running out is rare. `/clear` between tasks is still worth doing, because a focused context gets you better answers and costs less.
+Add IMPORTANT or ALL CAPS to instructions Claude keeps missing| Older models sometimes needed the emphasis. Current ones follow a plainly worded line, and piling on emphasis mostly makes Claude over-apply the rule. If it’s a rule that can’t bend, turn it into a hook or a deny rule. If the line is getting lost in a long file, the file needs to be shorter.
+Use subagents to protect your context window| Running out of context is rarely the problem anymore. Subagents are still great for parallel work, keeping noisy output out of your way, and independent review, but each of those costs extra tokens.
+Delegate to a subagent for a better answer| Handing the same task to a subagent doesn’t make the answer any better. A fresh reviewer does help, because it hasn’t seen your reasoning, which is a different thing from delegating.
+`think hard`, `think harder`, `be thorough` in the prompt| Effort is the control for that. Those phrases are ordinary prompt text that nudges Claude within its effort setting rather than keywords that raise it. `ultrathink` still works: it asks for deeper reasoning on that single turn without touching your effort setting.
+Tell Claude to keep going, loop until done, don’t be lazy| Current models usually carry on through an agreed task without being told, and lines like that are more likely to cause over-work than fix a stall. Giving Claude a check to pass is different, and still worth doing. If a run does stop short, say `continue`, and for runs nobody’s watching, `/goal` or a `Stop` hook enforces it.
+Describe your architecture and file layout in `CLAUDE.md`| Claude reads the repo itself. Only write down what isn’t in there.
+
+If any other advice on this page ever starts to feel like busywork, that’s probably a sign it belongs in this table too.
##
@@ -595,7 +607,10 @@
Related resources
- * [How Claude Code works](</docs/en/how-claude-code-works>): the agentic loop, tools, and context management
- * [Extend Claude Code](</docs/en/features-overview>): skills, hooks, MCP, subagents, and plugins
- * [Common workflows](</docs/en/common-workflows>): step-by-step recipes for debugging, testing, PRs, and more
- * [CLAUDE.md](</docs/en/memory>): store project conventions and persistent context
+ * [How Claude Code works](</docs/en/how-claude-code-works>): the loop, the tools, and what loads at startup
+ * [Explore the context window](</docs/en/context-window>): what uses space in a session and when it loads
+ * [Extend Claude Code](</docs/en/features-overview>): the choice between skills, hooks, MCP, subagents, and plugins
+ * [Choose a permission mode](</docs/en/permission-modes>) and [Configure permissions](</docs/en/permissions>)
+ * [Manage costs effectively](</docs/en/costs>)
+ * [Run Claude Code programmatically](</docs/en/headless>) and [Automate work with cloud scheduled tasks](</docs/en/routines>)
+ * For team leads and admins: [Set up Claude Code for your organization](</docs/en/admin-setup>)
Show diff (117 lines)
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,114 @@
This page is generated from the [CHANGELOG.md on GitHub](<https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md>). Longer releases are grouped by type of change, with long lists of improvements and bug fixes collapsed. Run `claude --version` to check your installed version.
+
+
+
+2.1.311
+
+October 26, 2026
+
+**Added**
+
+ * Added `--hold-idle-file` and `--max-hold-min` to `self-hosted-runner`, to keep an idle session while your host reports processes it left running
+ * Added a tip for the Explanatory output style, shown when you ask Claude for explanations
+ * [VSCode] Added syntax coloring to code blocks in Claude’s replies, in light, dark and high contrast dark themes
+ * [VSCode] Added a “Running UserPromptSubmit hooks” spinner status and screen reader announcement for slow UserPromptSubmit hooks
+ * [Claude Tag] Added a Skills view to Claude Tag analytics showing how often Claude runs each attached skill in Slack channels and which go unused, with Usage links in admin settings
+
+**Changed**
+
+ * Changed `ultrathink` in the interactive terminal to run its turn at xhigh effort on Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 through Anthropic’s API; typed while Claude is working, it raises the rest of that turn
+ * Changed the `ultrathink` rainbow to appear only where the keyword can raise effort, and not when the word is quoted or part of a file path
+ * Changed Ctrl+D in agent view to match the prompt: on an empty input, pressing it twice exits
+ * Changed `--output-format json` and `stream-json` output to write DEL, C1 control and Unicode format characters inside strings as `\uXXXX` escapes; parsed values are unchanged
+ * Changed model names and IDs to drop the `[1m]` suffix and its label on models where the suffix has no effect; the suffix is still accepted
+ * Changed startup warnings about permission rules in settings files to show once per user until the rule changes
+ * Changed `/code-review` to tell Claude to put the effort level first and use max only when asked
+ * Changed `DISABLE_COMPACT` in settings files and in a mod’s `$.env.set` so they can only turn compaction off, not back on
+ * Changed Claude Code on Bedrock, Mantle, Vertex, and Foundry to load model settings from a signed file on downloads.claude.ai; set CLAUDE_CODE_MODEL_CATALOG=off to turn this off
+ * Changed sessions that set `CLAUDE_CODE_SYNC_SKILLS` with feature-flag fetching off to reuse a claude.ai skills list up to 10 minutes old that another session on the machine fetched
+ * Changed clicks on scrollbar arrows and bars in fullscreen lists to act when the mouse button is released, so moving off the scrollbar before letting go cancels the click
+ * Changed `claude purge` to say it deletes data only on this computer, not anything stored by Anthropic
+ * [VSCode] Changed the extension to start Claude Code sessions with `DISABLE_TELEMETRY` set while VS Code’s telemetry setting is off, so they send no usage metrics or error reports and fetch no feature flags
+ * [VSCode] Changed the session list side bar to load Web sessions when the Web tab is first opened, not at startup
+ * [Claude Tag] Changed Claude Tag admin settings to show a lock instead of # for private Slack channels that your own Slack account can see
+
+Show 16 improvements
+
+ * Improved startup time for Pro and Max accounts by skipping two network requests on launches within an hour of the last check
+ * Improved `/teleport` and `claude --teleport` to warn when a compacted cloud session loads from its last compaction, so the messages it summarized aren’t in the local copy
+ * Improved the messages shown when a background session’s process exits: they no longer promise a restart that isn’t coming, and they say how to resume the session
+ * Improved artifacts with several views: Claude now routes each view on the link’s `#name` and no longer says the address bar stays the same as you switch views
+ * Improved shell commands that reach their timeout: the result now shows the output so far and says the command is still running in the background
+ * Improved compaction: when the model’s reply has no summary in it, Claude Code now usually asks for the summary once more before it replaces the conversation
+ * Improved the Artifact tool’s choice between a page and a document: explainers and visual or interactive work become artifact pages; documents are for writing people keep editing or pass around
+ * Improved startup time for launches whose only arguments are options and their values, such as `claude --model opus`
+ * Improved the “Connection dropped” API error: it now says where to look first (the proxy or gateway in use, else VPN or firewall; Anthropic API only, Bedrock, Vertex and Foundry are unchanged)
+ * Improved screen reader mode: deleting a rule in /permissions says “Deleted allow rule …” right away
+ * Improved the message shown when a pasted sign-in code is refused: it now says the code may have expired or been used, and to sign in again
+ * Improved Slack connector sends: Claude now checks a channel’s topic for posting rules before messaging a channel you didn’t name
+ * Improved screen reader mode: Claude’s questions are listed as “Questions: Color (answered), Pages”, without arrows or symbols
+ * [Claude Tag] Improved Claude Tag routines that run in a new session: a run with nothing to report can now end without posting a throwaway message to the channel
+ * [Code Review] Improved Code Review’s check run to say no further automatic review will start when the model still can’t analyze a change on the automatic retry
+ * [Code Review] Improved Code Review reliability: a review whose session fails to start because of a transient server fault is now retried once automatically, and its check run says so
+
+Show 56 bug fixes
+
+ * Fixed long freezes at startup and after reading or editing files when a CLAUDE.md file holds a very long list item
+ * Fixed interrupting Claude not taking effect until a timeout while an MCP server had not answered a resource read or a skill was still downloading
+ * Fixed standard-context sessions stopping with “Usage credits required for 1M context” when a request ran over 200K tokens; Claude Code now compacts the conversation and continues
+ * Fixed Write and Edit stalling for up to 5 seconds after they ran, and reporting 0 lines changed, when changing thousands of lines in a file
+ * Fixed subagents being unable to use MCP tools from servers that finish connecting after the subagent starts
+ * Fixed Claude seeing stale MEMORY.md and CLAUDE.md content right after automatic compaction when those files were edited earlier in the session
+ * Fixed `claude -p` and SDK sessions saving transcript messages out of order or keeping messages that were taken back
+ * Fixed `SubagentStop` hooks running about twice a minute for each running subagent instead of once when it finishes
+ * Fixed the @ file picker ignoring `.ignore`/`.rgignore` negation rules that re-include git-ignored files
+ * Fixed a subagent’s isolated worktree being removed while a background subagent it started was still working in it
+ * Fixed background agents in auto mode that wait on their own shells starting a new main conversation turn on every wake
+ * Fixed the Bash tool description claiming the working directory always persists between calls
+ * Fixed the environment block naming a shell commands don’t run in, such as fish when the Bash tool uses zsh
+ * Fixed `claude mcp add`, `claude mcp remove` and `/mcp` naming the current folder instead of the project entry in `~/.claude.json` that holds a local-scope server when run below a repository root
+ * Fixed `claude mcp list` and `claude mcp get` showing the error code twice on failed-connection lines (for example `ENOENT: ENOENT: …`)
+ * Fixed Remote Control sessions staying on “Connecting” for about two minutes when a network proxy blocks a startup request
+ * Fixed messages that Claude sends to a cloud or Remote Control session appearing as your own message in the Claude mobile apps
+ * Fixed Claude not being told the cause when a file attached to a message sent over Remote Control or to a cloud session could not be saved because the disk was full, or that a message’s attachments past the first 20 were left out
+ * Fixed WebFetch and WebSearch hanging on a stalled response in Cowork cloud sessions; an unfinished request now fails after 300 seconds
+ * Fixed a background session that crashed between turns not being restarted while it was attached, pinned, or had a scheduled task or wake-up set
+ * Fixed the “background service did not respond” error suggesting the disabled `claude daemon restart`; it now suggests `claude daemon stop --any` and says it ends background sessions
+ * Fixed `claude respawn <id>` starting the background service before reporting that no background session matches the id
+ * Fixed `/effort` not warning about a prompt cache miss in plan mode when the plan model differs from the session model
+ * Fixed `/ide` saying the VS Code extension was installed before the install finished or when it failed
+ * Fixed the Write tool’s file preview skipping rows and miscounting hidden lines when a line is wider than the terminal
+ * Fixed ↑ in an agent’s chat tab recalling a message that was still waiting to be delivered, so resending it sent a second copy
+ * Fixed Cowork cloud sessions losing their connectors and most tools after a restart when a plugin or your settings named an `agent`; Cowork cloud sessions now ignore that setting
+ * Fixed agent teams sessions showing an empty task list when coming back with `--resume`, `--continue`, `/resume` or `--session-id`, including after `/clear` or a crash, and `/branch` writing to the original session’s list
+ * Fixed pasting text that mentions an image file, such as `! open /tmp/shot.png` or `/review look at /tmp/shot.png`, attaching the image and dropping its path from the prompt
+ * Fixed the feedback draft card showing its 1/2/0 and Esc shortcuts while the prompt has text, when those keys act on the prompt instead of the card
+ * Fixed a lone backslash in quotes or brackets, like `"\"` or `(\)`, disappearing from Claude’s responses
+ * Fixed agent teammates compacting their history when `DISABLE_COMPACT` is set
+ * Fixed the rewind menu offering “Summarize from here” and “Summarize up to here” when `DISABLE_COMPACT` is set
+ * Fixed a finished `/code-review`, or another skill that runs in a sub-agent, running a second time when a cloud or background session restarts
+ * Fixed long hidden thinking being cut off as idle on Google Vertex AI, Microsoft Foundry and Claude Platform on AWS, where the endpoint sends thinking progress updates
+ * Fixed `/ide` saying it had installed the JetBrains plugin when nothing was installed
+ * Fixed Claude Pro and Max subscribers being told to ask their admin when their subscription can’t be used; the message now points to billing settings
+ * Fixed the diff pane opening by itself after an edit in wide fullscreen terminals when it had nothing to show
+ * Fixed `/mcp` showing a remote server as failed after “Clear authentication” when the server works without sign-in
+ * Fixed `/mcp` showing “authenticated” for a remote server that Claude Code sends no credentials to
+ * Fixed a `--plugin-dir` folder of plugins loading as one plugin when an empty `.mcp.json` was at its top
+ * Fixed `/usage` never showing large prompt-cache misses under “What’s contributing to your limits usage?”
+ * Fixed status line links staying plain text in background sessions after you open them from a terminal that supports links
+ * Fixed the /rewind confirmation saying the conversation “will be forked” when the later messages are removed from the conversation
+ * Fixed the /rewind warning that wrongly said manual and Bash edits are never affected by a code restore
+ * Fixed plan approval in screen reader mode sending feedback you had dismissed with Escape
+ * Fixed Claude Code retrying requests the API marked not to retry, which could hold a turn for minutes or, in unattended retry mode (`CLAUDE_CODE_RETRY_WATCHDOG`), indefinitely
+ * Linux: Fixed sandboxed Bash commands failing with `bwrap: Can't create file` when a `--plugin-dir` folder was also an added directory and `permissions.blockReadsOutsideWorkingDirectories` was on
+ * Self-hosted runner: Fixed a session failing to start when a rate limit (HTTP 429, or a git wrapper that exits 75) blocks an added read-only repository; it now starts without that repository
+ * [VSCode] Fixed custom skills and custom slash commands sent from the VS Code or JetBrains panel leaving out the open file or selected lines that ordinary messages include (anthropics/claude-code#102799)
+ * [VSCode] Fixed the extension host freezing while the login shell ran its start-up files to read PATH on macOS and Linux
+ * [VSCode] Fixed clicking an image in a tool result, or closing its preview, also opening the result’s text in an editor tab
+ * [VSCode] Fixed voice dictation continuing to record after a message was sent with the Send button; sending now stops dictation first, as pressing Enter already did
+ * [Cloud sessions] Fixed routines in Anthropic-hosted environments staying locked after their owner left the organization and rejoined; the owner can now turn them back on
+ * [Cloud sessions] Fixed a failed routine API token delete or regenerate showing nothing if the edit dialog had already closed; it now shows an error toast
+ * [Cloud sessions] Fixed cloud environment dialogs, including the admin dialog, accepting duplicate names; they now refuse a name another listed environment already has
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -873,7 +873,10 @@
permissions: { deny: ["Read(./.env)"] }
desktop: {}
-When you switch, delete any `serve_to_desktop` line in the same edit that renames the blocks. Where an instruction names the `cli` block, use your `code` block.
+When you switch, delete any `serve_to_desktop` line in the same edit that renames the blocks. Where an instruction names the `cli` block, use your `code` block. `serve_to_desktop: true` is a legacy way to offer a policy’s `cli` settings to the Code tab. It has no effect when Claude Desktop connects through `bootstrapUrl`. While your policies use `cli`, a boot warning that names this key means those settings aren’t reaching the Code tab:
+
+ * **To cover the Code tab** : switch to `code`, once users’ machines meet the conditions in Apply `code` settings in the Code tab
+ * **To stay on`cli`**: set `serve_to_desktop: false` beside `cli` in a policy to silence the warning
####
@@ -918,7 +921,7 @@
---|---|---
`availableModels`| Gateway + CLI| Model allowlist. Also checked at `/v1/messages`, so a patched client can’t bypass it.
[`deniedModels`](</docs/en/settings-reference#deniedmodels>), [`availableModelsMatch`](</docs/en/settings-reference#availablemodelsmatch>)| Gateway + CLI| [Block specific models or versions](</docs/en/model-config#block-specific-models-or-versions>) that `availableModels` would otherwise permit. A blocked model is rejected with a `400` at `/v1/messages` and is left out of `/v1/models`. The gateway’s own check requires Claude Code v2.1.299 or later on the gateway server. The CLI’s check requires v2.1.283 or later on clients, and earlier clients ignore both keys.
-`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>).
+`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>) and [what a Bash rule doesn’t match](</docs/en/permissions#bash-rule-limits>).
`permissions.disableBypassPermissionsMode`| CLI| Set to `disable` to block [`bypassPermissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), the mode that skips permission prompts, and the `--dangerously-skip-permissions` flag
`allowManagedPermissionRulesOnly`| CLI| When `true`, managed settings become the only settings source of permission rules. The [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>) entry lists every source Claude Code then ignores.
`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
@@ -934,6 +937,14 @@
* Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
+
+####
+
+
+
+Test a policy before deployment
+
+To test a policy change, start the gateway against a throwaway Postgres database. The gateway connects to Postgres and applies its schema migrations before it checks the contents of `cli`, `code`, and `desktop` blocks. When it can’t reach the database, the start stops at `could not connect to Postgres` and reports nothing about their contents.
####
@@ -1448,7 +1459,7 @@
# The contractors policy inherits this key.
enforceAvailableModels: true
permissions:
- allow: [Read, Grep, Bash, Edit]
+ allow: [Read, Grep, Edit]
deny: ["WebFetch"]
env: { HTTP_PROXY: http://proxy.example.com:8080 }
--- a/claude-apps-gateway-deploy.md
+++ b/claude-apps-gateway-deploy.md
@@ -402,6 +402,7 @@
A developer’s `/login` shows the standard account picker instead of the **Cloud gateway** screen| `forceLoginMethod` or `forceLoginGatewayUrl` isn’t set in managed settings on that machine| Deploy the [managed settings file](</docs/en/claude-apps-gateway#set-the-gateway-url>) to the device; `/login` reads the gateway URL from there
A developer’s requests fail with `Not signed in to the Cloud gateway — run /login.`| The machine’s managed settings set `forceLoginMethod: "gateway"` or `forceLoginGatewayUrl`, and the session has no gateway sign-in. A leftover claude.ai login doesn’t satisfy the requirement.| Have the developer run `/login` and complete the gateway sign-in. See also [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>).
Claude Desktop reports that its bootstrap configuration couldn’t be fetched| `/user/bootstrap` returned 404: the policy matching the user doesn’t carry a `desktop` key, or no policy matched. The gateway’s audit log records each rejection as `desktop_bootstrap.denied` with the reason.| Add a `desktop` block to the policy that matches the user, or to the `match: {}` base layer; an empty `desktop: {}` suffices. See [Claude Desktop overlay](</docs/en/claude-apps-gateway-config#claude-desktop-overlay>).
+Audit log shows `auth.denied` with `reason: invalid_token` on `/v1/logs` or `/v1/metrics`| You set [`otelHeadersHelper`](</docs/en/settings-reference#otelheadershelper>) in a machine’s managed settings. In a Claude Desktop session on that machine, Claude Code sends the `Authorization` header from the helper to the gateway’s telemetry relay in place of the session token. Where Claude Desktop bundles Claude Code before v2.1.307, you get the same denial if you set an `Authorization` header in `OTEL_EXPORTER_OTLP_HEADERS` or a per-signal form in those settings.| Remove the helper from those settings. Where Claude Desktop bundles Claude Code before v2.1.307, remove the variable.
Startup shows `Gateway login is configured in managed settings, but this Claude Code build does not include Cloud gateway support.`| The installed Claude Code build predates gateway support| Have the developer update Claude Code to a release that includes Cloud gateway support
Startup exits with `Administrator policy requires a Cloud gateway sign-in on this machine`| The developer’s environment sets `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN`, their settings configure an [`apiKeyHelper`](</docs/en/settings-reference#apikeyhelper>), or an API key from an earlier Claude Console login is still saved| Have the developer clear each that applies: unset the variable, remove the `apiKeyHelper` entry, or run `claude auth logout` to remove the saved key. A session that selects a cloud provider with `CLAUDE_CODE_USE_*` then starts with no sign-in; for every other session, have them start `claude` and sign in with `/login`. See also [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>).
Startup or `/login` reports `Claude Code may not be enabled for your organization` after a 403 on the managed settings load| The gateway, or something in front of it, answered the `/managed/settings` request with 403. The gateway’s own settings route never answers 403. The status comes from the [`access_control`](</docs/en/claude-apps-gateway-config#http-tuning>) IP checks or from a proxy or WAF in front of the gateway. The audit log records an IP-check denial as `access.denied` with the reason. The developer stays signed in.| Check the audit log for `access.denied` at the time of the failure and fix the `access_control` lists or the front end, then have the developer start `claude` again
--- a/claude-code-on-the-web.md
+++ b/claude-code-on-the-web.md
@@ -279,6 +279,38 @@
`/clear`| Yes| Starts a fresh conversation with empty context in the same cloud session
Auto-compaction runs automatically when the context window approaches capacity. Cloud sessions set [`CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`](</docs/en/env-vars>) themselves, so compaction triggers partway through the [auto-compact window](</docs/en/model-config#set-the-auto-compact-window>) rather than when the window fills. That value overrides one you add in your [environment variables](</docs/en/cloud-environments#set-environment-variables>), so adding the variable there doesn’t change when compaction triggers. To change the auto-compact window instead, set [`CLAUDE_CODE_AUTO_COMPACT_WINDOW`](</docs/en/env-vars>) in your environment variables, or run [`/autocompact`](</docs/en/commands#all-commands>) with a token count in a session where the variable isn’t set. [Subagents](</docs/en/sub-agents>) work the same way they do locally. Claude can spawn them with the Agent tool to offload research or parallel work into a separate context window, keeping the main conversation lighter. Outside a [project](</docs/en/claude-projects#what-threads-pick-up-from-your-repositories>)’s threads, subagents defined in your repo’s `.claude/agents/` load automatically. [Agent teams](</docs/en/agent-teams>) are off by default but can be enabled by adding `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` to your [environment variables](</docs/en/cloud-environments#set-environment-variables>).
+
+###
+
+
+
+Plugin suggestions in the conversation
+
+A card in the conversation that lists one or more [plugins](</docs/en/plugins/overview>), with an **Add** button, means Claude is suggesting plugins for your task. Claude can make these suggestions without you asking. You don’t have to respond, and Claude carries on with the task either way.
+
+####
+
+
+
+Add or remove a suggested plugin
+
+Select **Add** on a plugin to turn it on for your claude.ai account, where it stays on after the session ends. To undo, open the added plugin from the card, select **Manage** to reach the plugin’s page on claude.ai, and remove the plugin from that page.
+
+####
+
+
+
+Turn off plugin suggestions
+
+To stop Claude from suggesting plugins, deny the `SearchPlugins` and `SuggestPluginInstall` tools with [permission rules](</docs/en/permissions#manage-permissions>). In a session with one repository outside a [project](</docs/en/claude-projects>), commit the rules to that repository’s `.claude/settings.json`, listing both tool names under `permissions.deny`:
+
+ {
+ "permissions": {
+ "deny": ["SearchPlugins", "SuggestPluginInstall"]
+ }
+ }
+
+Claude Code ignores permission rules in the repository’s `.claude/settings.json`, including these deny rules, when the [managed settings](</docs/en/managed-settings>) that apply to the session set [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>). In that case, put the rules in those managed settings instead. For other setups, such as a session with several repositories or a cloud thread in a project, see which [settings reach a cloud session](</docs/en/settings#settings-in-cloud-sessions>).
###
--- a/claude-directory.md
+++ b/claude-directory.md
@@ -115,7 +115,12 @@
Application data
-Beyond the config you author, `~/.claude` holds data Claude Code writes during sessions. These files are plaintext. Anything that passes through a tool is written to a transcript on disk: file contents, command output, pasted text.
+Beyond the config you author, `~/.claude` holds data Claude Code writes during sessions. These files are plaintext. Anything that passes through a tool is written to a transcript on disk: file contents, command output, pasted text. The transcript can also hold what Claude Code sends the model with your messages:
+
+ * The system prompt
+ * Tool definitions
+ * Request parameters
+ * The instruction files it loaded, such as CLAUDE.md
###
@@ -127,9 +132,9 @@
Path under `~/.claude/`| Contents
---|---
-`projects/<project>/<session>.jsonl`| Full conversation transcript: every message, tool call, and tool result
+`projects/<project>/<session>.jsonl`| Conversation transcript: messages, tool calls, and tool results, plus the system prompt, tool definitions, and parameters of the requests Claude Code sent the model
`projects/<project>/<session>.orphaned-<timestamp>-<suffix>.jsonl`, `projects/<project>/<session>.jsonl.superseded-<timestamp>`| A previous transcript for the session that Claude Code set aside instead of overwriting or deleting it. It doesn’t appear in the session picker
-`projects/<project>/<session>/subagents/`| [Subagent](</docs/en/sub-agents>) conversation transcripts, removed with the parent session transcript when it ages out
+`projects/<project>/<session>/subagents/`| [Subagent](</docs/en/sub-agents>) transcripts in the same format as the session transcript, removed with the parent session transcript when it ages out
`projects/<project>/<session>/tool-results/`| Large tool outputs spilled to separate files, and full-size copies of [images that MCP tools return](</docs/en/mcp#images-in-tool-results>)
`projects/<project>/<session>/mcp-tasks/`| What a resumed session needs to follow its running [MCP tasks](</docs/en/mcp#mcp-tasks-that-run-on-the-server>) again, and the results of finished tasks that Claude hasn’t read yet
`file-history/<session>/`| Pre-edit snapshots of files Claude changed, used for [checkpoint restore](</docs/en/checkpointing>). Holds snapshots for the 100 most recent checkpoints; snapshot files that no retained checkpoint references are deleted, except each file’s first snapshot
--- a/claude-security.md
+++ b/claude-security.md
@@ -1,4 +1,4 @@
-The Claude Security plugin runs a multi-agent vulnerability scan of your codebase inside a Claude Code session. A team of Claude agents maps your architecture, builds a threat model, hunts for vulnerabilities, and independently reviews every finding before writing the report. Use the plugin to scan a whole repository or only a set of changes, such as a branch’s diff, a pull request’s diff, or a single commit, then turn the findings you choose into patches that you review and apply yourself. The plugin runs locally in your session, uses whichever models you have access to in Claude Code, and each scan counts toward your [usage](</docs/en/costs>). If you want a managed service that monitors your repositories, or want to run scans on [Claude Mythos](<https://platform.claude.com/docs/en/about-claude/models/introducing-claude-fable-5-and-claude-mythos-5>), see the [Claude Security](<https://claude.com/product/claude-security>) product, available on the Enterprise plan. The plugin is also distinct from the review tools already in Claude Code: the [security guidance plugin](</docs/en/security-guidance>) reviews code as Claude writes it, [`/security-review`](</docs/en/commands#all-commands>) runs a single pass over your branch, and [Code Review](</docs/en/code-review>) reviews pull requests. For how the layers stack, see How the plugin fits with other security tools.
+The Claude Security plugin runs a multi-agent vulnerability scan of your codebase inside a Claude Code session. By default, when you scan a whole repository, Claude agents map your architecture, build a threat model, hunt for vulnerabilities, and independently review every finding before writing the report. Use the plugin to scan a whole repository or only a set of changes, such as a branch’s diff, a pull request’s diff, or a single commit, then turn the findings you choose into patches that you review and apply yourself. The plugin runs locally in your session, uses whichever models you have access to in Claude Code, and each scan counts toward your [usage](</docs/en/costs>). If you want a managed service that monitors your repositories, or want to run scans on [Claude Mythos](<https://platform.claude.com/docs/en/about-claude/models/introducing-claude-fable-5-and-claude-mythos-5>), see the [Claude Security](<https://claude.com/product/claude-security>) product, available on the Enterprise plan. The plugin is also distinct from the review tools already in Claude Code: the [security guidance plugin](</docs/en/security-guidance>) reviews code as Claude writes it, [`/security-review`](</docs/en/commands#all-commands>) runs a single pass over your branch, and [Code Review](</docs/en/code-review>) reviews pull requests. For how the layers stack, see How the plugin fits with other security tools.
##
@@ -47,6 +47,14 @@
+Update the plugin
+
+To update the plugin yourself, see [Update plugins now](</docs/en/plugins/install#update-plugins-now>). Claude Code also [updates the plugin automatically](</docs/en/plugins/install#keep-plugins-updated>) unless auto-update is turned off.
+
+###
+
+
+
Uninstall the plugin
To remove the plugin, uninstall it from the `/plugin` menu, or run `claude plugin uninstall claude-security` in your terminal.
@@ -112,6 +120,20 @@
Scope large repositories
On a large repository, scan one area at a time instead of the whole tree. Pick one of the focused scopes the plugin offers, such as your API layer or your authentication code, and the run sizes itself to what you pick. The report’s coverage section states what was and wasn’t examined. Run another scan on a different area anytime.
+
+###
+
+
+
+Choose a scan effort
+
+Scan effort sets how deep a scan goes. Your findings go through the same independent verification at `low`, `medium`, and `high`.
+
+ * **`low`** : a quick first look. It skips the architecture map and the threat model when you scan your codebase.
+ * **`medium`** : the default.
+ * **`high`** : what `medium` does, plus more hunting for vulnerabilities in the same code.
+
+Name the scan effort in your request at the Claude Code prompt, such as `/claude-security scan my public API code at high` or `/claude-security scan my branch at high`. If a scan of a large repository finds less than you expect, choose `high` scan effort, scan a second time, or do both. Each can report findings that one `medium` scan doesn’t.
###
@@ -124,7 +146,7 @@
* **`CLAUDE-SECURITY-RESULTS.md`** : the report, with each finding’s ID, such as `F1`, plus its impact, exploit scenario, severity, confidence, and recommendation
* **`CLAUDE-SECURITY-RESULTS.jsonl`** : the same findings in machine-readable form, one JSON object per line
* **`CLAUDE-SECURITY-RESULTS.sarif`** : the same findings as a [SARIF 2.1.0](<https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html>) log for GitHub code scanning and any other tool that reads the standard. The scan classifies findings under their [CWE](<https://cwe.mitre.org/>) weakness categories
- * **`CLAUDE-SECURITY-REVISION-<commit>.json`**: the revision stamp, recording which commit was scanned, at what effort, whether uncommitted changes were part of the scanned tree, and how thoroughly the run was verified, so a report is always tied to the code it describes. A scan outside version control stamps `UNVERSIONED` in place of the commit
+ * **`CLAUDE-SECURITY-REVISION-<commit>.json`**: the revision stamp, recording which commit was scanned, at what scan effort, whether uncommitted changes were part of the scanned tree, and how thoroughly the run was verified, so a report is always tied to the code it describes. A scan outside version control stamps `UNVERSIONED` in place of the commit
That directory is the only change a scan makes to your checkout, and it carries its own `.gitignore`, so a stray `git add` never sweeps a report into a commit. To keep a report in history for an audit trail, delete that one `.gitignore` file and commit the directory like any other. Findings only appear in the report after independent verifier agents analyze them, which keeps reports short and worth reading. Scans are nondeterministic: two scans of the same code can surface different findings. Run scans regularly, and use the revision stamps to attribute each report to the exact code and settings it covered.
--- a/commands.md
+++ b/commands.md
@@ -63,7 +63,7 @@
`/desktop`| Continue the current session in the Claude Code Desktop app. Requires macOS or x64 Windows and a Claude subscription. Alias: `/app`
`/diff`| Review the changes in your working tree, including the edits Claude has made so far. See [Review changes with /diff](</docs/en/interactive-mode#review-changes-with-%2Fdiff>)
`/doctor [prompt-audit [path]]`| **[Skill](</docs/en/skills#bundled-skills>).** Run a setup checkup that diagnoses installation, settings, extension, and `CLAUDE.md` problems and proposes fixes that Claude applies after you confirm. For what the checkup covers, or to audit your instructions with `prompt-audit` instead, see [Check your setup with `/doctor`](</docs/en/skills#check-your-setup-with-/doctor>). The `prompt-audit` subcommand requires Claude Code v2.1.283 or later. Alias: `/checkup`
-`/effort [level|auto|status|ultracode [on|off]]`| Set the [effort level](</docs/en/model-config#adjust-effort-level>): `low` to `xhigh`, `max`, or `auto`; `status` prints it. `ultracode` or `ultracode on` turns [ultracode](</docs/en/workflows#let-claude-decide-with-ultracode>) on for the session at the current level, and `ultracode off` turns it off; the [`ultracode`](</docs/en/settings-reference#ultracode>) key persists. `max` is session-only. The `on` and `off` arguments and keeping the current level require Claude Code v2.1.284 or later. Before v2.1.284, `/effort ultracode` set the session to `xhigh`, and `/effort ultracode off` failed with `Invalid argument`. Run it while Claude is responding and, once you confirm the [cache warning](</docs/en/prompt-caching#changing-effort-level>), if Claude Code shows one, Claude Code applies the new level to the next request in that turn. Before v2.1.242, Claude Code decided from a feature flag it fetched from Anthropic whether to run the command mid-turn or queue it until the turn finished, and always queued it in a session that doesn’t [fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>), such as on a [third-party provider](</docs/en/third-party-integrations>). Works in `-p`
+`/effort [level|auto|status|ultracode [on|off]]`| Set the [effort level](</docs/en/model-config#adjust-effort-level>): `low` to `xhigh`, `max`, or `auto`; `status` prints it. `ultracode` or `ultracode on` turns [ultracode](</docs/en/workflows#let-claude-decide-with-ultracode>) on for the session, and `ultracode off` turns it off; the [`ultracode`](</docs/en/settings-reference#ultracode>) key persists. `max` is session-only. The `on` and `off` arguments require Claude Code v2.1.284 or later. If you run `/effort` while Claude is working, see [when the new level starts](</docs/en/model-config#when-a-new-effort-level-starts>). Works in `-p` on v2.1.205 or later
`/exit`| Exit the CLI. In an attached [background session](</docs/en/agent-view#attach-to-a-session>), this detaches and the session keeps running. Alias: `/quit`
`/export [filename]`| Export the current conversation as plain text. With a filename, writes directly to that file. Without, opens a dialog to copy to clipboard or save to a file
`/fast [on|off]`| Toggle [fast mode](</docs/en/fast-mode>) on or off. Run it while Claude is responding and Claude Code toggles fast mode without waiting for the turn to end, though the running turn finishes at its original speed. Before v2.1.242, Claude Code decided from a feature flag it fetched from Anthropic whether to run the command mid-turn or queue it until the turn finished, and always queued it in a session that doesn’t [fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>). Availability in non-interactive mode with `-p` is limited; see [Toggle fast mode](</docs/en/fast-mode#toggle-fast-mode>)
--- a/context-window.md
+++ b/context-window.md
@@ -74,6 +74,6 @@
* [Extend Claude Code](</docs/en/features-overview>): when to use CLAUDE.md vs skills vs rules vs hooks vs MCP
* [Store instructions and memories](</docs/en/memory>): CLAUDE.md hierarchy and auto memory
* [Subagents](</docs/en/sub-agents>): delegate research to a separate context window
- * [Best practices](</docs/en/best-practices>): managing context as your primary constraint
+ * [Best practices](</docs/en/best-practices#keep-cost-and-context-down>): keep sessions focused and costs down
* [Prompt caching](</docs/en/prompt-caching>): which actions invalidate the cached prefix
* [Reduce token usage](</docs/en/costs#reduce-token-usage>): strategies for keeping context usage low
--- a/custom-tools.md
+++ b/custom-tools.md
@@ -12,6 +12,7 @@
Make a parameter optional| Declare it optional in the schema and apply the default in the handler. See Make a parameter optional.
Register a tool with Claude| Wrap in `create_sdk_mcp_server` / `createSdkMcpServer` and pass to `mcpServers` in `query()`. See Call a custom tool.
Pre-approve a tool| Add to your allowed tools. See Configure allowed tools.
+Require approval for calls to a tool, or block the tool| In the TypeScript SDK, add a `permission_policy` for the tool to the config object that `createSdkMcpServer()` returns. See Require approval for specific tools.
Remove a built-in tool from Claude’s context| Pass a `tools` array listing only the built-ins you want. See Configure allowed tools.
Let Claude call tools in parallel| Set `readOnlyHint: true` on tools with no side effects. See Add tool annotations.
Control the error message Claude reads| Return `isError: true` to compose the message instead of surfacing the raw exception. See Handle errors.
@@ -326,7 +327,7 @@
Field| Default| Meaning
---|---|---
`readOnlyHint`| `false`| Tool does not modify its environment. Controls whether the tool can be called in parallel with other read-only tools.
-`destructiveHint`| `true`| Tool may perform destructive updates. Informational only.
+`destructiveHint`| `true`| Tool may perform destructive updates. Set it to `true` explicitly on any tool you mark `always_ask`.
`idempotentHint`| `false`| Repeated calls with the same arguments have no additional effect. Informational only.
`openWorldHint`| `true`| Tool reaches systems outside your process. Informational only.
@@ -386,6 +387,33 @@
disallowed tools| Both| A bare tool name such as `"Bash"` removes the tool from Claude’s context, the same as omitting it from `tools`. A scoped rule such as `"Bash(rm *)"` leaves the tool in context and denies only calls that match [as written](</docs/en/permissions#bash-rule-limits>).
To remove a built-in entirely, omit it from `tools` or list its bare name in `disallowedTools` (Python: `disallowed_tools`); both keep the tool out of context so Claude never attempts it. A scoped `disallowedTools` rule blocks matching calls but leaves the tool visible, so Claude may waste a turn trying it. See [Configure permissions](</docs/en/agent-sdk/permissions>) for the full evaluation order.
+
+###
+
+
+
+Require approval for specific tools
+
+Set a tool’s `permission_policy` to `always_ask`, and `allowedTools` stops approving that tool’s calls, so they can reach your [`canUseTool`](</docs/en/agent-sdk/user-input>) callback even though the tool is listed. Set `always_deny` instead, and [a call to the tool is denied](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>), but a [mod](</docs/en/plugins/mods/overview>) in a plugin you load [can still approve it](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). The field is TypeScript-only and requires Agent SDK v0.3.301 or later. Put the policy entry in a `tools` array on the config object `createSdkMcpServer()` returns, not in the `tools` option you pass into that function. This example spreads `weatherServer` from the weather tool example and adds a `tools` array giving `get_temperature` the `always_ask` policy:
+
+TypeScript
+
+ options: {
+ mcpServers: {
+ weather: {
+ ...weatherServer,
+ tools: [{ name: "get_temperature", permission_policy: "always_ask" as const }]
+ }
+ },
+ allowedTools: ["mcp__weather__get_temperature"],
+ permissionMode: "default",
+ canUseTool: async (toolName, input) => {
+ console.log(`Approval requested for ${toolName}`);
+ return { behavior: "allow", updatedInput: input };
+ }
+ }
+
+To try the policy, replace the `options` in the Call a custom tool script with this example’s `options`, then run that script from your terminal. The script prints `Approval requested for mcp__weather__get_temperature`, followed by Claude’s answer about the temperature. For a complete script, see the [TypeScript reference](</docs/en/agent-sdk/typescript#mcpsdkserverconfigwithinstance>). If you use `auto` or `plan` [permission mode](</docs/en/agent-sdk/permissions#permission-modes>), set `destructiveHint: true` in the tool’s annotations so calls to the tool still reach your callback. Otherwise the [auto mode classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) can approve some `always_ask` calls, under [conditions listed in the TypeScript reference](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>), and a call it approves doesn’t reach your callback. Set the hint explicitly, because an unset `destructiveHint` counts as `false` for `always_ask` calls rather than defaulting to `true`.
##
--- a/desktop.md
+++ b/desktop.md
@@ -104,7 +104,7 @@
Earlier versions of the Code tab labeled these modes Ask permissions, Auto accept edits, and Plan mode. The `dontAsk` permission mode is available only in the [CLI](</docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode>).
-Start complex tasks in Plan so Claude maps out an approach before making changes. Once you approve the plan, switch to Accept edits or Manual to execute it. See [explore first, then plan, then code](</docs/en/best-practices#explore-first-then-plan-then-code>) for more on this workflow.
+Start complex tasks in Plan so Claude maps out an approach before making changes. Once you approve the plan, switch to Accept edits or Manual to execute it. See [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for more on this workflow.
Cloud sessions support Accept edits, Plan, and Auto. Accept edits corresponds to `default` mode: cloud sessions pre-approve file edits, so the selector shows Accept edits instead of Manual. Bypass permissions isn’t available in cloud sessions, including sessions in a [self-hosted environment](</docs/en/self-hosted-environments>). Enterprise admins can restrict which permission modes are available. See enterprise configuration for details.
@@ -176,7 +176,7 @@
Review changes with diff view
-After Claude makes changes to your code, the diff view lets you review modifications file by file before creating a pull request. To open the diff view, click the line counts, such as `+12 -1`, in the **Changes** card of the session details panel. You can also click **Changes** in the session’s title bar. To comment on specific lines, click any line in the diff to open a comment box. Type your feedback and press **Enter** to add the comment. After adding comments to multiple lines, submit all comments at once:
+After Claude makes changes to your code, the diff view lets you review modifications file by file before creating a pull request. To open the diff view, click the line counts, such as `+12 -1`, in the **Changes** card of the session details panel. You can also click **Changes** in the session’s title bar. To comment on specific lines, hover over a line and click the **+** that appears beside its line number to open a comment box. Type your feedback and press **Enter** to add the comment. After adding comments to multiple lines, submit all comments at once:
* **macOS** : press **Cmd+Enter**
* **Windows** : press **Ctrl+Enter**
@@ -313,7 +313,7 @@
* **Cmd+Ctrl** : press **Ctrl+Alt**
* **Cmd** : press **Ctrl**
-Session cycling, the terminal toggle, and the view-mode toggle use **Ctrl** on every platform.
+Shortcuts that start with `Ctrl` stay the same on every platform.
Shortcut| Action
---|---
@@ -322,7 +322,7 @@
`Cmd` `Option` `1`–`9`| On the new session screen in the current layout, select an environment
`Cmd` `Option` `0`| On the new session screen in the current layout, open the **New environment** dialog
`Cmd` `W`| Close session
-`Ctrl` `Tab` / `Ctrl` `Shift` `Tab`| Next or previous session
+`Ctrl` `Tab` / `Ctrl` `Shift` `Tab`| Switch between sessions
`Cmd` `Shift` `]` / `Cmd` `Shift` `[`| Next or previous session
`Esc`| Stop Claude’s response
`Tab` / `Right arrow`| Accept the suggested prompt in an empty prompt box
@@ -448,7 +448,7 @@
Work in parallel with sessions
-Click **\+ New** in the sidebar, or press **Cmd+N** on macOS or **Ctrl+N** on Windows, to work on multiple tasks in parallel. Press **Ctrl+Tab** and **Ctrl+Shift+Tab** to cycle through sessions in the sidebar. You can also open a second session next to the current session or in a window of its own:
+Click **\+ New** in the sidebar, or press **Cmd+N** on macOS or **Ctrl+N** on Windows, to work on multiple tasks in parallel. Press **Ctrl+Tab** and **Ctrl+Shift+Tab** to switch between sessions. You can also open a second session next to the current session or in a window of its own:
* **Side by side** : hold **Option** on macOS or **Alt** on Windows and click a session in the sidebar, or right-click the session and select **Open in** , then **Split view**
* **In its own window** : hold **Cmd** on macOS or **Ctrl** on Windows and click a session, or right-click the session and select **Open in** , then **New window**
@@ -461,9 +461,10 @@
Run a session in its own worktree
-In a project that’s a Git repository, turn on **Worktree** before you start a session to run it in its own [Git worktree](</docs/en/worktrees>), an isolated copy of the project. By default, **Worktree** is off and Claude works in the project folder itself. Click the project folder control in the row under the prompt box and turn on **Worktree**.
-
- * **With asaved environment**: set **Worktree** when you create or edit the environment
+In a project that’s a Git repository, turn on **Worktree** before you start a session to run it in its own [Git worktree](</docs/en/worktrees>), an isolated copy of the project. By default, **Worktree** is off and Claude works in the project folder itself. On the current layout, turn on the **Worktree** button in the row under the prompt box.
+
+ * **With a[third-party provider](</docs/en/third-party-integrations>)**: if the row under the prompt box shows the project folder control but no **Worktree** button, click that control and turn on **Worktree**
+ * **As the default for asaved local or SSH environment**: set **Worktree** when you create or edit the environment
* **Earlier layout** : select the **worktree** checkbox beside the branch name, above the prompt box
Worktrees are stored in `<project-root>/.claude/worktrees/` by default. To store them in a custom directory instead:
--- a/env-vars.md
+++ b/env-vars.md
@@ -218,13 +218,13 @@
`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`| Set to `1` to remove the `run_in_background` parameter from the Bash, PowerShell, and subagent tools and to turn off the Ctrl+B shortcut and background runs of [forked skills](</docs/en/skills#run-skills-in-a-subagent>). Claude Code then also stops moving subagents, long MCP tool calls, and timed-out shell commands to the background automatically. [MCP tasks](</docs/en/mcp#make-claude-wait-for-the-result-of-an-mcp-task>) and the [Monitor tool](</docs/en/tools-reference#monitor-tool>) still run in the background
`CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_DEFAULT`| Set to `1` to stop Claude Code from treating an [Amazon Bedrock](</docs/en/amazon-bedrock>) streaming response with a missing or empty `Content-Type` header as Amazon Bedrock’s binary event stream. By default, Claude Code assumes a gateway dropped the header from an otherwise unmodified response, so it decodes the body and streaming keeps working. Set this only for a gateway that also re-emits the stream as server-sent events; Claude Code then reads the header-less body as server-sent events instead. Requires Claude Code v2.1.239 or later
`CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARD`| Set to `1` to skip the check that an [Amazon Bedrock](</docs/en/amazon-bedrock>) streaming response carries the `application/vnd.amazon.eventstream` content-type. Without this variable, when a response carries a different content-type, Claude Code fails the request with an error naming that type, which means a [gateway or proxy is transforming the response](</docs/en/amazon-bedrock#streaming-errors-behind-a-gateway-or-proxy>). Configure the gateway to forward the `Content-Type` header and body unmodified rather than setting this variable. Requires Claude Code v2.1.208 or later
-`CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF`| Set to `1` to stop a [background session’s](</docs/en/agent-view>) in-flight work when the [supervisor](</docs/en/agent-view#the-supervisor-process>) stops, restarts, or updates that session’s process, instead of handing it to the session’s next process. That work is the session’s running background shell commands and dynamic workflows, plus background subagents as of v2.1.198. Affects only that handoff: backgrounding a session with `←` or [`/background`](</docs/en/agent-view#from-inside-a-session>) still carries in-flight background work over. Requires Claude Code v2.1.196 or later
+`CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF`| Set to `1` to stop a [background session’s](</docs/en/agent-view>) in-flight work when the [supervisor](</docs/en/agent-view#the-supervisor-process>) stops, restarts, or updates that session’s process, instead of handing it to the session’s next process. That work is the session’s running background shell commands, plus background subagents as of v2.1.198. Affects only that handoff: backgrounding a session with `←` or [`/background`](</docs/en/agent-view#from-inside-a-session>) still carries in-flight background work over. Requires Claude Code v2.1.196 or later
`CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP`| Set to `1` to stop Claude Code from terminating [background shell commands](</docs/en/interactive-mode#background-bash-commands>) under memory pressure. By default, on macOS and Linux, Claude Code terminates background shells when the operating system reports critical memory pressure and the session has been idle for 30 minutes with no turn or subagent running. Windows has no memory-pressure signal, so this variable has no effect there. Requires Claude Code v2.1.193 or later
`CLAUDE_CODE_DISABLE_BUNDLED_SKILLS`| Set to `1` to disable the [skills](</docs/en/skills>) and workflows included with Claude Code: bundled skills and workflows are removed entirely, while built-in commands like `/init` stay typable but are hidden from the model. `/doctor` stays typable like the built-in commands; hide it with `DISABLE_DOCTOR_COMMAND` instead. Skills from plugins, `.claude/skills/`, and `.claude/commands/` are unaffected. Equivalent to the [`disableBundledSkills`](</docs/en/settings-reference#disablebundledskills>) setting
`CLAUDE_CODE_DISABLE_CFC_PROMPT`| Set to `1` to keep the [Claude in Chrome](</docs/en/chrome>) browser tools available while omitting the Chrome section of the system prompt and the `/claude-in-chrome` [bundled skill](</docs/en/skills#bundled-skills>). For hosts that embed Claude Code and supply their own browser guidance. Requires Claude Code v2.1.257 or later
`CLAUDE_CODE_DISABLE_CLAUDE_MDS`| Set to `1` to prevent loading any CLAUDE.md memory files into context, including user, project, and auto memory files
`CLAUDE_CODE_DISABLE_CRON`| Set to `1` to disable [session-scoped scheduled tasks](</docs/en/scheduled-tasks>). The `/loop` skill and cron tools become unavailable and any already-scheduled tasks stop firing, including tasks that are already running mid-session
-`CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT`| Set to `1` to turn off the time limit on [critical-path removal](</docs/en/permission-modes#critical-paths>) prompts. In `auto` mode Claude Code then sends these removals to the classifier instead, and in `bypassPermissions` mode the prompt waits for your answer. Set it in the environment that launches Claude Code, since Claude Code ignores a copy delivered through a settings `env` block. Requires Claude Code v2.1.281 or later
+`CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT`| Set to `1` to turn off the `auto` and `bypassPermissions` [time limit and denials](</docs/en/permission-modes#time-limits-and-denials-in-auto-and-bypasspermissions-modes>) on critical-path removals. These removals then go to the classifier in `auto` mode, and get an untimed prompt in `bypassPermissions` mode wherever Claude Code can show one. Set it in the environment that launches Claude Code, since Claude Code ignores a copy delivered through a settings `env` block. Requires Claude Code v2.1.281 or later
`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`| Set to `1` to strip pre-release `anthropic-beta` request headers, the body fields that pair with them, and beta tool-schema fields such as `defer_loading` and `eager_input_streaming` from API requests. Use this when a proxy gateway rejects requests with an `Unexpected value(s)` error for the `anthropic-beta` header or an `Extra inputs are not permitted` error. [Disable pre-release capabilities](</docs/en/llm-gateway-protocol#disable-pre-release-capabilities>) lists what the variable removes, including [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>), and what Claude Code keeps sending
`CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS`| Set to `1` to disable the built-in [Explore and Plan subagents](</docs/en/sub-agents#built-in-subagents>). Claude explores with its search tools or the general-purpose subagent instead, and [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) reads files directly rather than launching Explore and Plan agents. Custom subagents named `Explore` or `Plan` are unaffected. To remove every built-in subagent type in the Agent SDK or non-interactive mode, use `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS` instead. Requires Claude Code v2.1.198 or later
`CLAUDE_CODE_DISABLE_FAST_MODE`| Set to `1` to disable [fast mode](</docs/en/fast-mode>)
--- a/errors.md
+++ b/errors.md
@@ -236,6 +236,7 @@
`MCP server "<name>" was not saved to` / `was not removed from`| Command-line errors
`MCP server "<name>" may not have been saved` / `may not have been removed`| Command-line errors
`Server rejected the Authorization header minted by the configured headersHelper`| Command-line errors
+`This server (Java MCP SDK 0.17.0 or older) rejected Claude Code's elicitation capability`| Command-line errors
`Error: MCP tool <name> (passed via --permission-prompt-tool) not found`| Command-line errors
`OAuth callback port <port> is already in use — another process may be holding it`| Command-line errors
`No available ports for OAuth redirect`| Command-line errors
@@ -366,7 +367,7 @@
`This conversation is already open in another running Claude session`| Background session errors
`This session's saved conversation is no longer on disk`| Background session errors
`Bypass permissions was requested at launch and ignored`| [Bypass permissions ignored in a background session](</docs/en/permission-modes#bypass-permissions-ignored-in-a-background-session>)
-`kept <id> — its worktree is still at <path>`| Background session errors
+`kept <id> — its worktree is still at <path>`| Background session errors if the message’s next line mentions unpushed commits, otherwise [What deleting a session removes](</docs/en/agent-view#what-deleting-a-session-removes>)
`kept <id> — <n> unpushed commits on <branch>`| Background session errors
`kept <id> — worktree has commits that are not pushed anywhere`| Background session errors
`terminal host process died — press Enter to restart` / `This session's terminal host process died`| Background session errors
@@ -3294,6 +3295,35 @@
+MCP server rejected the elicitation capability
+
+An MCP server built on Java MCP SDK 0.11.0 through 0.17.0 refused the connection. Those SDK versions can’t parse the `form` and `url` [elicitation modes](</docs/en/mcp#elicitation-modes-claude-code-declares>) that Claude Code declares in its handshake. `claude mcp list` shows the server as failed with this message in place of the server’s own error:
+
+ This server (Java MCP SDK 0.17.0 or older) rejected Claude Code's elicitation capability. Set "bareElicitationCapability": true for it, or upgrade to Java MCP SDK 0.17.1+ (Spring AI 1.0.7+ or 1.1.6+).
+
+**What to do:**
+
+ * Upgrade the server to Java MCP SDK 0.17.1 or later, or to one of the Spring AI releases the message names
+ * Or add `"bareElicitationCapability": true` to that server’s entry in your MCP configuration, then restart Claude Code. The field is accepted on stdio, `sse`, `http`, and `ws` entries and requires Claude Code v2.1.281 or later
+
+This `.mcp.json` entry sets the field for one HTTP server:
+
+ {
+ "mcpServers": {
+ "inventory": {
+ "type": "http",
+ "url": "https://mcp.example.com/mcp",
+ "bareElicitationCapability": true
+ }
+ }
+ }
+
+After the restart, `/mcp` shows the server as connected. Claude Code declares form mode only to that server, so remove the field once you upgrade it. A server can also fail with its own error text, such as one containing `Unrecognized field "form"`. The same fixes apply.
+
+###
+
+
+
MCP permission prompt tool not found
The tool you passed to [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>) wasn’t among the connected MCP tools when the run first needed a permission decision, either because its server never connected or because no connected server exposes a tool by that name. Claude Code still sends your prompt: the [non-interactive](</docs/en/headless>) run exits with this error, and exit code 1, on the first tool call, so it produces no answer even though the request was made. Before the first prompt, Claude Code waits up to the per-server connection timeout of 30 seconds set by [`MCP_TIMEOUT`](</docs/en/env-vars>) for that server to connect. Before v2.1.206, startup didn’t wait for the server to finish connecting, so a slow-starting but healthy server produced this error too.
@@ -4895,10 +4925,10 @@
When Claude Code can’t summarize the commits, the detail line reads `The worktree has unpushed commits` instead. In [agent view](</docs/en/agent-view>), the session’s row shows `not deleted` with the same reason. Commits on a remote don’t block the delete. Neither do commits on the local copy of your `origin` remote’s default branch, as long as that branch is checked out in your main checkout, the repository directory itself rather than a worktree. **What to do:**
* To keep the commits, push the worktree’s branch, or merge it into the default branch checked out in your main checkout, then delete the session again
- * To discard the commits, run the `claude rm <id> --discard-unpushed` command the message printed, or press `Ctrl+X` twice on the session’s row in agent view again. This removes the session and the worktree along with its branch, the unpushed commits, and any uncommitted changes. If the worktree has gained a commit since the refusal, Claude Code keeps it again and shows the updated state
+ * To discard the commits, run the `claude rm <id> --discard-unpushed` command the message printed, or press `Ctrl+X` twice on the session’s row in agent view again. This removes the session and the worktree along with its branch, the unpushed commits, and any uncommitted changes. If the delete is refused again, follow the new message.
* When the message says the worktree is also recorded by another finished session, deleting again doesn’t discard it: push the commits, then delete the session again
-Before v2.1.268, `claude rm` put the commit summary on the `kept` line itself. When `claude rm` couldn’t summarize the commits, the `kept` line read `worktree has commits that are not pushed anywhere` in place of the summary. Before v2.1.260, the message didn’t name the branch or the commits, and deleting again was refused the same way: deleting the session without pushing meant removing the worktree yourself with `git worktree remove --force <path>`, then running `claude rm <id>` again. Before v2.1.248, the default branch checked out in your main checkout didn’t count: a branch you had already merged there still triggered this refusal until its commits reached a remote.
+Before v2.1.268, `claude rm` put the commit summary on the `kept` line itself. When `claude rm` couldn’t summarize the commits, the `kept` line read `worktree has commits that are not pushed anywhere` in place of the summary. Before v2.1.260, the message didn’t name the branch or commits, and there was no discard route. You can still delete the session, losing uncommitted changes but keeping the branch and commits. Run `git worktree remove --force --force <path>` with the path the refusal printed, then `claude rm <id>`. Git needs `--force` twice for a locked worktree. Before v2.1.248, the default branch checked out in your main checkout didn’t count: a branch you had already merged there still triggered this refusal until its commits reached a remote.
###
--- a/events.md
+++ b/events.md
@@ -385,7 +385,7 @@
Handle the settings hook events
-Settings hooks are the command, HTTP, prompt, and agent hooks you configure in settings files. Each [settings hook event](</docs/en/hooks#hook-events>), such as `Stop`, `SessionEnd`, or `PostToolUse`, is also an event named `classic.` followed by the settings hook event’s name, such as `classic.Stop`. `e` is the JSON a settings hook receives on stdin, including `transcript_path`. This hook uses `Stop`, which fires when Claude finishes responding, to log where the session’s transcript is saved:
+Settings hooks are the command, HTTP, prompt, and agent hooks you configure in settings files. Each [settings hook event](</docs/en/hooks#hook-events>), such as `Stop`, `SessionEnd`, or `PostToolUse`, is also an event named `classic.` followed by the settings hook event’s name, such as `classic.Stop`. `e` is the JSON a settings hook receives on stdin, including `transcript_path`. Where the [built-in guard](</docs/en/plugins/mods/admin#know-what-happens-by-default>) loads, [a hook on these events in a mod you install doesn’t run](</docs/en/plugins/mods/admin#hooks-the-guard-passes-over>). This hook uses `Stop`, which fires when Claude finishes responding, to log where the session’s transcript is saved:
on('classic.Stop', async ($, e, next) => {
// e has the same fields a Stop hook in a settings file reads from stdin
@@ -443,7 +443,7 @@
* **It failed before calling`next`**: Claude Code skips it, and the next handler runs in its place
* **It failed after`next` resolved**: that result stands, and nothing runs a second time
-One line names the mod, the event, and the reason, such as `my-mod: tool.call hook skipped: threw Error: boom`. Where you read it depends on the session, as [Find out why a mod does nothing](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>) lists. A `ui.render` hook whose drawing doesn’t validate is reported differently, as [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) describes. To make a hook that blocks calls fail closed, add a `.catch` error handler that answers in its place. Here, `guard` is your hook function, and the handler tests [`next.called`](</docs/en/plugins/mods/reference#the-hook-function>) to tell whether `guard` had already called `next` when it failed:
+One line names the mod, the event, and the reason, such as `my-mod: tool.call hook skipped: threw Error: boom`. Where you read it depends on the session, as [Find out why a mod does nothing](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>) lists. A `ui.render` hook whose [tree doesn’t validate](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) counts as one that returned the wrong shape. To make a hook that blocks calls fail closed, add a `.catch` error handler that answers in its place. Here, `guard` is your hook function, and the handler tests [`next.called`](</docs/en/plugins/mods/reference#the-hook-function>) to tell whether `guard` had already called `next` when it failed:
// on returns a registration, and .catch attaches a handler to that one hook
on('tool.call', { tool: 'Bash' }, guard).catch(async ($, e, next) => {
--- a/gallery.md
+++ b/gallery.md
@@ -260,7 +260,7 @@
`Input`
-An `Input` is a one-line text field that runs `onSubmit` when the user presses Enter:
+An `Input` is a text field that runs `onSubmit` when the user presses Enter. It holds one line unless you give it `rows`:
Input({
key: 'title',
@@ -271,7 +271,23 @@
onSubmit: noop,
})
-Without the focus, the field shows its label and its placeholder: With the focus, the label turns bold, a cursor appears, and the `submitLabel` shows after `⏎`: Typing replaces the placeholder:
+Without the focus, the field shows its label and its placeholder: With the focus, the label turns bold, a cursor appears, and the `submitLabel` shows after `⏎`: Typing replaces the placeholder: Add `rows` for a field that holds several lines, such as a note or a commit message:
+
+ Input({
+ key: 'note',
+ label: 'Note',
+ placeholder: 'Write a note',
+ rows: 4,
+ onSubmit: noop,
+ })
+
+Whatever the field holds, it takes that many rows, up to the height of the pane or band it’s drawn in. Longer text scrolls inside it.
+
+ * Enter still submits. In the terminal, the user starts a new line by typing a backslash and then pressing Enter, or by pressing Shift+Enter where [the terminal emulator supports it](</docs/en/terminal-config#enter-multiline-prompts>). Those are the same keys as in the prompt.
+ * Up and Down move between the field’s rows. From its first and last row they move to the control before or after.
+ * `onSubmit` and `onInput` receive the whole text with its lines joined by `\n`.
+
+The terminal and the Desktop app draw the rows. In the VS Code extension, the field holds one line.
###
--- a/glossary.md
+++ b/glossary.md
@@ -511,7 +511,7 @@
Verification loop
-How a session knows the work is actually done instead of accepting a result that looks plausible. You give Claude a check it can run, such as a test suite, a build, or a screenshot comparison, and Claude iterates until the check passes instead of stopping after one attempt. A verification loop is the prerequisite for [`/goal`](</docs/en/goal>), unattended runs, and [dynamic workflows](</docs/en/workflows>): without one, the only thing deciding the agent is finished is the agent itself. Learn more: [Give Claude a way to verify its work](</docs/en/best-practices#give-claude-a-way-to-verify-its-work>)
+How a session knows the work is actually done instead of accepting a result that looks plausible. You give Claude a check it can run, such as a test suite, a build, or a screenshot comparison, and Claude iterates until the check passes instead of stopping after one attempt. A verification loop is the prerequisite for [`/goal`](</docs/en/goal>), unattended runs, and [dynamic workflows](</docs/en/workflows>): without one, the only thing deciding the agent is finished is the agent itself. Learn more: [Give Claude a check to run](</docs/en/best-practices#give-claude-a-check-to-run>)
##
--- a/hooks-guide.md
+++ b/hooks-guide.md
@@ -589,6 +589,7 @@
* Reads from [network paths](</docs/en/permissions#network-paths>)
* MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>)
+ * Calls to [tools an Agent SDK app marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>), unless the [permission mode approves the call](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>)
* Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) in sessions where that setting reaches Claude Code
For what `"allow"` does in plan mode, see [Hook approvals in plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>). A fourth value, `"defer"`, is available in [non-interactive mode](</docs/en/headless>) with the `-p` flag. Returning it ends the turn with the tool call preserved, so an Agent SDK wrapper can collect input and resume. See [Defer a tool call for later](</docs/en/hooks#defer-a-tool-call-for-later>) in the reference. A `PreModelSwitch` hook returns the same `permissionDecision` field: `"allow"` lets a model switch proceed, and `"deny"` cancels it. `"ask"` has you confirm the switch when you run `/model` in an interactive session; everywhere else, Claude Code treats `"ask"` as a refusal. See [PreModelSwitch decision control](</docs/en/hooks#premodelswitch-decision-control>). Other events use different decision patterns. For example, `PostToolUse` and `Stop` hooks use a top-level `decision: "block"` field, while `PermissionRequest` uses `hookSpecificOutput.decision.behavior`. See the [summary table](</docs/en/hooks#decision-control>) in the reference for a full breakdown by event. For `UserPromptSubmit` hooks, use `hookSpecificOutput.additionalContext` instead to inject text into Claude’s context. Nest `additionalContext` inside `hookSpecificOutput`; if you place it at the top level of the JSON, Claude Code silently ignores it. For example, this output adds the current branch state to every prompt:
@@ -901,6 +902,7 @@
* **What still holds over`"allow"`**: a hook returning `"allow"` doesn’t bypass deny rules from settings, and it can’t suppress the prompt for:
* Reads from [network paths](</docs/en/permissions#network-paths>)
* MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>)
+ * Calls to [tools an Agent SDK app marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>), unless the [permission mode approves the call](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>)
* Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) in sessions where that setting reaches Claude Code
In [plan mode](</docs/en/permissions#hook-approvals-in-plan-mode>), if your `PreToolUse` hook returns `"allow"` for a file edit, you get the same prompt, block, or approval the edit would get with no hook. To lift this limit on hook approvals, [approve the plan](</docs/en/permission-modes#review-and-approve-a-plan>) or switch to another permission mode.
* **`"deny"` in every permission mode**: a hook that returns `permissionDecision: "deny"` blocks the tool even in `bypassPermissions` mode or with `--dangerously-skip-permissions`. `PreToolUse` hooks fire before any permission-mode check, in every [permission mode](</docs/en/permission-modes>), including `dontAsk`. This lets you enforce policy that users can’t bypass by changing their permission mode.
--- a/host-marketplace.md
+++ b/host-marketplace.md
@@ -443,7 +443,7 @@
* **Version ranges** : a dependency can carry a semver range.
* **Cross-marketplace dependencies** : a dependency from another marketplace installs only when your marketplace lists that marketplace in `allowCrossMarketplaceDependenciesOn`.
-For version ranges, the `<plugin>--v<version>` git-tag convention they resolve against, and cross-marketplace trust, see [Plugin dependencies](</docs/en/plugins/dependencies>). To have Claude Code suggest a plugin when a project matches it, add a `relevance` block to the entry with the signals that identify the project. Users see suggestions from your marketplace only when an admin lists it in `pluginSuggestionMarketplaces`. For the signals and the enablement step, see [Plugin relevance](</docs/en/plugins/relevance>).
+For version ranges, the `<plugin>--v<version>` git-tag convention they resolve against, and cross-marketplace trust, see [Plugin dependencies](</docs/en/plugins/dependencies>). To have Claude Code suggest a plugin when a project matches it, add a `relevance` block to the entry with the signals that identify the project. Users see these suggestions only when an admin lists your marketplace in `pluginSuggestionMarketplaces`. For the signals and the enablement step, see [Plugin relevance](</docs/en/plugins/relevance>).
##
--- a/how-claude-code-works.md
+++ b/how-claude-code-works.md
@@ -192,7 +192,7 @@
Work effectively with Claude Code
-These tips help you get better results from Claude Code. For more on specific prompts, verification, and planning, see [Best practices](</docs/en/best-practices>).
+These tips help you get better results from Claude Code. For more on specific prompts, verification, and the rules worth enforcing rather than prompting for, see [Best practices](</docs/en/best-practices>).
###
--- a/interactive-mode.md
+++ b/interactive-mode.md
@@ -442,7 +442,7 @@
In shell mode, the key only queues your command. In terminals that don’t report extended keys, `Ctrl+Enter` arrives as plain `Enter` and queues the draft instead; `Ctrl+X Ctrl+S` works in any terminal. Both keys are bindings of the [`chat:sendNow` action](</docs/en/keybindings#chat-actions>). Press `Esc` to interrupt the turn without submitting your draft. Claude Code keeps what you queued and sends it right away. Claude Code runs some commands as soon as you send them instead of queueing them, among them `/model`, `/effort`, and `/fast`. Each of the three changes a setting: the model, the effort level, or fast mode. Whether Claude Code applies the new setting to the turn Claude is already working on, or only from your next turn, differs by command:
* [`/model`](</docs/en/model-config#setting-your-model>): once you confirm the [cache warning](</docs/en/prompt-caching#switching-models>), if Claude Code shows one, Claude Code applies your change to the next request it makes in that turn
- * [`/effort`](</docs/en/model-config#adjust-effort-level>): once you confirm the [cache warning](</docs/en/prompt-caching#changing-effort-level>), if Claude Code shows one, Claude Code applies your change to the next request it makes in that turn
+ * `/effort`: the next message you send runs at the new level. To [start it in the turn Claude is already working on](</docs/en/model-config#when-a-new-effort-level-starts>), queue a message while Claude is running tool calls
* [`/fast`](</docs/en/fast-mode#toggle-fast-mode>): Claude Code keeps the fast mode setting that was active when the turn started, so your speed change applies from your next turn. If your current model doesn’t support fast mode, turning it on also [switches your model](</docs/en/prompt-caching#turning-on-fast-mode>), and Claude Code uses the new model from its next request in that turn
###
--- a/interface.md
+++ b/interface.md
@@ -371,6 +371,8 @@
Note: Type a note and press Enter
+Add `rows` to let the field hold several lines. Enter still submits, and a backslash before Enter starts a new line, as does Shift+Enter where [the terminal supports it](</docs/en/terminal-config#enter-multiline-prompts>). The gallery shows [a field with `rows`](</docs/en/plugins/mods/gallery#input>).
+
The [interface gallery](</docs/en/plugins/mods/gallery>) has samples and screenshots of most elements. This table lists every element:
Element| What it draws| Where
@@ -384,7 +386,9 @@
`Client`| A region drawn by a second file of yours, for animation and pointer input. That file gets no mods API. It reaches your hooks by posting data, which arrives as a `ui.message` event. If it fails to load, draw, or run, your hooks receive a [`ui.fault`](</docs/en/plugins/mods/reference#interface>) event.| Terminal, Desktop
`Raster`, `Image`| A grid of colored cells, and a picture| Terminal
-If your module is a `.tsx` or `.jsx` file, you can write the tree as JSX. Destructure the elements from `$.ui.resolve(e)` first. If a tree uses an element the app doesn’t have, a prop an element doesn’t take, or a child where none goes, Claude Code draws its own version of the site. In a session started with `--plugin-dir`, a transcript line says so, such as `ui.render (Pane) refused: Text prop "bogusProp" is not allowed; the engine drew its own`. The [debug log](</docs/en/plugins/mods/troubleshoot#read-the-debug-log>) records it as `ui.render (Pane): a hook returned a tree that does not validate` with the same reason. Nothing else appears in the session, so when a drawing doesn’t show up, check that line or the log.
+If your module is a `.tsx` or `.jsx` file, you can write the tree as JSX. Destructure the elements from `$.ui.resolve(e)` first. If your drawing doesn’t show up, check its tree for a prop an element doesn’t take or a child where none goes. A hook that returns such a tree [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>), and a [`hook skipped` line](</docs/en/plugins/mods/troubleshoot#a-pane-or-band-is-empty>) names your mod and the rule the tree broke. For a `Text` in a pane with a prop named `bogusProp`, that line reads:
+
+ my-mod: ui.render hook skipped: returned the wrong shape (a tree Pane refuses: Text prop "bogusProp" is not allowed)
###
@@ -504,7 +508,7 @@
Key| What it does
---|---
Tab| Moves to the next control
-Up and Down| Move between controls while your drawing fits. When the pane or band has more rows than it can show, they scroll it.
+Up and Down| Move between controls while your drawing fits. When the pane or band has more rows than it can show, they scroll it. In an `Input`, they [move between the field’s rows](</docs/en/plugins/mods/gallery#input>) first.
Enter| Presses the focused `Button`, submits the focused `Input`, or picks in a `Select`
A button’s hotkey| Presses that button. While an `Input` has the focus, every printable key goes to the field.
Page Up, Page Down, Home, and End| Scroll your pane or band when it has more rows than it can show
--- a/large-codebases.md
+++ b/large-codebases.md
@@ -27,7 +27,7 @@
Give Claude procedures specific to one area that load only when relevant| Per-directory skills
Replace many per-directory CLAUDE.md files with one set of conventions everyone installs| A plugin in an internal marketplace
-For workflow techniques that keep context small in any repository, such as [running exploration in a subagent](</docs/en/best-practices#use-subagents-for-investigation>) so file reads stay out of the main conversation, see [Best practices for Claude Code](</docs/en/best-practices>). To roll out a baseline configuration to every developer in your organization, see [Set up Claude Code for your organization](</docs/en/admin-setup>).
+For workflow techniques that keep context small in any repository, see [Best practices for Claude Code](</docs/en/best-practices>). One example is [running exploration in a subagent](</docs/en/best-practices#know-what-subagents-cost>) so file reads stay out of the main conversation. To roll out a baseline configuration to every developer in your organization, see [Set up Claude Code for your organization](</docs/en/admin-setup>).
###
@@ -439,7 +439,7 @@
The configuration above controls what Claude sees. When a single change touches several packages, such as updating a shared type along with every call site that uses it, how you scope and sequence the task also affects the result. Two techniques help keep a cross-package change consistent:
* **Give Claude the whole change in one session** : handing over the shared edit and its call sites together keeps the decisions behind each edit consistent, rather than re-deriving them per package
- * **Plan before editing** : [plan first](</docs/en/best-practices#explore-first-then-plan-then-code>) in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), and Claude writes the plan to a file. A long cross-package session [compacts its context](</docs/en/context-window#what-survives-compaction>) along the way. Claude Code re-injects the plan file after each compaction, so the plan survives where conversation history may not
+ * **Plan before editing** : plan first in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), and Claude writes the plan to a file. A long cross-package session [compacts its context](</docs/en/context-window#what-survives-compaction>) as it goes. Claude Code re-injects the plan file after each compaction, so the plan survives where conversation history may not
##
--- a/managed-settings.md
+++ b/managed-settings.md
@@ -403,7 +403,7 @@
[`managedMcpServers`](</docs/en/settings-reference#managedmcpservers>)| Remote MCP servers provided to every user alongside their own. It provides servers rather than locking anything down. See [Provide servers through managed settings](</docs/en/managed-mcp#provide-servers-through-managed-settings>). Requires Claude Code v2.1.259 or later
[`managedSourcesBehavior`](</docs/en/settings-reference#managedsourcesbehavior>)| Whether Claude Code applies only the highest-priority managed source or composes every one of them
[`parentSettingsBehavior`](</docs/en/settings-reference#parentsettingsbehavior>)| Whether host-supplied parent settings merge under the managed policy
-[`pluginSuggestionMarketplaces`](</docs/en/settings-reference#pluginsuggestionmarketplaces>)| Marketplaces whose plugins Claude Code may suggest to users
+[`pluginSuggestionMarketplaces`](</docs/en/settings-reference#pluginsuggestionmarketplaces>)| Marketplaces whose plugins Claude Code may suggest to users in the terminal
[`pluginTrustMessage`](</docs/en/settings-reference#plugintrustmessage>)| Custom message appended to the plugin trust warning shown before installation
[`policyHelper`](</docs/en/settings-reference#policyhelper>)| Executable that computes managed settings at startup; see [Compute managed settings with a policy helper](</docs/en/settings-reference#policyhelper>)
[`sandbox.filesystem.allowManagedReadPathsOnly`](</docs/en/settings-reference#sandbox-filesystem-allowmanagedreadpathsonly>)| When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources
--- a/model-config.md
+++ b/model-config.md
@@ -460,7 +460,7 @@
When Claude Code switches your session to the fallback model, it keeps the effort level the flagged request ran at. For example, a session on Opus 5.5 at its default `medium` that falls back to Opus 4.8 stays at `medium`, although Opus 4.8 defaults to `high`. A different level applies in cases such as these:
* **Your own change** : once you choose an effort level, pick a model in `/model`, or resume the session later, the flagged request’s level no longer carries over.
- * **Skill effort** : a level that a skill’s `effort` frontmatter set for the flagged request applies to that turn, and later turns run at the level the effort resolution order gives the fallback model.
+ * **Effort set for one turn** : if you raised the flagged turn with `ultrathink`, or a skill’s `effort` frontmatter set its level, that level applies to that turn. Later turns run at the level the effort resolution order gives the fallback model.
In the session, run `/effort status` to see the level in effect, or `/effort` to change it.
@@ -582,7 +582,11 @@
Use ultrathink for one-off deep reasoning
-Include `ultrathink` anywhere in your prompt to request deeper reasoning on that turn without changing your session effort setting. Claude Code recognizes the keyword and adds an in-context instruction. The effort level sent to the API is unchanged. Claude Code passes other phrases such as “think”, “think hard”, and “think more” through as ordinary prompt text and doesn’t recognize them as keywords.
+Include `ultrathink` anywhere in your prompt to request deeper reasoning on that turn without changing your session effort setting. Claude Code recognizes the keyword and adds an in-context instruction. Claude Code passes other phrases such as “think”, “think hard”, and “think more” through as ordinary prompt text and doesn’t recognize them as keywords. Typed in the terminal prompt, the word can also raise that turn to `xhigh` effort. When it can, the word shows in rainbow colors. Requires Claude Code v2.1.311 or later. If the word isn’t rainbow when you start a new turn, try one of these:
+
+ * Retype it outside anything such as quotes, brackets, a path, or a command, in a prompt that doesn’t start with `/`
+ * Unset `CLAUDE_CODE_EFFORT_LEVEL` if it’s set below `xhigh`, raise your own [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>) to `xhigh` or above, or ask an organization admin to raise your organization’s limit
+ * Run `/model` in your session to switch to an Opus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.1 model. Where the word can’t raise a turn, such as on Amazon Bedrock, set the effort level instead
####
@@ -592,7 +596,7 @@
You can change effort through any of the following:
- * **`/effort`** : run `/effort` with no arguments to open an interactive slider, `/effort` followed by a level name to set it directly, or `/effort auto` to clear your saved level for the active model. You can run it while Claude is working, and once you confirm the [cache warning](</docs/en/prompt-caching#changing-effort-level>), if Claude Code shows one, Claude Code applies the new level to the next request in the turn
+ * **`/effort`** : run `/effort` with no arguments to open an interactive slider, `/effort` followed by a level name to set it directly, or `/effort auto` to clear your saved level for the active model
* **In`/model`**: use left/right arrow keys to adjust the effort slider when selecting a model
* **`--effort` flag**: pass a level name to set it for a single session when launching Claude Code
* **Environment variable** : set `CLAUDE_CODE_EFFORT_LEVEL` to a level name or `auto`
@@ -600,7 +604,28 @@
* **From a connected device** : in a [Remote Control](</docs/en/remote-control#what-connected-devices-see>) session, pick a level from the effort control on your phone or in your browser. The level applies to the current session only. Requires Claude Code v2.1.234 or later
* **Skill and subagent frontmatter** : set `effort` in a [skill](</docs/en/skills#frontmatter-reference>) or [subagent](</docs/en/sub-agents#supported-frontmatter-fields>) markdown file to override the effort level when that skill or subagent runs
-Frontmatter effort applies when that skill or subagent is active, overriding the session level but not the environment variable. A [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>) or organization effort cap still limits the level the skill or subagent runs at. If you set `effortLevel` in [managed settings](</docs/en/managed-settings>), Claude Code applies it at the settings step of the effort resolution order, and users can still change the level with `/effort` or `--effort`. To keep users at or below a level, set [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>). The effort slider appears in `/model` when a supported model is selected. The current effort level is also shown in the session header next to the model name, for example “with low effort”, so you can confirm which setting is active without opening `/model`. The footer also briefly shows the effort level at startup and when it changes.
+Frontmatter effort applies when that skill or subagent is active, overriding the session level but not the environment variable. A [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>) or organization effort cap still limits the level the skill or subagent runs at. If you set `effortLevel` in [managed settings](</docs/en/managed-settings>), Claude Code applies it at the settings step of the effort resolution order, and users can still change the level with `/effort` or `--effort`. To keep users at or below a level, set [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>).
+
+####
+
+
+
+Check the effort level you set
+
+The effort slider appears in `/model` when a supported model is selected. A level in the session header, for example “with low effort”, comes from your effort setting, even if Claude is still working at the old level. The footer also briefly shows the effort level at startup and when it changes.
+
+####
+
+
+
+When a new effort level starts
+
+In a terminal session, once `/effort` confirms the new level, the next message you send runs at that level. You can send it after the turn in progress ends or [while Claude is still working](</docs/en/interactive-mode#queue-messages-while-claude-works>):
+
+ * **After the turn ends** : you don’t have to do anything until then, and it’s expected if the turn finishes at the old level
+ * **While Claude is still working** : type a message, such as `keep going`, and press `Enter` to queue it without interrupting the turn. Claude gets it when its current tool calls finish, or when the turn ends at the latest, and works at the new level from then on.
+
+Before v2.1.242, Claude Code could queue `/effort` itself until the turn finished, and always did in a session that doesn’t [fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>), such as on a [third-party provider](</docs/en/third-party-integrations>).
####
--- a/org.md
+++ b/org.md
@@ -186,11 +186,11 @@
`blockedMarketplaces`| Blocklist of marketplace sources, checked before the allowlist| Doesn’t block a marketplace already registered from a source it doesn’t match
`syncClaudeAiPlugins`| Set `false` to stop Claude Code downloading and loading the plugins [synced from claude.ai](</docs/en/plugins/loading#synced-plugins>) for each user’s account. Requires Claude Code v2.1.273 or later| Doesn’t turn off one synced plugin. For that, set `"<name>@synced": false` in [`enabledPlugins`](</docs/en/settings-reference#enabledplugins>)
`enabledPlugins`| `true` force-enables, `false` blocks at every scope and hides the plugin| Doesn’t install a plugin whose marketplace isn’t registered or allowed
-`disableSideloadFlags`| Rejects `--plugin-dir`, `--plugin-url`, `--agents`, the Agent SDK `plugins` option, and non-SDK `--mcp-config` at startup, and rejects folders named in the [`CLAUDE_CODE_PLUGIN_DIRS`](</docs/en/env-vars#variables>) variable the same way| Doesn’t restrict `.mcp.json`, `claude mcp add`, or SDK-provided servers. Pair it with [`allowedMcpServers`](</docs/en/managed-mcp>)
+`disableSideloadFlags`| Rejects `--plugin-dir`, `--plugin-url`, `--agents`, the Agent SDK `plugins` option, and folders named in the [`CLAUDE_CODE_PLUGIN_DIRS`](</docs/en/env-vars#variables>) variable at startup, and `--mcp-config` too unless every server in it is an in-process `type: "sdk"` entry. Refuses plugin folders an Agent SDK application adds mid-session with [`addPlugins`](</docs/en/agent-sdk/typescript#load-more-plugin-folders-with-addplugins>)| Doesn’t restrict `.mcp.json`, `claude mcp add`, or SDK-provided servers. Pair it with [`allowedMcpServers`](</docs/en/managed-mcp>)
`disableCommandPluginSources`| Blocks plugins with a `command` source from installing, updating, or loading. A `command` source is one whose plugin directory is produced by running a command on the machine. When unset, it takes the value of `allowManagedHooksOnly`| Doesn’t affect other source types
`allowManagedHooksOnly`| Restricts which hooks run. See [`allowManagedHooksOnly`](</docs/en/settings-reference#allowmanagedhooksonly>)| Doesn’t trust hooks from plugins users enable themselves
`strictPluginOnlyCustomization`| Blocks skills, agents, hooks, and MCP servers that don’t come from a plugin, managed settings, or Claude Code’s built-ins. It also stops skills-directory plugins loading. Set `true` to cover all four types, or an array of `skills`, `agents`, `hooks`, and `mcp` values such as `["skills", "hooks"]` to cover some| Doesn’t restrict which plugins users install. Pair it with `strictKnownMarketplaces`
-`pluginSuggestionMarketplaces`| Marketplaces whose plugins may appear as install suggestions. See Recommend plugins| Doesn’t affect the built-in tips
+`pluginSuggestionMarketplaces`| Marketplaces whose plugins may appear as install suggestions in the terminal. See Recommend plugins| Doesn’t affect the built-in tips
`pluginTrustMessage`| Appends your text to the trust warning that `/plugin` shows before a plugin installs| Doesn’t change the warning’s own text
`allowedChannelPlugins`| Replaces the default list of plugins allowed to push channel messages. Requires `channelsEnabled: true`| See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>)
[`CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL=1`](</docs/en/env-vars>)| Stops interactive terminal sessions from auto-registering the official marketplace| Doesn’t remove a marketplace already registered. The allowlist and blocklist gate the same auto-registration without it. A machine that started once with it set doesn’t resume auto-registration after you unset it
@@ -395,6 +395,8 @@
Marketplace owners can attach `relevance` signals to entries so Claude Code suggests the plugin when a project matches. Suggestions from a marketplace appear only when it’s registered on the user’s machine, you list its name in `pluginSuggestionMarketplaces` in managed settings, and you declare its source in the same policy. Declare the source either as the marketplace’s `extraKnownMarketplaces` entry or as an allowlist entry. The official marketplace needs only the name. See [Enable suggestions in managed settings](</docs/en/plugins/relevance#enable-suggestions-in-managed-settings>).
+In a cloud session’s conversation, Claude can suggest plugins whether or not you set `pluginSuggestionMarketplaces`. To turn those suggestions off, see [Turn off plugin suggestions](</docs/en/claude-code-on-the-web#turn-off-plugin-suggestions>).
+
##
Show diff (110 lines)
--- a/permission-modes.md
+++ b/permission-modes.md
@@ -30,7 +30,7 @@
* Tools matched by an explicit [ask rule](</docs/en/permissions#manage-permissions>)
* Connector tools your organization [set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), in sessions where that setting reaches Claude Code
* Tools that require user interaction: the built-in `AskUserQuestion` tool and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>)
- * Recognized `rm` and `rmdir` critical-path removals, which no allow rule or `PreToolUse` hook `"allow"` approves
+ * Recognized `rm` and `rmdir` critical-path removals, which no allow rule or `PreToolUse` hook `"allow"` approves, and Bash commands flagged `Dangerous rm operation not ruled out`
* The cross-session messaging safeguards
* Reads outside the working directories while [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) is on: recognized file-reading Bash commands prompt even in auto mode and `bypassPermissions` mode, and so does any [unsandboxed retry](</docs/en/sandboxing#the-unsandboxed-retry-escape-hatch>) that needs approval to run outside the sandbox. Requires Claude Code v2.1.257 or later. A command the shell parser can’t trace, such as one that changes directory more than once or runs a subshell, prompts the same way even when it names no outside path. This prompt doesn’t apply when the command runs in the [sandbox](</docs/en/sandboxing>) and the sandbox enforces the block.
@@ -229,11 +229,12 @@
Auto-approve file edits with acceptEdits mode
-`acceptEdits` mode lets Claude create and edit files in your working directory without prompting. The status bar shows `⏵⏵ accept edits on` while this mode is active. In addition to file edits, `acceptEdits` mode auto-approves common filesystem Bash commands: `mkdir`, `touch`, `rm`, `rmdir`, `mv`, `cp`, and `sed`. These commands are also auto-approved when prefixed with safe environment variables such as `LANG=C` or `NO_COLOR=1`, or process wrappers such as `timeout`, `nice`, or `nohup`. Like file edits, auto-approval applies only to paths inside your working directory or `additionalDirectories`. These still prompt:
+`acceptEdits` mode lets Claude create and edit files in your working directory without prompting. The status bar shows `⏵⏵ accept edits on` while this mode is active. In addition to file edits, `acceptEdits` mode auto-approves common filesystem Bash commands: `mkdir`, `touch`, `rm`, `rmdir`, `mv`, `cp`, and `sed`. Except for `touch`, these commands are also auto-approved when prefixed with safe environment variables such as `LANG=C` or `NO_COLOR=1`, or process wrappers such as `timeout`, `nice`, or `nohup`. Like file edits, auto-approval applies only to paths inside your working directory or `additionalDirectories`. These still prompt:
* Paths outside that scope
* Writes to protected paths
* Recognized `rm` and `rmdir` critical-path removals
+ * `touch` with anything beyond plain file paths, for example an option, a glob, or a prefix such as `timeout 5` or `LANG=C`
* All other Bash commands except the [built-in read-only set](</docs/en/permissions#read-only-commands>)
Each path also goes through the [symlink check](</docs/en/permissions#symlinks>), so a write that resolves outside that scope isn’t auto-approved either. When the [PowerShell tool](</docs/en/tools-reference#powershell-tool>) is enabled, `acceptEdits` mode also auto-approves `Set-Content`, `Add-Content`, `Clear-Content`, and `Remove-Item` on in-scope paths, along with their common aliases. The same scope and protected-path rules apply, and `Remove-Item` gets its own check. A positional argument that contains a quote character, such as the apostrophe in `Set-Content .\notes.txt "It's done"`, still prompts even on in-scope paths, because Claude Code can’t statically validate an argument whose quoted and unquoted readings differ. Pass the content through a named parameter such as `-Value` to avoid the prompt. Use `acceptEdits` when you want to review changes in your editor or via `git diff` after the fact rather than approving each edit inline. Press `Shift+Tab` once from Manual mode to enter it, or start with it directly:
@@ -323,6 +324,7 @@
* **A direct connection to the Anthropic API** : in interactive terminal sessions and in `-p`, Agent SDK, [VS Code extension](</docs/en/vs-code>), and [desktop app](</docs/en/desktop>) sessions, whatever your plan or account type, as Anthropic rolls it out. In interactive terminal sessions, this requires Claude Code v2.1.271 or later on Pro, Max, and Team plans, and v2.1.278 or later on Enterprise plans and Claude API accounts. In `-p`, Agent SDK, VS Code extension, and desktop app sessions, this requires Claude Code v2.1.281 or later. From v2.1.282, a session that [doesn’t fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>), for example because you turned telemetry off, asks the server by default in any kind of session.
* **A cloud provider, or an LLM gateway or proxy** : on [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, and whenever you point `ANTHROPIC_BASE_URL` at an [LLM gateway or proxy](</docs/en/llm-gateway>), whatever your plan. Asking by default requires Claude Code v2.1.278 or later.
* **A signed-in[Claude apps gateway](</docs/en/claude-apps-gateway>) session**: requires Claude Code v2.1.280 or later
+ * **A[cloud session](</docs/en/claude-code-on-the-web>) in an Anthropic-hosted environment**: whatever your plan, when you start it from the web, the mobile app, or the desktop app with **Cloud** selected. Sessions started by a [cloud scheduled task](</docs/en/routines>) ask the server as Anthropic rolls it out.
Where the server reviews the actions, its verdicts decide them. Two other outcomes are possible:
@@ -595,7 +597,7 @@
Skip all checks with bypassPermissions mode
-`bypassPermissions` mode disables permission prompts and safety checks so tool calls execute immediately, including writes to protected paths. The actions no mode auto-approves still prompt in this mode. Reading [another organization’s public artifact](</docs/en/artifacts#read-an-artifact-shared-with-you>) needs your approval, and this mode doesn’t ask for it, so Claude can’t read one. The Remove-Item in PowerShell denies also apply in this mode. Two [cross-session messaging](</docs/en/cross-session-messaging>) safeguards still apply in this mode, and in interactive terminal plan-mode sessions where bypass permissions are available:
+`bypassPermissions` mode disables permission prompts and safety checks so tool calls execute immediately, including writes to protected paths. Even in `bypassPermissions` mode, each of the actions no mode auto-approves gets a prompt or a denial instead of running on its own. Reading [another organization’s public artifact](</docs/en/artifacts#read-an-artifact-shared-with-you>) needs your approval, and this mode doesn’t ask for it, so Claude can’t read one. The Remove-Item in PowerShell denies also apply in this mode. Two [cross-session messaging](</docs/en/cross-session-messaging>) safeguards still apply in this mode, and in interactive terminal plan-mode sessions where bypass permissions are available:
* The [`isolatePeerMachines`](</docs/en/settings-reference#isolatepeermachines>) approval prompt for messages to your sessions beyond this machine still appears.
* When no [`crossSessionInbound`](</docs/en/cross-session-messaging#control-inbound-messages>) value applies, Claude Code holds an inbound message from another of your sessions for your approval, and delivers without asking only when the sending session identifies itself as also bypassing permission prompts. If you leave the permission mode while messages are held, Claude Code re-applies the inbound rules and delivers any held message they now accept.
@@ -701,6 +703,7 @@
* `.devcontainer.json`
* `.ripgreprc`, `pyrightconfig.json`
* `.mcp.json`, `.claude.json`
+ * A file you passed to [`--settings`](</docs/en/cli-reference#cli-flags>), `--mcp-config`, or `--agents` when you started the session
* The file that your user, project, or local [settings file](</docs/en/settings#settings-files-and-who-they-affect>) points to when the settings file is itself a symbolic link, for example into a dotfiles repository. In the modes that route protected-path writes to the classifier, a write to this file prompts you instead, even when an allow rule matches. If the file’s own path is also that of a settings file, such as `.claude/settings.json` in another folder, the write goes to the classifier as other protected-path writes do
##
@@ -794,6 +797,22 @@
+The `Dangerous rm operation not ruled out` prompt
+
+The full reason reads:
+
+ Dangerous rm operation not ruled out — the shell may read this command differently than it was parsed
+
+This reason means the shell may read the command differently than Claude Code did, so a removal could sit in an unchecked part, even with no `rm` present. In `auto` or `bypassPermissions` mode, a denial with this sentence comes from the same check:
+
+ This command could not be checked for dangerous rm operations: the shell may read it differently than it was parsed.
+
+You get the prompt or denial a critical-path removal gets in your permission mode, `bypassPermissions` included. You can’t approve the command with a `Bash` or `Bash(*)` allow rule, sandbox [auto-allow mode](</docs/en/sandboxing#auto-allow-mode>), or a `PreToolUse` hook returning `"allow"`. Read the command, then approve the prompt or, after a denial, run it in your shell.
+
+###
+
+
+
The mounted drive prompt
The mounted drive prompt appears on macOS, Linux, and WSL when a recursive `rm` targets a listed mounted drive path, such as `/mnt/c` or `/Volumes/USB/build`. Its reason reads `Dangerous rm operation on mounted drive path: <path>`. A `/*` target gets the prompt without the recursive flag, since Claude Code reads `rm /Volumes/USB/build/*` as a removal of `/Volumes/USB/build`. Even with an allow rule for `rm`, Claude Code handles the command as a critical-path removal: a prompt or a denial depending on your permission mode. Approve the prompt to let the `rm` run, or turn the prompt off.
@@ -858,7 +877,7 @@
`plan`| Asks you to approve it. When the classifier reviews commands during planning and no bypass permissions are available, handles it as in `auto` mode
`auto`| Asks you to approve it in the terminal, with a time limit. Elsewhere, denies it
`dontAsk`| Denies it
-`bypassPermissions`| Asks you to approve it, with a time limit in the terminal
+`bypassPermissions`| In the terminal, asks you to approve it before a time limit runs out. Elsewhere, see what happens in each place
If an explicit [ask rule](</docs/en/permissions#manage-permissions>) matches the command, Claude Code asks you instead, even in `auto` mode and without a time limit. In modes that ask, a [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) can answer the prompt.
@@ -874,7 +893,26 @@
* Press any key while the prompt is open to stop the countdown and keep the prompt waiting for your answer.
* After three of these prompts run out unanswered in a session, Claude Code stops showing them and denies further critical-path removals immediately. Sending a new message starts the count over.
-In `auto` mode, wherever Claude Code can’t show you a terminal prompt, it denies the command immediately, for example in [non-interactive runs](</docs/en/headless>) with `-p`, in [Agent SDK](</docs/en/agent-sdk/permissions>) sessions, and in the VS Code extension’s chat panel and the Desktop app. The denial tells Claude to report what it wanted to delete and leave the removal to you. The `auto` and `bypassPermissions` handling requires Claude Code v2.1.281 or later. To turn it off, set [`CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT=1`](</docs/en/env-vars#variables>) in the environment that launches Claude Code. In `auto` mode, critical-path removals then go to the classifier instead, and in `bypassPermissions` mode the prompt has no time limit.
+The time limit applies in Claude Code v2.1.281 and later, and so does the `auto` mode denial outside the terminal. Away from the terminal, you don’t get that prompt:
+
+Where| `auto`| `bypassPermissions`
+---|---|---
+[VS Code extension](</docs/en/vs-code>)’s chat panel| Denies it| Denies it unless a [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) allows it
+[Desktop app](</docs/en/desktop>)| Denies it| Denies it unless a `PermissionRequest` hook allows it
+[`-p` run](</docs/en/headless>) or [Agent SDK session](</docs/en/agent-sdk/permissions>)| Denies it| Your [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>) or [`canUseTool` callback](</docs/en/agent-sdk/user-input#handle-tool-approval-requests>) decides. With neither, or under [`--permission-prompts none`](</docs/en/headless#turn-off-permission-prompts-in-unattended-runs>), denies it unless a `PermissionRequest` hook allows it
+
+Wherever the removal is denied, you can read the whole command and run it in your shell. To change what you get in each mode, set [`CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT`](</docs/en/env-vars#variables>) to `1`:
+
+ * **`bypassPermissions`** : the terminal prompt has no time limit, and the VS Code chat panel asks you
+ * **`auto`** : the classifier decides, in the terminal, the VS Code chat panel, `-p` runs and Agent SDK sessions
+
+Set it in the environment that starts Claude Code, such as your shell or the SDK’s `env` option, not in a Claude Code settings file. For the chat panel, add it to [`claudeCode.environmentVariables`](</docs/en/vs-code#extension-settings>) in VS Code’s own user `settings.json`, then start a new conversation:
+
+ {
+ "claudeCode.environmentVariables": [
+ { "name": "CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT", "value": "1" }
+ ]
+ }
###
Show diff (150 lines)
--- a/permissions.md
+++ b/permissions.md
@@ -6,6 +6,8 @@
How permissions are evaluated
+If you load a plugin that contains a [mod](</docs/en/plugins/mods/overview>), see [where a mod’s decisions fit among rules and hooks](</docs/en/permissions#precedence-among-rules-hooks-and-mods>).
+
When Claude requests a tool, the SDK checks permissions in this order:
1
@@ -18,13 +20,13 @@
Deny rules
-Check `deny` rules (from `disallowed_tools` and [settings.json](</docs/en/settings-reference#permission-settings>)). If a deny rule matches, the tool is blocked, even in `bypassPermissions` mode. Bare-name deny rules like `Bash` remove the tool from Claude’s context before this evaluation begins, so only scoped rules like `Bash(rm *)` are checked at this step.
+If a deny rule from `disallowed_tools` or [settings.json](</docs/en/settings-reference#permission-settings>) matches, the call is denied and [`canUseTool`](</docs/en/agent-sdk/user-input>) isn’t called, even in `bypassPermissions` mode and even when a hook returned `allow`.In the TypeScript SDK, if you set the `permission_policy` of a [custom tool](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) to [`always_deny`](</docs/en/agent-sdk/typescript#mcpservertoolpolicy>), a call to that tool is denied at this step.
3
Ask rules
-Check `ask` rules from [settings.json](</docs/en/settings-reference#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts.
+Check `ask` rules from [settings.json](</docs/en/settings-reference#permission-settings>). If an ask rule matches, the call falls through to your [`canUseTool` callback](</docs/en/agent-sdk/user-input>) for confirmation, even in `bypassPermissions` mode.Tools that require user interaction behave the same way: `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>) always fall through to the callback, even when an allow rule matches. In `dontAsk` mode both cases are denied instead, because that mode never prompts. The MCP annotation requires Claude Code v2.1.199 or later.[claude.ai connector](</docs/en/mcp#organization-controls-on-connector-tools>) tools your organization has set to `ask` also leave the flow at this step. Every call falls through to the callback, even in `bypassPermissions` mode and even when an allow rule matches. The callback receives the reason `Your organization requires approval for this tool`. In `dontAsk` mode the call is denied instead, because that mode never prompts.In the TypeScript SDK, if you set a custom tool’s `permission_policy` to [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>), no allow rule approves its calls, not even an `allowedTools` entry. In `dontAsk` mode Claude Code denies those calls, and in `auto`, `plan`, or `bypassPermissions` mode it [can approve them](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>) before your callback runs.
4
@@ -32,16 +34,16 @@
Apply the active permission mode:
- * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except recognized [critical-path removals](</docs/en/permission-modes#critical-paths>), which fall through instead.
+ * In `bypassPermissions` mode, Claude Code approves everything that reaches this step except recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) and Bash commands flagged [`Dangerous rm operation not ruled out`](</docs/en/permission-modes#dangerous-rm-operation-not-ruled-out>), which fall through instead.
* In `acceptEdits` mode, Claude Code approves the file operations listed under Accept edits mode.
- * In `plan` mode, Claude Code sends file-edit and shell-write tools to your `canUseTool` callback regardless of allow rules, so write operations can’t be auto-approved while planning.
+ * In `plan` mode, Claude Code sends file-edit tools to your `canUseTool` callback regardless of allow rules.
* In other modes, the request falls through.
5
Allow rules
-Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) aren’t approved by an allow rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with them.An allow rule doesn’t approve a read from a [network path](</docs/en/permissions#network-paths>).
+Check `allow` rules (from `allowed_tools` and settings.json). If a rule matches, the tool is approved. A call the tool approves on its own is resolved at this step too, with no rule needed: for example a file read inside your working directories or a [read-only Bash command](</docs/en/permissions#read-only-commands>).Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) aren’t approved by an allow rule, and commands flagged `Dangerous rm operation not ruled out` aren’t approved by a `Bash` or `Bash(*)` rule. Whether they then reach your callback depends on the permission mode: in an Agent SDK session in `auto` mode, for example, Claude Code denies them by default without calling it. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with them.An allow rule doesn’t approve a read from a [network path](</docs/en/permissions#network-paths>).
6
@@ -51,10 +53,10 @@
If you pass a `canUseTool` callback in a configuration where the TypeScript SDK expects the evaluation order to auto-approve calls before the callback is consulted, the SDK emits a Node.js process warning once when the query is constructed. The warning’s code is `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED`. Two configurations trigger it:
- * `permissionMode: 'bypassPermissions'`, which auto-approves every call that reaches the permission mode step apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>)
- * Each bare `allowedTools` entry such as `"Read"`, which auto-approves that whole tool before the callback is consulted, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>)
-
-Entries with a specifier such as `Bash(ls *)` and the `acceptEdits` mode don’t trigger it, and allow rules coming from settings files aren’t visible to the check. Listen with `process.on('warning', ...)` and match the code to log or suppress it. To gate every tool call regardless of mode and rules, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>) instead. This page focuses on **allow and deny rules** and **permission modes**. For the other steps:
+ * `permissionMode: 'bypassPermissions'`: the warning text starts with `canUseTool will not be invoked: permissionMode 'bypassPermissions'`. Tool calls are approved before `canUseTool` is consulted, so your callback runs for only a few calls, such as the calls listed under Bypass permissions mode. To check the approved calls too, put your callback’s checks in a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>)
+ * An `allowedTools` entry that is only a tool name, such as `"Read"`: the warning lists each such entry after `canUseTool will not be invoked for:`. Calls to a listed tool are approved before `canUseTool` is consulted, apart from the calls an allow rule never approves. To have your callback run for a listed tool’s calls that need approval, remove that tool’s entry from `allowedTools`
+
+Entries with a specifier such as `Bash(ls *)` and the `acceptEdits` mode don’t trigger it, and allow rules coming from settings files aren’t visible to the check. The warning doesn’t block any call or change any option. If your callback already receives every call you want to check, leave your configuration as it is. To log the warning, listen with `process.on('warning', ...)` and match the `CLAUDE_SDK_CAN_USE_TOOL_SHADOWED` code. This page focuses on **allow and deny rules** and **permission modes**. For the other steps:
* **Hooks:** run custom code to allow, deny, or modify tool requests. See [Control execution with hooks](</docs/en/agent-sdk/hooks>).
* **canUseTool callback:** prompt users for approval at runtime, when no earlier step resolves the call. See [Handle approvals and user input](</docs/en/agent-sdk/user-input>).
@@ -76,7 +78,15 @@
Allow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured: `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored entry like `allowed_tools=["*"]` or `allowed_tools=["mcp__*"]` is ignored and doesn’t auto-approve anything. Scoped rules for `Read` and `Edit` take a path pattern. `Edit(path)` rules govern all built-in tools that write files, including `Write` and `NotebookEdit`; a `Write(path)` rule is never matched by the file permission checks. Use `//path` for an absolute filesystem path: a deny rule of `Edit(//secrets/**)` blocks writes anywhere under `/secrets` on disk. With a single leading slash, `Edit(/secrets/**)` anchors at the rule’s source instead. For rules passed through `allowed_tools` or `disallowed_tools`, that means the session’s working directory, so the rule doesn’t block `/secrets` on disk. See [Read and Edit rules](</docs/en/permissions#read-and-edit>) for the four anchor forms and how rules from settings files resolve.
-**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.No allow rule auto-approves `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), or recognized `rm` and `rmdir` [critical-path removals](</docs/en/permission-modes#critical-paths>). In `dontAsk` mode Claude Code denies these calls without invoking the callback. In other modes the first three reach the callback. The [Critical paths mode table](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>) lists what each mode does with a critical-path removal. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>).Coverage depends on the entry’s form: a bare name like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from those exceptions and [reads from network paths](</docs/en/permissions#network-paths>), while a scoped rule like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback. For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode.
+**Auto-approved tools never reach`canUseTool`.** A tool call approved at any earlier step, by `acceptEdits` or `bypassPermissions`, or by an allow rule, skips your `canUseTool` callback, so permission checks you put there are silently bypassed for that tool.If calls to a tool in `allowed_tools` still reach your `canUseTool` callback, or are denied in `dontAsk` mode, check whether they’re [reads from network paths](</docs/en/permissions#network-paths>) or among the following calls. No allow rule approves these calls. In `dontAsk` mode, which never prompts, Claude Code denies them without calling `canUseTool`, and in the other permission modes you handle them as each item says:
+
+ * `AskUserQuestion`, MCP tools marked [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>), and connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>): answer them in the callback. [Handle clarifying questions](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) shows how to answer `AskUserQuestion`, and a connector call arrives with the reason `Your organization requires approval for this tool`
+ * Custom tools your application marks [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>): decide the call in the callback. To stop these calls arriving, [change the policy mid-session](</docs/en/agent-sdk/typescript#mcpsdkserverconfigwithinstance>). In `auto`, `plan`, and `bypassPermissions` mode the call can instead be approved before the callback, in the cases listed under [Permission modes that can approve an `always_ask` call](</docs/en/agent-sdk/typescript#permission-modes-that-can-approve-an-always_ask-call>)
+ * Recognized `rm` and `rmdir` [critical-path removals](</docs/en/permission-modes#critical-paths>): in `default`, `acceptEdits`, and `bypassPermissions` mode, allow or deny the removal in the callback, where [`decisionReason`](</docs/en/agent-sdk/typescript#canusetool>) starts with `Dangerous rm`. For `auto` and `plan` mode, see [Critical-path removals in each permission mode](</docs/en/permission-modes#critical-path-removals-in-each-permission-mode>). The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>)
+ * **Bare name** : an entry like `Read` or `mcp__github__get_issue` auto-approves every call to that tool apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>).
+ * **Scoped rule** : an entry like `Bash(npm test *)` auto-approves only matching calls, and other `Bash` calls that need approval still fall through to the callback.
+
+For checks that must run on every tool call, use a [`PreToolUse` hook](</docs/en/agent-sdk/hooks>): hooks run before every other step, and a hook deny applies even in `bypassPermissions` mode.
For a locked-down agent, pair `allowedTools` with `permissionMode: "dontAsk"`:
@@ -85,7 +95,7 @@
permissionMode: "dontAsk"
};
-Listed tools are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). Every other call that would prompt is denied instead, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls that need no approval in `default` mode run whether or not you list them. They include [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To remove a tool from the request entirely, add its bare name to `disallowedTools`.
+The listed `Read`, `Glob`, and `Grep` calls are approved, apart from the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and [reads from network paths](</docs/en/permissions#network-paths>). Every other call that would prompt is denied instead, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls that need no approval in `default` mode run whether or not you list them. These include [read-only Bash commands](</docs/en/permissions#read-only-commands>), tools like `Agent` that don’t ask before running, and file reads inside your working directories. To hide a built-in tool from Claude entirely rather than deny its calls, add its bare name to `disallowedTools`.
**`allowed_tools` does not constrain `bypassPermissions`.** `allowed_tools` pre-approves the tools you list. Other unlisted tools are not matched by any allow rule and fall through to the permission mode, where `bypassPermissions` approves them. Setting `allowed_tools=["Read"]` alongside `permission_mode="bypassPermissions"` still approves every tool, including `Bash`, `Write`, and `Edit`. If you need `bypassPermissions` but want specific tools blocked, use `disallowed_tools`.
@@ -112,7 +122,7 @@
`default`| Standard permission behavior| No mode-based auto-approvals; calls that need approval and match no allow rule trigger your `canUseTool` callback
`dontAsk`| Deny instead of prompting| Any call that would otherwise prompt is denied without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Calls approved by `allowed_tools` or `settings.json` allow rules run, and so do calls that need no approval in `default` mode. Some calls, such as [reads from network paths](</docs/en/permissions#network-paths>), are denied even when `allowed_tools` or an allow rule matches them. For the list, see Don’t ask mode
`acceptEdits`| Auto-accept file edits| File edits and filesystem operations (`mkdir`, `rm`, `mv`, etc.) are automatically approved
-`bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Use with caution
+`bypassPermissions`| Bypass permission checks| Tools run without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) and, outside a [cloud session](</docs/en/claude-code-on-the-web>), custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>). Use with caution
`plan`| Planning mode| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback
`auto`| Model-classified approvals| A model classifier reviews actions such as shell commands and network requests, allowing or blocking each one it reviews. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and the decision order
@@ -240,6 +250,7 @@
* Works on a path outside that scope
* Writes to a protected path
* Removes a path that Claude Code recognizes as a [critical path](</docs/en/permission-modes#critical-paths>) with `rm` or `rmdir`
+ * Runs [`touch`](</docs/en/permission-modes#auto-approve-file-edits-with-acceptedits-mode>) with, for example, an option, a glob, or a `timeout 5` or `LANG=C` prefix
**Use when:** you trust Claude’s edits and want faster iteration, such as during prototyping or when working in an isolated directory.
@@ -249,7 +260,15 @@
Don’t ask mode (`dontAsk`)
-Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run, such as file reads inside your working directories and calls to `Agent`. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, [reads from network paths](</docs/en/permissions#network-paths>), and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) are denied even when an allow rule matches. A `PreToolUse` hook allow doesn’t clear a recognized critical-path removal or a read from a network path either. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent.
+Converts any permission prompt into a denial, without calling `canUseTool`, though a [mod](</docs/en/plugins/mods/overview>) you installed can still approve [some of those calls](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Tools pre-approved by `allowed_tools`, `settings.json` allow rules, or a hook run as normal. Calls that need no approval in `default` mode also run as normal, such as file reads inside your working directories and calls to `Agent`. These calls are denied even when an allow rule matches:
+
+ * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>)
+ * Tools that require user interaction, such as `AskUserQuestion` and MCP tools whose server sets [`_meta["anthropic/requiresUserInteraction"]`](</docs/en/mcp#require-approval-for-a-specific-tool>)
+ * Custom tools whose `permission_policy` your application sets to [`always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>)
+ * [Reads from network paths](</docs/en/permissions#network-paths>)
+ * Recognized [critical-path removals](</docs/en/permission-modes#critical-paths>)
+
+If your `PreToolUse` hook returns `allow` for a recognized critical-path removal, a read from a network path, or a call to a tool marked `always_ask`, the call is still denied. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). **Use when:** you want a fixed, explicit tool surface for a headless agent and prefer a hard deny over silent reliance on `canUseTool` being absent.
####
@@ -257,12 +276,12 @@
Bypass permissions mode (`bypassPermissions`)
-Auto-approves tool uses without prompting, except the cases listed in the warning below. Hooks still execute and can block operations if needed. On Linux and macOS, Claude Code refuses to start in this mode as root or under `sudo` outside a [recognized sandbox](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), and the query fails before the first turn.
+Auto-approves tool uses without prompting, except the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>). Hooks still execute and can block operations if needed. On Linux and macOS, Claude Code refuses to start in this mode as root or under `sudo` outside a [recognized sandbox](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), and the query fails before the first turn.
Use with extreme caution. Claude has full system access in this mode. Only use in controlled environments where you trust all possible operations.`allowed_tools` does not constrain this mode. Every tool is approved, not just the ones you listed. These controls still apply:
* Deny rules, explicit `ask` rules, and hooks are evaluated before the mode check and can still block a tool.
- * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>).
+ * Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), tools that require user interaction, and recognized [critical-path removals](</docs/en/permission-modes#critical-paths>) still fall through to your `canUseTool` callback. The check that recognizes these removals [can miss some commands](</docs/en/permission-modes#critical-paths>). Outside a [cloud session](</docs/en/claude-code-on-the-web>), calls to custom tools your application [marks `always_ask`](</docs/en/agent-sdk/custom-tools#require-approval-for-specific-tools>) fall through to the callback too.
* The [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still apply.
####
@@ -271,7 +290,11 @@
Plan mode (`plan`)
-Claude explores the codebase and produces a plan without editing your source files. Read-only tools run as they do in the `default` permission mode. File edits are never auto-approved in plan mode, even when an allow rule matches or a `PreToolUse` hook returns `allow`. They prompt through your `canUseTool` callback instead. On Claude Code v2.1.212 or later, shell commands that modify files, such as `touch` and `rm`, reach your `canUseTool` callback the same way. In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits and shell commands that modify files still reach your `canUseTool` callback. The option lets you switch to `bypassPermissions` later with `setPermissionMode()`. Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made.
+Claude explores the codebase and produces a plan without editing your source files. File edits are never auto-approved in plan mode, even when an allow rule matches or a `PreToolUse` hook returns `allow`. They prompt through your `canUseTool` callback instead. While auto mode is available to the session, commands Claude runs during planning don’t reach your callback by default, because the classifier model that [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses [reviews them instead](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). With that review on, the classifier can also approve read-only calls that would otherwise reach your callback, such as a `WebFetch` call with no allow rule.
+
+In the TypeScript SDK, if you set `allowDangerouslySkipPermissions: true` alongside `permissionMode: 'plan'`, file edits still reach your `canUseTool` callback. To switch a session that starts in plan mode to `bypassPermissions` later with `setPermissionMode()`, you need `allowDangerouslySkipPermissions` set from the start.
+
+Claude may use `AskUserQuestion` to clarify requirements before finalizing the plan. See [Handle approvals and user input](</docs/en/agent-sdk/user-input#handle-clarifying-questions>) for handling these prompts. **Use when:** you want Claude to propose changes without executing them, such as during code review or when you need to approve changes before they’re made.
####
--- a/plugins.md
+++ b/plugins.md
@@ -63,6 +63,22 @@
* **Absolute paths** : full file system paths (for example, `"/home/user/plugins/my-plugin"`)
The path should point to the plugin’s root directory: the parent of `skills/`, `agents/`, `hooks/`, `commands/`, or `.claude-plugin/`.
+
+###
+
+
+
+Add plugins to a running session
+
+In the TypeScript SDK, call [`reloadPlugins()`](</docs/en/agent-sdk/typescript#load-more-plugin-folders-with-addplugins>) on the `Query` object that `query()` returned, and list the plugin directory in that call’s `addPlugins` option. Each `addPlugins` entry is a `{ type: "local", path }` object with an absolute `path`. Requires TypeScript Agent SDK v0.3.301 or later. In this example, `q` is the `Query` object that `query()` returned. The example adds one plugin directory to the running session and, after `reloadPlugins()` returns, prints the path of every plugin in the session:
+
+ const result = await q.reloadPlugins({
+ addPlugins: [{ type: "local", path: "/home/user/plugins/another-plugin" }]
+ });
+
+ console.log(result.plugins.map((plugin) => plugin.path));
+
+If the plugin loaded, the printed list includes `/home/user/plugins/another-plugin`. If that path is missing from the list, or `reloadPlugins()` rejects, see [When `reloadPlugins()` doesn’t load the `addPlugins` folders](</docs/en/agent-sdk/typescript#when-reloadplugins-doesnt-load-the-addplugins-folders>) for the causes.
##
--- a/reference.md
+++ b/reference.md
@@ -339,7 +339,7 @@
[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓| ✓
[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓| ✓
`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓| ✓
-[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
+[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, [`rows`](</docs/en/plugins/mods/gallery#input>), `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓| ✓
`Svg`| a `source` of SVG markup up to 131,072 characters, `alt` text, `width`, `height`, and `isInteractive`| | ✓| ✓
[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`, `props`, `width`, `height`, `flexGrow`| ✓| ✓|
@@ -401,7 +401,7 @@
`'lg'`| 3| 1
`'xl'`| 4| 2
-If you set `gap`, `padding`, or `margin` to a step, the step applies across and down at once. For example, in the terminal and the VS Code extension, `padding: 'md'` is two cells at each side and one row above and below. Step names require Claude Code v2.1.299 or later. On an earlier release, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) in place of a tree that uses a step name.
+If you set `gap`, `padding`, or `margin` to a step, the step applies across and down at once. For example, in the terminal and the VS Code extension, `padding: 'md'` is two cells at each side and one row above and below. Step names require Claude Code v2.1.299 or later. On an earlier release, a tree that uses a step name doesn’t draw.
###
@@ -418,7 +418,7 @@
`mono`| `true` to ask for the app’s monospaced typeface| Ignored: the terminal is always monospaced| Ignored, so text keeps the extension’s own typeface
`tabular`| `true` to ask for digits of equal width, so that a number that updates in place or a column of numbers stays aligned| Ignored: the terminal’s digits are already one cell wide| Ignored
-These four props require Claude Code v2.1.299 or later. On an earlier release, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) in place of a tree that sets `size`, `weight`, `mono`, or `tabular`.
+These four props require Claude Code v2.1.299 or later. On an earlier release, a tree that sets `size`, `weight`, `mono`, or `tabular` doesn’t draw.
####
@@ -426,7 +426,7 @@
Replace `bold` with `weight`
-`bold` on a `Text` is deprecated in favor of `weight` and still works. To replace it on a `Text` with no `weight`, change `bold: true` to `weight: 'semibold'` for the same result on Claude Code v2.1.299 or later. On a release earlier than v2.1.299, a tree that sets `weight` doesn’t draw, and Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) instead. If you set both `bold` and `weight` on a `Text`, `bold` has no effect.
+`bold` on a `Text` is deprecated in favor of `weight` and still works. To replace it on a `Text` with no `weight`, change `bold: true` to `weight: 'semibold'` for the same result on Claude Code v2.1.299 or later. On a release earlier than v2.1.299, a tree that sets `weight` doesn’t draw. If you set both `bold` and `weight` on a `Text`, `bold` has no effect.
##
@@ -434,7 +434,7 @@
Limits
-Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit.
+Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit. A tree over the nesting, element, `Raster` cell, or `Image` byte limit [isn’t drawn](</docs/en/plugins/mods/troubleshoot#a-pane-or-band-is-empty>).
Limit| Value
---|---
@@ -450,8 +450,12 @@
Redirects one `$.http.fetch` call follows| 5
A hook’s `drop` reason or `config.set` `deny` reason| 4,096 characters. The end of a longer reason is cut, and the drop or deny still applies. The cut requires Claude Code v2.1.292 or later, and on earlier versions the hook [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>) instead.
Text in one tree| The first 100,000 characters are drawn
-A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>).
-A `Link`’s `href`| 2,048 characters. A longer `href` keeps the whole tree from drawing.
+A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
+A `Link`’s `href`| 2,048 characters. If it’s longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
+Nesting depth of one tree| 32 levels below the root element
+Elements and text children in one tree| 20,000
+`Raster` cells in one tree, each `Raster`’s `columns` times its `rows`| 262,144
+PNG or RGBA bytes of all the `Image`s in one tree| 2 MiB
`$.store`| 4 MiB of JSON in total
`$.session.messages()`| The newest 4,096 entries
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
--- a/relevance.md
+++ b/relevance.md
@@ -1,9 +1,9 @@
-Claude Code can suggest installing a plugin from your organization’s marketplace when a user’s session matches signals you define for that plugin. Signals include the working directory, files Claude has read, and commands Claude has run. You define them by adding a `relevance` block to the plugin’s entry in `marketplace.json`. A marketplace operator writes the `relevance` entries. An administrator then allowlists the marketplace in managed settings. Users see no suggestions from a marketplace until it’s allowlisted.
+Claude Code can suggest installing a plugin from your organization’s marketplace when a user’s session matches signals you define for that plugin. Signals include the working directory, files Claude has read, and commands Claude has run. You define them by adding a `relevance` block to the plugin’s entry in `marketplace.json`. A marketplace operator writes the `relevance` entries. An administrator then allowlists the marketplace in managed settings. In the terminal, users see no suggestions from a marketplace until it’s allowlisted.
These cases are covered on other pages:
* **You want to install plugins** : see [Install and manage plugins](</docs/en/plugins/install>)
- * **You want to turn suggestions off** : see Understand how plugin relevance works
+ * **You want to turn suggestions off** : see Understand how plugin relevance works, or for the suggestions Claude makes in a cloud session’s conversation, [Turn off plugin suggestions](</docs/en/claude-code-on-the-web#turn-off-plugin-suggestions>)
Start with the sections for your role:
@@ -166,7 +166,7 @@
Enable suggestions in managed settings
-Users see no suggestions from a marketplace until an administrator allowlists it in [managed settings](</docs/en/plugins/org>), even when its `marketplace.json` declares `relevance`. To allowlist a marketplace, edit your managed settings as follows:
+In the terminal, users see no suggestions from a marketplace until an administrator allowlists it in [managed settings](</docs/en/plugins/org>), even when its `marketplace.json` declares `relevance`. To allowlist a marketplace, edit your managed settings as follows:
* Add the marketplace name to `pluginSuggestionMarketplaces`.
* For any marketplace other than the official Anthropic marketplace, also declare the marketplace source, either as that name’s entry in [`extraKnownMarketplaces`](</docs/en/plugins/org#require-a-marketplace-and-its-plugins>) or as an entry in [`strictKnownMarketplaces`](</docs/en/plugins/org#allowlist-with-strictknownmarketplaces>).
--- a/self-hosted-environments-configuration.md
+++ b/self-hosted-environments-configuration.md
@@ -381,7 +381,7 @@
Flag, with an example value| Pass it to| What it does
---|---|---
-`--release-idle-session-min 30`| Every runner your hook starts| The runner releases its session after that many idle minutes and then exits 0. The session resumes when its user sends their next message, but [work it hadn’t pushed is gone](</docs/en/self-hosted-environments-deploy#additional-limitations>).
+`--release-idle-session-min 30`| Every runner your hook starts| The runner releases its session after that many idle minutes and then exits 0. The session resumes when its user sends their next message, but [work it hadn’t pushed is gone](</docs/en/self-hosted-environments-deploy#additional-limitations>). [Hold a session](</docs/en/self-hosted-environments-deploy#keep-an-idle-session-while-its-processes-run>) for processes it left running.
`--kill-session-after-min 480`| Every runner your hook starts| Limits each session to that many minutes, as a backstop for [sessions that don’t count as idle](</docs/en/self-hosted-environments-deploy#some-sessions-don%E2%80%99t-count-as-idle>), so set it above your longest expected session
`--exit-if-unused-min 60`| Standby runners, which your hook starts for pre-warming requests| A standby that never takes a session exits after that many minutes. If you set [`--min-idle`](</docs/en/self-hosted-environments-reference#orchestrator-cli-flags>), you get a replacement unless the standby was surplus, so use a value well above your boot time.
--- a/self-hosted-environments-deploy.md
+++ b/self-hosted-environments-deploy.md
@@ -56,6 +56,7 @@
`code.claude.com` and `claude.com`| 443| Documentation lookups by the built-in claude-code-guide agent and pre-approved WebFetch requests during sessions. Blocking these hosts only affects documentation lookups.
`*.frame.claudeusercontent.com`| 443| Only when the [Artifact tool](</docs/en/artifacts#availability>) is available for sessions in your organization; defaults vary by plan, per the availability table there. Set `CLAUDE_CODE_DISABLE_ARTIFACT=1` on the runner to keep the tool disabled regardless of the organization setting.
`registry.npmjs.org`| 443| When a session installs a plugin, both for fetching npm-source plugin packages and for installing a plugin’s Node.js dependencies, or when an `npx`-launched MCP server runs
+An internal mirror of the package registries your builds use, or the registries themselves| 443, or your mirror’s port| When sessions install dependencies to build or test your repositories
`http-intake.logs.us5.datadoghq.com`| 443| Anthropic operational metrics. Only when `CLAUDE_CODE_BYOC_ENABLE_DATADOG=1` is set; off by default in self-hosted environments.
`browser-intake-us5-datadoghq.com`| 443| Anthropic error-report uploads, sent only when [error reporting](</docs/en/data-usage#telemetry-services>) is enabled for the session’s account. Suppressed by `DISABLE_ERROR_REPORTING=1` or `DISABLE_TELEMETRY=1`.
Your cloud provider’s endpoints for model requests, model lookups, and renewing credentials, such as `bedrock-runtime.us-east-1.amazonaws.com` or `aiplatform.googleapis.com`| 443| Only when the runner [sends model requests to Amazon Bedrock or Google Cloud’s Agent Platform](</docs/en/self-hosted-environments-configuration#send-model-requests-to-bedrock-or-agent-platform>)
@@ -681,7 +682,7 @@
In the first two stages that follow the signal, the runner releases sessions, and a released session resumes on a fresh runner when its user sends their next message. Counting from the first signal, the runner moves through three stages:
- * **For the first`n` minutes**: the runner serves its sessions normally and keeps enforcing `--startup-timeout-min` and `--kill-session-after-min`. If you also set [`--release-idle-session-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>), the runner releases any session whose user has been idle that long; without it, idle sessions stay on the runner.
+ * **For the first`n` minutes**: the runner serves its sessions normally and keeps enforcing `--startup-timeout-min` and `--kill-session-after-min`. If you also set [`--release-idle-session-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>), the runner releases any session whose user has been idle that long, unless you hold that session. Without the flag, idle sessions stay on the runner.
* **When the`n` minutes run out**: the runner releases every session it still holds, idle or not. The runner waits for a mid-turn session’s turn to end, and up to 60 seconds more for a turn’s background tasks, before releasing that session.
* **When the post-release grace runs out** : the runner drains whatever sessions it still holds, and the control plane requeues each drained session to another runner right away. The post-release grace starts when the `n` minutes run out and is 75 seconds at defaults. If you set `--drain-wait-sec` above 60 seconds, the post-release grace is `--drain-wait-sec` plus 15 seconds instead.
@@ -784,18 +785,65 @@
Release idle sessions on a fixed fleet
-If sessions stay queued on a fixed fleet while every runner is online, idle sessions may be the cause. By default, a session keeps its slot after its turn finishes, and its runner stays locked to that session’s [owner](</docs/en/self-hosted-environments#key-concepts>). If your team’s [cloud scheduled task](</docs/en/routines>) starts a new session at each run, its idle sessions can fill every slot. To check, read `claude_code_self_hosted_runner_session_idle_seconds` in each runner’s [Prometheus metrics](</docs/en/self-hosted-environments-reference#prometheus-metrics>). Each session a runner holds has its own series: `0` while the session is busy, otherwise the seconds since it went idle. Choose the idle time you’d allow: longer than the pauses people take mid-task, and short enough that each run is released before the scheduled task’s next one starts. Compare the series with it.
+If sessions stay queued on a fixed fleet while every runner is online, idle sessions may be the cause. By default, a session keeps its slot after its turn finishes, and its runner stays locked to that session’s [owner](</docs/en/self-hosted-environments#key-concepts>). Other owners’ sessions can’t use that runner’s free slots. If your team’s [cloud scheduled task](</docs/en/routines>) starts a new session at each run, its idle sessions can fill every slot. To check, read `claude_code_self_hosted_runner_session_idle_seconds` in each runner’s [Prometheus metrics](</docs/en/self-hosted-environments-reference#prometheus-metrics>). Each session a runner holds has its own series: `0` while the session is busy, otherwise the seconds since it went idle. Choose the idle time you’d allow: longer than the pauses people take mid-task, and short enough that each run is released before the scheduled task’s next one starts. Compare the series with it.
* **Series above that time, such as`1800` for 30 minutes**: idle sessions hold those slots, so set `--release-idle-session-min`
* **Every series below it** : no session has been idle that long. Add runners, or set [`--kill-session-after-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) for sessions that never go idle.
* **A runner with no series** : no session holds it. See **Sessions stay queued** under Troubleshooting.
* **A runner whose metrics don’t answer** : its process may have exited. See **An environment that looks healthy** under When the runner exits.
-To release idle sessions, start every runner with [`--release-idle-session-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) and that time in minutes, such as `--release-idle-session-min 30`. The runner then releases any session that stays idle that long, whether a scheduled task or a person started it.
+To release idle sessions, start every runner with [`--release-idle-session-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) and that time in minutes, such as `--release-idle-session-min 30`. The runner then releases any session that stays idle that long, whether a scheduled task or a person started it, unless you hold it for processes it left running.
* **Unpushed work** : a released session resumes at its next message, without the work it hadn’t pushed. To keep its commits, see Resumed sessions lose unpushed work.
* **Runner exits** : a runner that releases its last session starts a normal exit. Have your supervisor restart it on a fresh filesystem, as Harden your deployment describes.
* **Sessions that never go idle** : also set [`--kill-session-after-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>), because some sessions don’t count as idle
+
+###
+
+
+
+Keep an idle session while its processes run
+
+To keep an idle session until processes it left on your host finish, such as `nohup` jobs, start the runner with [`--hold-idle-file`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) and keep touching that file from the host. Requires Claude Code v2.1.311 or later. These steps assume a non-root runner on a host. If your runner runs as `root`, its sessions can touch the file themselves, so run it as a dedicated user first.
+
+1
+
+Pick a path for the file
+
+Choose a local regular file, such as `/var/lib/claude-hold/hold-idle`, in a directory sessions can’t write to, parent directories included, so a session can’t write to it. The runner and its sessions share one OS user, so create that directory first, owned by another user such as `root`, with mode `755`.
+
+2
+
+Start the runner
+
+From your shell, start the runner with `--hold-idle-file`, `--release-idle-session-min`, and [`--max-hold-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>), the cap on a hold, counted from when a session goes idle. Without it, the cap is one day. Set it above `--release-idle-session-min`, or nothing is held. This example releases idle sessions after 30 minutes and releases a held session at most 4 hours after it went idle:
+
+ claude self-hosted-runner \
+ --environment-secret-file /etc/claude/environment-secret \
+ --release-idle-session-min 30 \
+ --hold-idle-file /var/lib/claude-hold/hold-idle \
+ --max-hold-min 240
+
+3
+
+Touch the file while the processes run
+
+While the processes run, `touch` the file from the host as the directory’s owner, more often than every three minutes. The first `touch` creates the file. For example, add this line to `root`’s crontab:
+
+ * * * * * pgrep -x nightly-build > /dev/null && touch /var/lib/claude-hold/hold-idle
+
+The line runs once a minute and touches the file while any process named `nightly-build` runs, so a session that starts one stays held up to the cap. Replace the `pgrep` check with however your host finds what sessions left running.The check must stop matching when they finish, or every idle session on that runner stays held until the cap.
+
+4
+
+Confirm the hold
+
+While the processes run, check that the file’s modification time stays under three minutes old. When a session’s idle time runs out, look for `idle release held` in the runner’s log. If no such line appears, read `leftover-hold=` in the `watchdog config` line the runner logs at startup, which shows the file and cap, or why nothing is held.Three minutes after the last `touch`, the hold ends. Within about a minute more, the log shows `idle release no longer held` and the runner releases the session.
+
+Even while the file keeps changing, a hold can end, in cases such as these:
+
+ * **Past the cap** : `--max-hold-min` runs out. To hold longer, raise it
+ * **Forced releases** : you set [`--retire-at`](</docs/en/self-hosted-environments-reference#runner-cli-flags>), [`--defer-shutdown-max-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>), or [`--kill-session-after-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>), and that limit arrives. To hold longer, set a later limit
##
@@ -892,7 +940,8 @@
* **The branch exists and the runner is older than v2.1.301** : upgrade the runner as described in Pin the version, so that a different failure shows its own error. Before v2.1.301, other failures with `couldn't find remote ref` in their error output were also reported as a deleted branch.
Once the runner is upgraded or the cause is fixed, retry the session or start a new one. If none of these checks finds the cause, report an issue. For the source the session pushes results to, a deleted branch fails the session. For a git source the session only reads from, the runner skips that source and continues on the remaining ones. The runner fails the session when skipping would leave it with no repository at all. Before v2.1.228, such a session started in an empty directory.
* **Claude Tag sometimes doesn’t post its reply in Slack** : the reply reminder is a [hook the control plane supplies](</docs/en/self-hosted-environments-configuration#how-each-session%E2%80%99s-config-is-assembled>). Confirm the runner is Claude Code v2.1.229 or later with `claude --version`, since older runners ignore supplied hooks; confirm `python3 --version` succeeds inside the runner image, since the hooks run `python3`; and confirm no settings file turns hooks off, whether `disableAllHooks` in `managed-settings.json`, the runner user’s `~/.claude/settings.json`, or the repository’s `.claude/settings.json` or `.claude/settings.local.json`, or `allowManagedHooksOnly` or a [`strictPluginOnlyCustomization`](</docs/en/settings-reference#strictpluginonlycustomization>) that covers hooks in managed settings.
- * **A session starts without one of its repositories** : on a runner with no [`checkout` hook](</docs/en/self-hosted-environments-configuration#checkout>), the git host can refuse the runner’s access check for a repository the session only reads from. The runner then skips that repository, logs a `[runner:warn] could not access context source` line naming the refusal, and starts the session on the remaining ones. The runner skips only a clear refusal: the host answers that the repository wasn’t found, git finds no credentials for the host, or authentication fails. A network failure, a timeout, or an HTTP `403` still fails the session start, as does a refusal for a repository the session pushes results to. The runner still fails a session that skipping would leave with no repository at all. With `--use-anthropic-git-proxy`, the runner skips only a repository the git proxy itself denies. The access check runs again each time the session starts on a runner, so once the runner’s git identity has read access, the next start clones the repository. Before v2.1.274, each of these refusals failed the session start.
+ * **A session starts without one of its repositories** : on a runner with no [`checkout` hook](</docs/en/self-hosted-environments-configuration#checkout>), the git host can refuse the runner’s access check for a repository the session only reads from. The runner then skips that repository, logs a `[runner:warn] could not access context source` line naming the refusal, and starts the session on the remaining ones. With its own git credentials, the runner can skip a repository when the host answers that the repository wasn’t found, git finds no credentials for the host, or authentication fails. With `--use-anthropic-git-proxy`, when the git proxy refuses a repository with `access denied by the git proxy`, the runner skips it. The log line then says `blocked by the git proxy`. For the causes to check, see the `remote: access denied by the git proxy` case in When sessions fail to start on a runner with the git proxy. A network failure, a timeout, or any other HTTP `403` still fails the session start, as does a refusal for a repository the session pushes results to. The runner still fails a session that skipping would leave with no repository at all. The access check runs again each time the session starts on a runner, so once the runner’s git identity has read access, the next start clones the repository. Before v2.1.274, each of these refusals failed the session start.
+ * **The log shows`could not read context source`**: this line, unlike `could not access context source`, means the git host kept answering HTTP `429`, or a wrapper you installed as `git` kept exiting `75`. The runner skipped that repository. To retry, start a new session. The runner also tries the repository again each time this session starts on a runner. With no `checkout` hook, the runner can skip a repository the session only reads from, unless it’s first among the session’s repositories. Before v2.1.311, the session start failed.
* **A session fails to start with`This runner couldn't read`**: the runner asked the git host for a repository with its git credentials and got a not-found answer. The repository doesn’t exist, or those credentials can’t reach the repository.
* **If you administer the runner** : give its git credentials read access to the repository, then start a new session.
* **If you started the session** : if the repository doesn’t exist, start a new session with the right repository. If the runner can’t reach the repository, ask the runner’s administrator to grant access, then start a new session.
--- a/self-hosted-environments-reference.md
+++ b/self-hosted-environments-reference.md
@@ -29,17 +29,19 @@
`--git-host-rewrite <from>=<to>`| none| unset| Rewrite `https://<from>/...` source URLs to `https://<to>/...` before cloning, for split-horizon DNS. Repeatable; flag only.
`--git-ssh-rewrite <host>`| none| unset| Rewrite `https://<host>/...` source URLs to `git@<host>:...` before cloning, for SSH-only git hosts. Repeatable; flag only.
`--health-port <port>`| `SELF_HOSTED_RUNNER_HEALTH_PORT`| `8080`| Port for the `/healthz` and `/metrics` listener. Set `0` to disable.
+`--hold-idle-file <path>`| `SELF_HOSTED_RUNNER_HOLD_IDLE_FILE`| unset| File your host keeps changing to hold an idle session on the runner. See [Keep an idle session while its processes run](</docs/en/self-hosted-environments-deploy#keep-an-idle-session-while-its-processes-run>). Requires Claude Code v2.1.311 or later.
`--hooks-dir <path>`| `SELF_HOSTED_RUNNER_HOOKS_DIR`| unset| Directory of lifecycle hook scripts. See [Lifecycle hooks](</docs/en/self-hosted-environments-configuration#lifecycle-hooks>).
`--host-config-snapshot <mode>`| `SELF_HOSTED_RUNNER_HOST_CONFIG_SNAPSHOT`| `disk`| Where the runner keeps the startup snapshot of the host config directory that it seeds each session from. `disk` copies the snapshot into a runner-owned directory under `--base-dir` and, at each session start, verifies every file against an in-memory digest. If a file in the copy has been modified, the session fails and the runner refuses sessions until you restart it. `memory` holds the whole snapshot on the heap, capped at 64 MiB; over the cap, sessions start without host config and show a notice saying so. When the runner can’t write the disk snapshot, it logs the failure and uses `memory` for that run. Requires Claude Code v2.1.271 or later.
`--kill-session-after-min <n>`| `SELF_HOSTED_RUNNER_MAX_LIFETIME_MS`| `0`| Limit a session to N minutes wall-clock, as a safety limit for stuck sessions. On v2.1.260 or later, the runner releases a session that reaches the limit so it can resume on its user’s next message, and terminates it only if it’s still on the runner when the `SELF_HOSTED_RUNNER_MAX_LIFETIME_GRACE_MS` grace window ends. Before v2.1.260, the runner terminated the session at the limit. See [Some sessions don’t count as idle](</docs/en/self-hosted-environments-deploy#some-sessions-don%E2%80%99t-count-as-idle>) for the details and how to choose a value. `0` disables.
`--lock-to-account <id>`| `SELF_HOSTED_RUNNER_LOCK_TO_ACCOUNT`| unset| Pre-lock the runner to a specific account at startup instead of locking on first session. Accepts an email address or `user_...` ID in the environment’s organization. A pre-locked runner never picks up Claude Tag channel sessions, which have no account.
`--log-file <path>`| `SELF_HOSTED_RUNNER_LOG_FILE`| unset| Mirror runner logs to a file in addition to stdout and stderr, created with `0600` permissions. Required for `self-hosted-runner doctor` to tail logs locally.
`--log-level <level>`| none| `info`| `info` or `debug`
+`--max-hold-min <n>`| `SELF_HOSTED_RUNNER_MAX_HOLD_MS`| `1440`| With `--hold-idle-file`, release a held session anyway N minutes after it went idle. A value at or below `--release-idle-session-min` holds nothing. `0` turns the hold off. Requires Claude Code v2.1.311 or later.
`--post-session-hook-timeout-sec <n>`| `SELF_HOSTED_RUNNER_POST_SESSION_HOOK_TIMEOUT_MS`| `60`| Budget for the [`post-session` hook](</docs/en/self-hosted-environments-configuration#post-session>) on every session end, including runner shutdown
`--proxy-authorization-command <command>`| `SELF_HOSTED_RUNNER_PROXY_AUTHORIZATION_COMMAND`| unset| Shell command the runner runs for every connection to your egress proxy, using its trimmed stdout as the `Proxy-Authorization` header value. Requires `HTTPS_PROXY` or `HTTP_PROXY`, and can’t be combined with `--proxy-authorization-file`. See [Authenticate to an egress proxy](</docs/en/self-hosted-environments-deploy#authenticate-to-an-egress-proxy>). Requires Claude Code v2.1.238 or later.
`--proxy-authorization-file <path>`| `SELF_HOSTED_RUNNER_PROXY_AUTHORIZATION_FILE`| unset| File the runner reads for every connection to your egress proxy, using its trimmed contents as the `Proxy-Authorization` header value. Use this flag for a token another process rotates in place. Carries the same requirements as `--proxy-authorization-command`, and can’t be combined with it. See [Authenticate to an egress proxy](</docs/en/self-hosted-environments-deploy#authenticate-to-an-egress-proxy>). Requires Claude Code v2.1.238 or later.
`--push-outcome-on-release`| `SELF_HOSTED_RUNNER_PUSH_OUTCOME_ON_RELEASE`| off| On a runner-initiated session end such as a drain or idle release, push tracked outcome branches to `origin` before deleting the workspace, so in-flight commits survive a restart. Best-effort; adds 30 seconds to the shutdown budget, and requires git 2.29 or newer to resume from the pushed branch. Restrict push access to `claude/*` refs before enabling; see [Resumed sessions lose unpushed work](</docs/en/self-hosted-environments-deploy#additional-limitations>). Repositories checked out via a `checkout` lifecycle hook aren’t pushed; snapshot those from the [`post-session` hook](</docs/en/self-hosted-environments-configuration#post-session>) instead.
-`--release-idle-session-min <n>`| `SELF_HOSTED_RUNNER_SESSION_IDLE_MS`| `0`| Release a session slot after N minutes of inactivity once a turn finishes or the session waits for the user’s action. A session that’s still mid-turn, including one holding a never-finishing background task or an approval requested from inside a running tool call, doesn’t count as idle; pair with `--kill-session-after-min` as the hard backstop. After a session’s background task finishes, the runner considers the session busy until the follow-up turn that reads the result starts, for at most the `SELF_HOSTED_RUNNER_BG_RESULT_GRACE_MS` window. Until the runner receives a shutdown signal or reaches its retire time, a release that leaves the runner with no active sessions starts the same exit path as a normal drain, governed by `--drain-grace-sec`. After a first signal you deferred with [`--defer-shutdown-max-min`](</docs/en/self-hosted-environments-deploy#defer-the-drain-past-the-first-signal>), the runner exits as soon as a release leaves it holding no sessions. `0` disables.
+`--release-idle-session-min <n>`| `SELF_HOSTED_RUNNER_SESSION_IDLE_MS`| `0`| Release a session slot after N minutes of inactivity once a turn finishes or the session waits for the user’s action. [Some sessions don’t count as idle](</docs/en/self-hosted-environments-deploy#some-sessions-don%E2%80%99t-count-as-idle>), so pair with `--kill-session-after-min`. A finished background task keeps the session busy for at most the `SELF_HOSTED_RUNNER_BG_RESULT_GRACE_MS` window. To delay a release, set [`--hold-idle-file`](</docs/en/self-hosted-environments-deploy#keep-an-idle-session-while-its-processes-run>). `0` disables.
`--remove-session-state [bool]`| `SELF_HOSTED_RUNNER_REMOVE_SESSION_STATE`| off| Remove a session’s per-session directories under `<base-dir>/_sessions/` when the session ends on this runner, whatever the outcome. [Reuse a pre-warmed checkout](</docs/en/self-hosted-environments-deploy#reuse-a-pre-warmed-checkout>) describes what they hold and who can read them when they stay. The removal is best-effort: the per-session directories stay in place when the runner is killed or reaches its drain deadline before cleanup runs. With the flag on, a failed or interrupted session’s debug log isn’t kept on disk. Requires Claude Code v2.1.268 or later.
`--retire-at <epoch-seconds>`| `SELF_HOSTED_RUNNER_RETIRE_AT`| unset| Retire the runner at an absolute Unix timestamp in seconds, for infrastructure that kills the runner at a known time; [Runner lifecycle](</docs/en/self-hosted-environments#runner-lifecycle>) describes the release sequence and how to size the margin. Values before 2001 or after the year 5138 are rejected by the flag and ignored by the environment variable.
`--server-auto-mode-lists <mode>`| `SELF_HOSTED_RUNNER_SERVER_AUTO_MODE_LISTS`| `no-allow`| Which of the [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) classifier rule lists that the control plane sends with a session may reach that session: `all`, `no-allow`, or `none`. See Auto mode rule lists for what each value applies. An invalid value stops the runner at startup. Requires Claude Code v2.1.295 or later.
@@ -326,7 +328,10 @@
Alert on lost runners and waiting sessions
-On a [fixed fleet](</docs/en/self-hosted-environments-deploy#scale-the-fleet>), load `ClaudeRunnersBelowFloor`. With [on-demand runners](</docs/en/self-hosted-environments-configuration#on-demand-runners>), load `ClaudeOrchestratorSessionsWaiting` and `ClaudeOrchestratorQueueWaitHigh` instead.
+To be alerted when runners are lost, sessions wait, or the orchestrator is down, load these Prometheus alert rules beside the sample alert rules:
+
+ * **[Fixed fleet](</docs/en/self-hosted-environments-deploy#scale-the-fleet>)** : `ClaudeRunnersBelowFloor`
+ * **[On-demand runners](</docs/en/self-hosted-environments-configuration#on-demand-runners>)** : `ClaudeOrchestratorSessionsWaiting`, `ClaudeOrchestratorQueueWaitHigh`, and `ClaudeOrchestratorAbsent`
####
@@ -388,6 +393,29 @@
* **Threshold** : if some session is always waiting, raise the `> 0` in `ClaudeOrchestratorSessionsWaiting` above the number you usually see
* **`ClaudeOrchestratorDisconnected`** : keep it loaded from the sample alert rules, because `ClaudeOrchestratorSessionsWaiting` stops firing about 2 minutes after the last orchestrator in the namespace disconnects
+####
+
+
+
+Alert when the orchestrator is down
+
+To learn that the [orchestrator](</docs/en/self-hosted-environments-configuration#on-demand-runners>) itself is down, load `ClaudeOrchestratorAbsent`. It fires when no orchestrator in the namespace has been scraped for 5 minutes:
+
+ groups:
+ # On-demand runners only. Replace claude-runners with the orchestrator's namespace.
+ - name: claude-code-self-hosted-on-demand-orchestrator
+ rules:
+ - alert: ClaudeOrchestratorAbsent
+ expr: absent(claude_code_self_hosted_orchestrator_connected{namespace="claude-runners"})
+ for: 5m
+ labels: {severity: critical}
+ annotations:
+ summary: "No orchestrator has been scraped for 5 minutes. If it's down, no on-demand runner starts, and sessions wait. Check the orchestrator workload first, then its scrape target if it's running."
+
+ * **Namespace** : replace `claude-runners` with the orchestrator’s namespace, and copy the alert for each further namespace that runs an orchestrator. If your targets have no `namespace` label, remove the matcher, or the alert fires after 5 minutes and stays on.
+ * **Prometheus servers that don’t scrape the orchestrator** : leave the alert out of their rule files, because on such a server it fires after 5 minutes and stays on
+ * **Don’t rely on the orchestrator’s other alerts** : they read metrics that the orchestrator itself serves. `ClaudeOrchestratorSessionsWaiting`, `ClaudeOrchestratorQueueWaitHigh`, and the orchestrator’s sample alert rules all stop firing within about 10 minutes of the orchestrator going down.
+
###
--- a/server-managed-settings.md
+++ b/server-managed-settings.md
@@ -174,9 +174,11 @@
**Subsequent launches with cached settings:**
- * Cached settings apply immediately at startup, except for the cached `modelPricing` and `managedMcpServers` values and the environment variables that Claude Code withholds until the server confirms the payload
+ * Cached settings apply immediately at startup, except for the cached `modelPricing` and `managedMcpServers` values; the environment variables that Claude Code withholds until the server confirms the payload; the removal, repositioning, or disabling of the [built-in guard](</docs/en/plugins/mods/admin#know-what-happens-by-default>) by a cached plugin list; and, on a machine where an endpoint-managed source lists or enables plugins of its own, the [organization standing](</docs/en/plugins/mods/admin#install-your-organizations-mods>) of a plugin that only a cached list enables
* A cached [`modelPricing`](</docs/en/settings-reference#modelpricing>) doesn’t apply until the session’s fetch confirms the payload. Until then, the cost figures developers see in `/usage` and the status line are at list price
* A cached [`managedMcpServers`](</docs/en/settings-reference#managedmcpservers>) block doesn’t apply until the session’s fetch confirms the payload. Claude Code waits up to 30 seconds for that fetch before connecting MCP servers. If the fetch fails or times out, the session starts without the organization’s servers, `/status` says so, and they connect once a later fetch confirms them. See [When provided servers connect](</docs/en/managed-mcp#when-provided-servers-connect>) for the full behavior, including first launch. Requires Claude Code v2.1.259 or later
+ * A cached [`prependPlugins`](</docs/en/settings-reference#prependplugins>), [`appendPlugins`](</docs/en/settings-reference#appendplugins>), or [`enabledPlugins`](</docs/en/settings-reference#enabledplugins>) value can’t remove the built-in guard, change its position, or turn it off until the session’s fetch confirms the payload
+ * On a machine where an [endpoint-managed source](</docs/en/managed-settings#choose-a-delivery-mechanism>) lists or enables plugins of its own, a plugin that only a cached list enables counts as [the user’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), not your organization’s, until the fetch confirms the payload
* Claude Code fetches fresh settings in the background
* Cached settings persist through network failures. If the startup fetch fails, Claude Code warns in interactive sessions that the cached policy is in effect
* Until a fetch succeeds, the values withheld at startup stay withheld
--- a/settings-reference.md
+++ b/settings-reference.md
@@ -2263,14 +2263,14 @@
* **Type** : array of strings, each a service name; a single trailing `*` matches a prefix, and `"*"` alone matches every service
* **Default** : unset
-This allows every service under the `com.apple.coresimulator.` prefix:
+This allows every service under the `com.apple.CoreSimulator.` prefix:
settings.json
{
"sandbox": {
"network": {
- "allowMachLookup": ["com.apple.coresimulator.*"]
+ "allowMachLookup": ["com.apple.CoreSimulator.*"]
}
}
}
@@ -5407,13 +5407,13 @@
* **Type** : array of strings, directory paths relative to the repository root
* **Default** : unset, so each worktree checks out the whole tree
-This example checks out only `packages/my-app` and `shared/utils`, plus root-level files, in each worktree:
+Include `.claude` in the list so that each worktree also has the repository’s `.claude/settings.json` and `.claude/rules/`. This example checks out only `.claude`, `packages/my-app`, and `shared/utils`, plus root-level files, in each worktree:
settings.json
{
"worktree": {
- "sparsePaths": ["packages/my-app", "shared/utils"]
+ "sparsePaths": [".claude", "packages/my-app", "shared/utils"]
}
}
@@ -6357,7 +6357,12 @@
"disableSideloadFlags": true
}
-Claude Code still accepts a `--mcp-config` whose servers are all in-process `type: "sdk"` entries, so the Agent SDK and VS Code extension keep working. Users can still add servers with `claude mcp add` or a `.mcp.json` file; for per-server control, set [`allowedMcpServers`](</docs/en/managed-mcp>) as well. Requires Claude Code v2.1.193 or later. The same check covers plugin folders named in the [`CLAUDE_CODE_PLUGIN_DIRS`](</docs/en/env-vars#variables>) environment variable, which requires Claude Code v2.1.280 or later. When the variable names a folder, Claude Code exits with the same error, and the error says to unset the variable. In cloud sessions, Claude Code also ignores server-delivered mid-session MCP updates, the path behind cloud session configuration and SDK `setMcpServers()` calls that reach those sessions. In-process `type: "sdk"` entries and a Claude Tag session’s Slack tools stay exempt there too. Before v2.1.268, both this drop and the startup drop also removed a Claude Tag session’s Slack tools. Before v2.1.239, a server-delivered `--mcp-config` blocked a cloud session from starting. The desktop app manages some plugins itself, including plugins synced from claude.ai and plugins your organization deploys through the app. If you deploy this key to a device through MDM, OS-level policy, or a managed settings file, the desktop app doesn’t pass those plugins to the following sessions on that device:
+Claude Code still accepts a `--mcp-config` whose servers are all in-process `type: "sdk"` entries, so the Agent SDK and VS Code extension keep working. Users can still add servers with `claude mcp add` or a `.mcp.json` file; for per-server control, set [`allowedMcpServers`](</docs/en/managed-mcp>) as well. Requires Claude Code v2.1.193 or later. `disableSideloadFlags` also rejects plugin folders from these sources:
+
+ * **The[`CLAUDE_CODE_PLUGIN_DIRS`](</docs/en/env-vars#variables>) environment variable**: when the variable names a plugin folder, Claude Code exits at startup with an error that names the variable and says to unset it. Requires Claude Code v2.1.280 or later
+ * **The Agent SDK[`addPlugins`](</docs/en/agent-sdk/typescript#load-more-plugin-folders-with-addplugins>) option**: when an application passes plugin folders to `reloadPlugins()` in `addPlugins`, that call fails with an error. The session keeps running with the plugins it already had. Requires Claude Code v2.1.301 or later
+
+In cloud sessions, Claude Code also ignores server-delivered mid-session MCP updates, the path behind cloud session configuration and SDK `setMcpServers()` calls that reach those sessions. In-process `type: "sdk"` entries and a Claude Tag session’s Slack tools stay exempt there too. Before v2.1.268, both this drop and the startup drop also removed a Claude Tag session’s Slack tools. Before v2.1.239, a server-delivered `--mcp-config` blocked a cloud session from starting. The desktop app manages some plugins itself, including plugins synced from claude.ai and plugins your organization deploys through the app. If you deploy this key to a device through MDM, OS-level policy, or a managed settings file, the desktop app doesn’t pass those plugins to the following sessions on that device:
* **[Code sessions on the user’s machine](</docs/en/desktop#environment-configuration>)** : they also start without the skills enabled for the user’s claude.ai account. Plugins that Claude Code installs from marketplaces in your managed settings still load. In [Claude Desktop on 3P](<https://claude.com/docs/third-party/claude-desktop/overview>), MCP servers from plugins you deploy to the device’s `org-plugins` directory stay available too, because the desktop app connects to them itself. Before Claude Desktop v1.37937.0, these sessions failed at startup instead.
* **[Cowork sessions on the user’s machine](</docs/en/managed-settings#where-and-when-a-policy-applies>)** : the skills inside those plugins and the skills enabled for the user’s claude.ai account stay available. In [Claude Desktop on 3P](<https://claude.com/docs/third-party/claude-desktop/overview>), MCP servers from plugins you deploy to the device’s `org-plugins` directory stay available too, because the desktop app connects to them itself. Before Claude Desktop v1.44121.0, these sessions failed at startup instead.
--- a/terminal-config.md
+++ b/terminal-config.md
@@ -316,7 +316,7 @@
* `inactive` and `inactiveShimmer`
* `fastMode` and `fastModeShimmer`
-Each [subagent](</docs/en/sub-agents>) and parallel task is shown in one of eight named colors so you can tell them apart in the transcript. The token names follow the pattern `<color>_FOR_SUBAGENTS_ONLY`, where `<color>` is `red`, `blue`, `green`, `yellow`, `purple`, `orange`, `pink`, or `cyan`. Override these to change what each named color looks like. For example, a subagent with `color: blue` in its definition is drawn using the `blue_FOR_SUBAGENTS_ONLY` value.Claude Code renders the [`ultrathink`](</docs/en/model-config#use-ultrathink-for-one-off-deep-reasoning>) keyword in the prompt input with a seven-color rainbow gradient. The token names follow the pattern `rainbow_<color>` and `rainbow_<color>_shimmer`, where `<color>` is `red`, `orange`, `yellow`, `green`, `blue`, `indigo`, or `violet`.
+Each [subagent](</docs/en/sub-agents>) and parallel task is shown in one of eight named colors so you can tell them apart in the transcript. The token names follow the pattern `<color>_FOR_SUBAGENTS_ONLY`, where `<color>` is `red`, `blue`, `green`, `yellow`, `purple`, `orange`, `pink`, or `cyan`. Override these to change what each named color looks like. For example, a subagent with `color: blue` in its definition is drawn using the `blue_FOR_SUBAGENTS_ONLY` value.When [`ultrathink`](</docs/en/model-config#use-ultrathink-for-one-off-deep-reasoning>) can raise a turn’s effort, Claude Code renders the word in the prompt input with a seven-color rainbow gradient. The token names follow the pattern `rainbow_<color>` and `rainbow_<color>_shimmer`, where `<color>` is `red`, `orange`, `yellow`, `green`, `blue`, `indigo`, or `violet`.
##
--- a/test.md
+++ b/test.md
@@ -300,12 +300,12 @@
Method| What it does
---|---
`press({ key: 'more' })`| Presses the `Button` with that key
-`input({ key: 'new-note', text: 'buy milk' })`| Types the text into the `Input` with that key and presses Enter. Add `kind: 'change'` to type without submitting.
+`input({ key: 'new-note', text: 'buy milk' })`| Types the text into the `Input` with that key and presses Enter. Add `kind: 'change'` to type without submitting. For a field with `rows`, the text can hold `\n`.
`select({ key: 'size', value: 'large' })`| Picks the option with that value in the `Select` with that key
`find({ key: 'more' })` or `find({ type: 'Text', text: 'Count: 2' })`| Returns the first matching element as `{ type, props, children }`, or `undefined`. `text` can be a string or a regular expression.
`unmount()`| Removes the drawing
-Each method resolves after your handler has finished, so you can check the result on the next line. Set `props` to what Claude Code would pass for that site. The [render sites table](</docs/en/plugins/mods/reference#render-sites>) lists each site’s props, and [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) have their types. A drawing test checks the tree your hook returns and whether it’s valid for that app. It doesn’t check how the app paints it, so look at a new layout in a real session as well.
+Each method resolves after your handler has finished, so you can check the result on the next line. Set `props` to what Claude Code would pass for that site. The [render sites table](</docs/en/plugins/mods/reference#render-sites>) lists each site’s props, and [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) have their types. To catch an [element tree](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) that isn’t valid for the app you named in `surface`, check with `find` for an element your hook adds. The test doesn’t check how the app paints a tree, so look at a new layout in a real session too.
###
--- a/troubleshoot.md
+++ b/troubleshoot.md
@@ -300,7 +300,7 @@
* **Keep the bands after it** : put the result of `await next(e)` among the children of a `Box` in its tree, as in the Band above the prompt tab of [Pick where to draw](</docs/en/plugins/mods/interface#pick-where-to-draw>)
* **Keep the tree valid** : don’t give that `Box`, or any `Box` around it, a `width`, `height`, `minWidth`, `minHeight`, `position`, `top`, `left`, `right`, `bottom`, `display`, or `overflow` prop
-To find that mod, write a debug log and search it for `answered ui.render without next()`. A line such as `other-mod (user) answered ui.render without next()` names a mod that returned its tree without calling `next(e)`. It doesn’t name the [render site](</docs/en/plugins/mods/reference#render-sites>), so a pane-only mod can appear too. A mod that calls `next(e)` and drops the result gets no line, so check the hooks before yours too. After the change, you see nothing in the band if any of the mods returns a tree that doesn’t validate. To read the reason, look for a `ui.render (AbovePrompt) refused:` line in the transcript of a `--plugin-dir` session, or search the debug log for `does not validate`. With several mods in the band, neither line names a mod, so check each mod’s tree.
+To find that mod, write a debug log and search it for `answered ui.render without next()`. A line such as `other-mod (user) answered ui.render without next()` names a mod that returned its tree without calling `next(e)`. It doesn’t name the [render site](</docs/en/plugins/mods/reference#render-sites>), so a pane-only mod can appear too. A mod that calls `next(e)` and drops the result gets no line, so check the hooks before yours too. A mod’s band is also missing when the tree its own hook returned doesn’t validate, and the other mods’ bands stay. To find which mod and why, write a debug log and search it for `ui.render hook skipped`.
###
@@ -308,7 +308,23 @@
A pane or band is empty or shows Claude Code’s usual content
-The [tree](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) your hook returned didn’t validate. With `--plugin-dir`, the transcript says `ui.render (Pane) refused:` with the reason, as in `first-mod: ui.render (Pane) refused: Box prop "flexDirection" must be one of row, column, row-reverse, column-reverse; the engine drew its own`. The debug log has `a hook returned a tree that does not validate` with the same reason. Read the reason on that line. Common causes are a prop the element doesn’t take and an element the app doesn’t have.
+The [tree](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) your hook returned didn’t validate. A `hook skipped` line in the transcript or the debug log names your mod and the reason, as in this one for a `Box` in a pane:
+
+ first-mod: ui.render hook skipped: returned the wrong shape (a tree Pane refuses: Box prop "flexDirection" must be one of row, column, row-reverse, column-reverse)
+
+Fix what the reason names. If the reason is cut short, write a debug log and search it for `a hook returned a tree that does not validate` to read the rest. If the line instead says `refused:` right after the site’s name, as in `ui.render (Pane) refused:`, see A `ui.render` line says `refused`.
+
+###
+
+
+
+A `ui.render` line says `refused`
+
+`ui.render (<site>) refused:`, or `ui.render (<site>): the chain settled on a tree that does not validate` in the debug log, means the [tree](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) at that site exceeds a [size limit](</docs/en/plugins/mods/reference#limits>). Either line names the [render site](</docs/en/plugins/mods/reference#render-sites>) and then the reason, and the reason names the limit. Change the mods that draw at that site so their [`ui.render`](</docs/en/plugins/mods/reference#interface>) hooks return smaller trees, or ask their authors to. If the transcript line starts with `hooks`, more than one loaded mod has a `ui.render` hook for that site, so check each of those mods’ trees. For several mods whose bands above the prompt nest into a tree more than 32 levels deep, the line reads:
+
+ hooks: ui.render (AbovePrompt) refused: deeper than 32; nothing was drawn
+
+Before v2.1.307, a `refused:` line for any site reported any tree that didn’t validate, and for `Pane` and `AbovePrompt` it ended `; the engine drew its own`. On those releases, fix what the reason names.
###
@@ -493,7 +509,7 @@
hooks module first-mod@inline loaded (worker, environment 2, tier user); events: session.start,tool.call,command.run,ui.render
-A drawing that didn’t validate counts as a refused result and gets a line too. To write your own lines in the log, call [`$.ui.log`](</docs/en/plugins/mods/api#show-something-without-starting-a-turn>) with a second argument, as in `$.ui.log('message', { to: 'debug' })`. Without the second argument, `$.ui.log` adds a dim line to the transcript. While you edit a mod loaded with `--plugin-dir`, the transcript shows a line for each reload that names the mod and lists its hooks. If a save breaks the module, the line says `reload failed, the previous version stays loaded:` with the reason, and the last working version keeps running until Claude Code next reloads plugins, such as when you run `/reload-plugins`.
+To write your own lines in the log, call [`$.ui.log`](</docs/en/plugins/mods/api#show-something-without-starting-a-turn>) with a second argument, as in `$.ui.log('message', { to: 'debug' })`. Without the second argument, `$.ui.log` adds a dim line to the transcript. While you edit a mod loaded with `--plugin-dir`, the transcript shows a line for each reload that names the mod and lists its hooks. If a save breaks the module, the line says `reload failed, the previous version stays loaded:` with the reason, and the last working version keeps running until Claude Code next reloads plugins, such as when you run `/reload-plugins`.
##
Show diff (228 lines)
--- a/typescript.md
+++ b/typescript.md
@@ -224,7 +224,7 @@
---|---|---|---
`title`| `string`| `undefined`| Human-readable title for the tool
`readOnlyHint`| `boolean`| `false`| If `true`, the tool does not modify its environment
-`destructiveHint`| `boolean`| `true`| If `true`, the tool may perform destructive updates (only meaningful when `readOnlyHint` is `false`)
+`destructiveHint`| `boolean`| `true`| If `true`, the tool may perform destructive updates. Set `destructiveHint: true` explicitly on any tool you mark `always_ask`, or the auto mode classifier can approve that tool’s calls in place of your `canUseTool` callback. Leaving `destructiveHint` unset isn’t enough, because Claude Code treats an unset `destructiveHint` as `false` when it handles `always_ask` calls, although the MCP specification’s default is `true`
`idempotentHint`| `boolean`| `false`| If `true`, repeated calls with the same arguments have no additional effect (only meaningful when `readOnlyHint` is `false`)
`openWorldHint`| `boolean`| `true`| If `true`, the tool interacts with external entities (for example, web search). If `false`, the tool’s domain is closed (for example, a memory tool)
@@ -721,6 +721,7 @@
): Promise<SDKControlReadFileResponse | null>;
reloadPlugins(options?: {
holdOnCacheImpact?: boolean;
+ addPlugins?: SdkPluginConfig[];
}): Promise<SDKControlReloadPluginsResponse>;
reloadSkills(): Promise<SDKControlReloadSkillsResponse>;
reloadOutputStyles(): Promise<SDKControlReloadOutputStylesResponse>;
@@ -763,7 +764,7 @@
`mcpServerStatus()`| Returns the status of connected MCP servers as `McpServerStatus``[]`
`getContextUsage(opts?)`| Returns an `SDKControlGetContextUsageResponse` breaking down the session’s context window usage by category, skill, and tool. With the default `detail`, it includes the data `/context` shows in an interactive session, computed with token-counting API requests that don’t appear in the message stream; see how these requests are handled. The `detail` option requires Agent SDK v0.3.257 or later
`readFile(path, options?)`| Reads a file from the session’s filesystem. Claude Code resolves the path against `cwd`; What `readFile()` can read lists the files it serves. Pass `{ maxBytes }` to change the read cap (default 1 MB, ceiling 10 MB) and `{ encoding: 'base64' }` for binary files such as images. Resolves with an `SDKControlReadFileResponse`, or `null` on permission denial, a missing file, or a transport error. Requires TypeScript SDK v0.2.121 or later
-`reloadPlugins(options?)`| Reloads plugins from disk, so plugins you install or edit mid-session reach the running session. Resolves with an `SDKControlReloadPluginsResponse` listing the session’s commands, subagents, plugins, and MCP server status. Requires Agent SDK v0.2.85 or later. The `holdOnCacheImpact` option requires Agent SDK v0.3.268 or later
+`reloadPlugins(options?)`| Reloads plugins from disk, so plugins you install or edit mid-session reach the running session. Resolves with an `SDKControlReloadPluginsResponse` listing the session’s commands, subagents, plugins, and MCP server status. Requires Agent SDK v0.2.85 or later. The `holdOnCacheImpact` option requires Agent SDK v0.3.268 or later. The `addPlugins` option requires Agent SDK v0.3.301 or later
`reloadSkills()`| Reloads skills from disk, so skills you add or edit mid-session become available to the running session. Resolves with an `SDKControlReloadSkillsResponse` listing the skills available after the reload. Requires Agent SDK v0.3.163 or later
`reloadOutputStyles()`| Re-reads [output styles](</docs/en/output-styles>) from disk, so a style file you add or edit mid-session becomes available to the running session. Resolves with an `SDKControlReloadOutputStylesResponse` listing the style names available after the reload. Requires Agent SDK v0.3.261 or later
`seedReadState(path, mtime)`| Marks a file as already read so a later Edit doesn’t fail with `File has not been read yet`. See `seedReadState()`. Requires TypeScript SDK v0.2.83 or later
@@ -1221,6 +1222,31 @@
`cache_impact` is present only alongside `held: true`. `mcp_servers_added` and `mcp_servers_removed` name the plugin MCP servers the reload would register or drop, as scoped `plugin:<plugin>:<server>` names. The names are plugin-authored, so validate them before showing them. `lsp_tool_change` says whether applying would add or remove the LSP tool, or `null` when it would do neither. The `may-` forms mean the check couldn’t fully see the pending plugin set.
+####
+
+
+
+Load more plugin folders with `addPlugins`
+
+To load plugin folders that weren’t in the `plugins` option at startup, pass them to `reloadPlugins()` as `addPlugins`, a list of `SdkPluginConfig` entries whose `path` is absolute. Claude Code loads the new folders and reloads the session’s existing plugins in one pass. Each added plugin’s MCP servers connect too, unless you set `skipMcpDiscovery` on that folder’s entry. Requires Agent SDK v0.3.301 or later and Claude Code v2.1.301 or later. This example adds one folder to a running query `q` and prints the install path of every plugin the session has loaded when the call returns:
+
+ const result = await q.reloadPlugins({
+ addPlugins: [{ type: "local", path: "/opt/my-app/plugins/reports" }]
+ });
+
+ console.log(result.plugins.map((plugin) => plugin.path));
+
+If the folder loaded, the printed list includes `/opt/my-app/plugins/reports`, and the plugin’s commands and subagents appear in `result.commands` and `result.agents`. An added folder stays part of the session. When you call `reloadPlugins()` again, Claude Code reloads it with the other plugins, and you don’t pass it in `addPlugins` again. If `reloadPlugins()` rejects, none of the `addPlugins` folders are added, so pass them in `addPlugins` again when you retry. When the rejection has one of the following causes, the session keeps the plugins it already had:
+
+ * **A relative`path` or a malformed entry**: the error message says `add_plugins must be a list of { type: "local", path } entries with absolute paths`. Claude Code refuses the whole list over one bad entry, so pass every entry as `{ type: "local", path }` with an absolute `path`
+ * **An administrator has turned on[`disableSideloadFlags`](</docs/en/settings-reference#disablesideloadflags>) in your managed settings**: the message says `reload_plugins add_plugins is disabled by managed settings (disableSideloadFlags)`. To load the folder, ask that administrator to remove the setting
+ * **The[sandbox](</docs/en/sandboxing>) couldn’t be rebuilt**: with sandboxing on, Claude Code rebuilds the sandbox configuration so that sandboxed shell commands can’t write to the folders you add. The message says `the sandbox could not be rebuilt to keep shell commands out of this folder`. Check that your sandbox settings still form a valid configuration
+
+If you pass `holdOnCacheImpact` and the call resolves with `held: true`, the `addPlugins` folders aren’t added. To add them anyway, call `reloadPlugins()` again with the same `addPlugins` list and without `holdOnCacheImpact`. When the call resolves without `held: true` and a folder is still missing from `result.plugins`, start by checking for these causes:
+
+ * **The folder doesn’t exist or its plugin failed to load** : `result.error_count` is `1` or higher. The folder stays part of the session even so. After you fix the folder, call `reloadPlugins()` again to load it, this time without listing it in `addPlugins`
+ * **The Claude Code executable is older than v2.1.301** : an executable older than v2.1.301 ignores `addPlugins` and reloads only the plugins the session already had. Check `claude_code_version` on the init message, and run an executable at v2.1.301 or later
+
###
@@ -1546,12 +1572,93 @@
`McpSdkServerConfigWithInstance`
+Configuration for an in-process MCP server. It is what `createSdkMcpServer()` returns, plus an optional `tools` list of `McpServerToolPolicy` entries that you add.
+
type McpSdkServerConfigWithInstance = {
type: "sdk";
name: string;
timeout?: number;
+ tools?: McpServerToolPolicy[];
instance: McpServer;
};
+
+To require approval for calls to one of the server’s tools, or deny them, add a policy entry naming the tool. Spread what `createSdkMcpServer()` returns into an object under `mcpServers` and put the entry in a `tools` list on that object, because the function’s `tools` option accepts tool definitions and not policy entries. The policy list requires Agent SDK v0.3.301 or later, and `McpServerToolPolicy` describes what each `permission_policy` value does. In this script, an `allowedTools` wildcard pre-approves every tool on the `records` server, but `delete_record` is marked `always_ask`, so calls to it go to `canUseTool` anyway. With the `destructiveHint: true` annotation, the call still reaches the callback if the session runs in `auto` mode, where the auto mode [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) could otherwise approve it.
+
+ import { query, tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
+ import { z } from "zod";
+
+ const deleteRecord = tool(
+ "delete_record",
+ "Delete a customer record by ID",
+ { id: z.string() },
+ async ({ id }) => ({ content: [{ type: "text", text: `Deleted record ${id}` }] }),
+ { annotations: { destructiveHint: true } }
+ );
+
+ const records = createSdkMcpServer({ name: "records", tools: [deleteRecord] });
+
+ for await (const message of query({
+ prompt: "Delete customer record 42",
+ options: {
+ mcpServers: {
+ // Spread the returned config and add the policy list beside it
+ records: {
+ ...records,
+ tools: [{ name: "delete_record", permission_policy: "always_ask" as const }]
+ }
+ },
+ allowedTools: ["mcp__records__*"],
+ canUseTool: async (toolName, input) => {
+ console.log(`Approval requested for ${toolName}`);
+ return { behavior: "allow", updatedInput: input };
+ }
+ }
+ })) {
+ if (message.type === "result" && message.subtype === "success") {
+ console.log(message.result);
+ }
+ }
+
+When Claude calls `delete_record`, the script prints `Approval requested for mcp__records__delete_record`. To change or lift a tool’s policy while the session runs, pass the server’s config with a new `tools` value to `setMcpServers()`. The `tools` value you pass takes effect from Claude’s next call to that server’s tools:
+
+ * **A list with entries** : the entries replace the current policies
+ * **An empty list** : every policy on the server is cleared
+ * **No`tools` key**: the current policies stay
+
+Include in that call your other in-process servers and any server an earlier `setMcpServers()` call added, or the call disconnects them.
+
+####
+
+
+
+`McpServerToolPolicy`
+
+One entry in an `McpSdkServerConfigWithInstance`’s `tools` list, naming one of the server’s tools and setting the permission policy for calls to that tool. The list requires Agent SDK v0.3.301 or later and Claude Code v2.1.301 or later. An older Claude Code executable, such as an executable you point `pathToClaudeCodeExecutable` at, ignores the list. Then `always_ask` and `always_deny` aren’t enforced, and each call goes through the [permission flow](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>).
+
+ type McpServerToolPolicy = {
+ name: string;
+ permission_policy?: "always_allow" | "always_ask" | "always_deny";
+ org_max_permission?: "allow" | "ask" | "blocked";
+ };
+
+Field| Type| Description
+---|---|---
+`name`| `string`| The tool’s bare name as passed to `tool()`, without the `mcp__<server>__` prefix
+`permission_policy`| `'always_allow' | 'always_ask' | 'always_deny'`| The approval policy for the tool’s calls, `always_ask` or `always_deny`. `always_allow` is ignored on an in-process server: to pre-approve a tool, list it in `allowedTools` instead
+`org_max_permission`| `'allow' | 'ask' | 'blocked'`| A per-tool ceiling that an organization admin sets. Ignored on an in-process server, so leave it unset
+
+Choose `always_ask` to approve each call yourself, or `always_deny` to block the tool outright:
+
+ * **`always_ask`** : each call to the tool [needs approval](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>), even if an `allowedTools` entry or allow rule covers it. The call goes to your `canUseTool` callback or `permissionPromptToolName` tool, unless it’s settled first. A [mod](</docs/en/plugins/mods/overview>) in a plugin you load [can approve it first](</docs/en/permissions#precedence-among-rules-hooks-and-mods>). Otherwise, in `dontAsk` mode it’s denied, and in `auto`, `plan`, and `bypassPermissions` mode it can be approved before it reaches your callback
+ * **`always_deny`** : a call to the tool [is denied](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) in every permission mode, including `bypassPermissions`, but a mod in a plugin you load [can still approve it](</docs/en/permissions#precedence-among-rules-hooks-and-mods>)
+
+If you pass neither `canUseTool` nor `permissionPromptToolName`, or set `permissionPrompts` to `'none'`, an `always_ask` call that isn’t settled first is denied unless a [`PermissionRequest` hook](</docs/en/hooks#permissionrequest>) allows it. In `auto`, `plan`, and `bypassPermissions` mode, a call to a tool marked `always_ask` can be approved before it reaches your `canUseTool` callback.
+
+ * **`auto`** : the auto mode [classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) reviews the call and can allow it. To make every call reach your callback in `auto` mode, set `destructiveHint: true` in the tool’s annotations
+ * **`plan`** : while [auto mode is available](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) to the session, calls to an `always_ask` tool annotated `readOnlyHint: true` go to the auto mode classifier, which can allow them. Calls to other `always_ask` tools reach your callback. To make a read-only tool’s calls reach your callback too, add `destructiveHint: true` to that tool’s annotations alongside `readOnlyHint: true`. Alternatively, set [`useAutoModeDuringPlan`](</docs/en/settings-reference#useautomodeduringplan>) to `false`, which turns the classifier off during planning
+ * **`bypassPermissions`** : when the [`CLAUDE_CODE_REMOTE`](</docs/en/env-vars#variables>) environment variable is `true`, as it is in a [cloud session](</docs/en/claude-code-on-the-web>), the call is approved without your callback, whatever the tool’s annotations. Anywhere else the call reaches your callback. To make it reach your callback in a cloud session too, run the session in `default` or `acceptEdits` mode instead
+
+Set `destructiveHint` to `true` explicitly in `auto` and `plan` mode. For `always_ask` calls, Claude Code reads an unset `destructiveHint` as `false`, although the default listed under `ToolAnnotations` is `true`.
####
@@ -1582,7 +1689,7 @@
Field| Type| Description
---|---|---
`type`| `'local'`| Must be `'local'` (only local plugins currently supported)
-`path`| `string`| Absolute or relative path to the plugin directory
+`path`| `string`| Path to the plugin directory. A relative path resolves against the `cwd` option when the session starts. The path must be absolute when you load the plugin mid-session with `addPlugins`
`skipMcpDiscovery`| `boolean`| When `true`, the SDK loads skills, hooks, agents, and commands from this plugin but does not read its `.mcp.json` or manifest `mcpServers`. Set this when your application owns the plugin’s MCP connections.
**Example:**
@@ -5416,7 +5523,29 @@
}[];
};
-`source` says where the server’s definition came from, with the same values and trust rule as `McpServerProvenance`’s `source`. The field requires Agent SDK v0.3.274 or later and is absent on earlier versions. `_meta` on a `tools` entry carries the MCP Apps members of that tool’s `_meta`, so your application can find the `ui://` resource to render with `readMcpResource()`. Claude Code passes through the `ui` object and the deprecated flat `ui/resourceUri` string, and withholds every other key. Inside `ui`, `resourceUri` is a `ui://` string and `visibility` an array of `"model"` and `"app"` when the server sets them, and any other member passes through unchanged. Claude Code drops either key when the value is malformed, and omits `_meta` from a tool that declares neither. The field is present only when the init message’s `capabilities` include `mcp_tool_ui_meta_v1`, and requires TypeScript Agent SDK v0.3.280 or later.
+Use `source` to decide how far to trust a server, and the `_meta` on each `tools` entry to find a UI resource the server attached to that tool:
+
+ * **`source`** : where the server’s definition came from, with the same values as `source` on `McpServerProvenance`. Base trust decisions on `source` rather than on `name`, because only your own in-process server reports `sdk`, whatever name any other server is registered under. If you don’t recognize a `source` value, treat that server as you treat any server whose `source` isn’t `sdk`. Requires Agent SDK v0.3.274 or later
+ * **`_meta`** : the `ui` object and the `ui/resourceUri` string from the `_meta` the server declared for the tool. Claude Code withholds every other `_meta` key. `ui/resourceUri` is an older top-level spelling of `ui.resourceUri`. When the server attaches an [MCP Apps UI resource](</docs/en/mcp#reference-mcp-resources>) to the tool, `ui.resourceUri` or `ui/resourceUri` holds the resource’s `ui://` URI. Fetch that URI with `readMcpResource()` and render the resource in your application. Requires Agent SDK v0.3.280 or later
+
+Claude Code sends `_meta` only when the `capabilities` array of the `system` message with subtype `init` lists `mcp_tool_ui_meta_v1`. You don’t turn `mcp_tool_ui_meta_v1` on yourself.
+
+####
+
+
+
+When a tool’s `_meta.ui` holds only `visibility`
+
+If your server declares `ui.resourceUri` for a tool but the `_meta.ui` your application receives holds only `visibility`, the `ui` object the server sent failed one of Claude Code’s checks. Compare the `_meta` in your server’s `tools/list` response against the checks for each key:
+
+ * **`ui`** : reaches your application unchanged, including any members other than `resourceUri` and `visibility`, if all three checks pass:
+ * `resourceUri` is absent, or is a string that starts with `ui://`
+ * `visibility` is absent, or lists only `"model"` and `"app"`
+ * The whole object is at most 4,096 characters when serialized as JSON
+If any of the checks fails, your application receives at most a `ui` whose only member is a `visibility` array with the `"model"` and `"app"` entries the server listed.
+ * **`ui/resourceUri`** : reaches your application if it is a string that starts with `ui://` and is at most 4,096 characters. Otherwise Claude Code drops it
+
+When Claude Code is left with no `ui` member and no `ui/resourceUri` string to send, the `tools` entry has no `_meta` at all.
###
@@ -5663,7 +5792,9 @@
When you call `setMcpServers()`, Claude Code applies these rules:
* **Servers the call doesn’t name** : outside a [cloud session](</docs/en/claude-code-on-the-web>), Claude Code disconnects the servers an earlier `setMcpServers()` call added and the in-process SDK servers, and lists them in `removed`. Other servers keep running and aren’t listed in `removed`, among them the stdio, HTTP, and SSE servers from the `mcpServers` option, servers from settings files, and plugin-provided servers.
- * **Servers the call names** : Claude Code replaces a stdio, HTTP, or SSE server that an earlier `setMcpServers()` call added only when its config differs from the one you passed. An in-process SDK server already registered under that name stays as it is, so to swap one, leave it out of one call and add it in the next.
+ * **Stdio, HTTP, and SSE servers that an earlier`setMcpServers()` call added**: outside a cloud session, a server you name again with an identical config keeps its connection and tools. It appears in neither `added` nor `removed`. If you pass a changed config, Claude Code reconnects the server using that config and lists it in `added`, not in `removed`.
+ * **Stdio, HTTP, and SSE servers the call names that no earlier call added** : outside a cloud session, Claude Code adds the server and lists it in `added`, or in `errors` if it refuses the server.
+ * **In-process SDK servers the call names** : a server already registered through `mcpServers` or an earlier call keeps its running instance and timeout. If you pass a `tools` policy list for it, even an empty one, you replace its policies; otherwise they stay. To run a new instance outside a cloud session, omit the server from one call and name it in the next.
* **Built-in servers the CLI started at startup** : if the call names one, Claude Code drops that entry and reports it in `errors`.
* **Stdio, HTTP, or SSE servers that share a name with one from an MCP installation scope such as`.mcp.json`**: under that name the session uses your server’s tools rather than the [installation-scope server’s](</docs/en/mcp#mcp-installation-scopes>). Before Claude Code v2.1.305, Claude Code could disconnect your server and connect the installation-scope server when your app reloaded plugins.
@@ -6147,6 +6278,22 @@
* `timestamp`: when the reset happened, as an ISO 8601 string in UTC. Use it for display, not for ordering messages.
The `trigger`, `user_message_uuid`, and `timestamp` fields require Claude Code v2.1.281 or later. The SDK’s published typings declare `SDKConversationResetMessage` in Claude Code v2.1.203 and later. Before v2.1.203, `SDKMessage` referenced the type without declaring it, so narrowing on `type === "conversation_reset"` failed to typecheck when `skipLibCheck` was disabled.
+
+###
+
+
+
+`BUILTIN_TOOL_NAMES` and `LEGACY_TOOL_NAME_ALIASES`
+
+Use these two constants to check tool names that your application’s users enter. Both spell each name the way you write it in permission rules, hook matchers, and the `tools` and `disallowedTools` options. Import them from `@anthropic-ai/claude-agent-sdk` or from `@anthropic-ai/claude-agent-sdk/core`. They require Agent SDK v0.3.301 or later and are alpha. The SDK’s type declarations give `BUILTIN_TOOL_NAMES` a readonly tuple type and `LEGACY_TOOL_NAME_ALIASES` a string-to-string record type:
+
+ const BUILTIN_TOOL_NAMES: readonly ["Agent", /* ...more names... */ "Write"];
+ const LEGACY_TOOL_NAME_ALIASES: Readonly<Record<string, string>>;
+
+ * **`BUILTIN_TOOL_NAMES`** : names of Claude Code’s built-in tools in alphabetical order, such as `Agent`, `Bash`, and `Read`. MCP tool names aren’t included. Because the type is a tuple of string literals, `(typeof BUILTIN_TOOL_NAMES)[number]` gives you a union type of the names
+ * **`LEGACY_TOOL_NAME_ALIASES`** : earlier tool names that permission rules, hook matchers, and the `tools` and `disallowedTools` options still accept. Each key is an earlier name and its value is the current one: for example, `Task` maps to `Agent`, and `KillShell` and `KillBash` map to `TaskStop`
+
+You can confirm a name with either of two tests: `BUILTIN_TOOL_NAMES` includes it, or `Object.hasOwn(LEGACY_TOOL_NAME_ALIASES, name)` returns `true`. A name that fails both can still be valid, because `BUILTIN_TOOL_NAMES` leaves out MCP tools and some built-in tools. If you build a deny list from `BUILTIN_TOOL_NAMES`, Claude can still use the tools the constant leaves out. To deny every tool, set [`disallowedTools: ["*"]`](</docs/en/agent-sdk/permissions#allow-and-deny-rules>) instead. Finding a name in `BUILTIN_TOOL_NAMES` doesn’t tell you the session has that tool: `TodoWrite` is listed even though it’s [disabled by default](</docs/en/tools-reference>). To see which tools a session has, read the `tools` array of its `SDKSystemMessage`. That array includes MCP tools and lists the Agent tool as `Task`, so map each name through `LEGACY_TOOL_NAME_ALIASES` before comparing it with `BUILTIN_TOOL_NAMES`.
###
Show diff (113 lines)
--- a/vs-code.md
+++ b/vs-code.md
@@ -145,12 +145,27 @@
Explain the logic in @auth (fuzzy matches auth.js, AuthService.ts, etc.)
What's in @src/components/ (include a trailing slash for folders)
-For large PDFs, you can ask Claude to read specific pages instead of the whole file. Ask for a single page, a range like pages 1-10, or an open-ended range like page 3 onward. Reading specific pages requires [poppler-utils](</docs/en/tools-reference#read-tool-behavior>) on the machine where Claude Code runs. When you select text in the editor, Claude can see your highlighted code automatically. The prompt box footer shows how many lines are selected. Press `Option+K` (Mac) / `Alt+K` (Windows/Linux) to insert an @-mention with the file path and line numbers, for example `@app.ts#5-10`. Click the **X** on the selection indicator to remove it so Claude doesn’t receive the selection. The indicator comes back when you select other text. The extension withholds selected text from some files:
-
- * When the file is inside your workspace and matches your `files.exclude` or `search.exclude` settings, Claude receives at most the file’s path and not the text you selected.
- * The same applies to a file git ignores, as long as VS Code’s `search.useIgnoreFiles` setting and the extension’s `respectGitIgnore` setting are both on, which is the default.
-
-This filter covers the chat panel only. When Claude Code runs in the integrated terminal, the CLI sends your selected text whatever the file. To keep a file’s contents from Claude there, add a `Read` deny rule. Claude also sees which file you have open in the editor, even when nothing is selected, and the prompt box shows its name. To add only your selected text, turn off the [Attach Open File setting](<vscode://settings/claudeCode.attachOpenFile>). The setting requires Claude Code v2.1.271 or later. You can also attach images and files to your message:
+###
+
+
+
+Read specific pages of a PDF
+
+For large PDFs, you can ask Claude to read specific pages instead of the whole file. Ask for a single page, a range like pages 1-10, or an open-ended range like page 3 onward. Reading specific pages requires [poppler-utils](</docs/en/tools-reference#read-tool-behavior>) on the machine where Claude Code runs.
+
+###
+
+
+
+Include terminal output in prompts
+
+Reference terminal output in your prompts using `@terminal:name` where `name` is the terminal’s title. This lets Claude see command output, error messages, or logs without copy-pasting.
+
+###
+
+
+
+Attach images and files
* To attach an image, paste it from your clipboard into the prompt box.
* To attach files, hold `Shift` while dragging them into the prompt box.
@@ -160,20 +175,46 @@
-Include terminal output in prompts
-
-Reference terminal output in your prompts using `@terminal:name` where `name` is the terminal’s title. This lets Claude see command output, error messages, or logs without copy-pasting.
-
-###
-
-
-
Paste text
Text you paste stays visible in the prompt box, rather than collapsing to a placeholder as it does [in the terminal](</docs/en/terminal-config#paste-large-content>). In sessions where Claude Code [marks pasted text](</docs/en/terminal-config#how-claude-treats-pasted-text>), Claude still sees a large paste as text you pasted rather than typed. Claude Code also removes [invisible Unicode characters](</docs/en/interactive-mode#invisible-characters-in-prompts>) from text you paste into the prompt box and from anything else you send:
* If a notice such as `Removed 3 invisible characters from the pasted text` appears when you paste, the text went in without those characters.
* If a notice about removed characters appears when you send, nothing was sent. The cleaned text is back in the prompt box. Send again to send the text as shown.
+
+###
+
+
+
+Automatic context from your selection and open file
+
+When you select text in the editor, Claude can see your highlighted code automatically. The prompt box footer shows how many lines are selected. Claude also sees which file you have open in the editor, even when nothing is selected, and the prompt box shows its name. Press `Option+K` (Mac) / `Alt+K` (Windows/Linux) to insert an @-mention with the file path and line numbers, for example `@app.ts#5-10`.
+
+####
+
+
+
+Keep your selection and open file out of your messages
+
+To stop selected text or your open file from going into your messages, turn off the matching setting in VS Code’s settings:
+
+ * **Selected text** : turn off the [Attach Selection setting](<vscode://settings/claudeCode.attachSelection>). Requires Claude Code v2.1.300 or later. To drop one selection, click the **X** beside the line count. The count returns when you select different text.
+ * **Open file** : turn off the [Attach Open File setting](<vscode://settings/claudeCode.attachOpenFile>). Requires Claude Code v2.1.271 or later. The file stays out unless your message includes text you selected in it.
+
+To add text as an @-mention with Attach Selection off, select it and press `Option+K` on Mac or `Alt+K` on Windows and Linux. Both settings also apply when you run `claude` in VS Code’s integrated terminal.
+
+####
+
+
+
+Selected text from excluded or ignored files
+
+In the chat panel, the extension withholds selected text from some files:
+
+ * When the file is inside your workspace and matches your `files.exclude` or `search.exclude` settings, Claude receives at most the file’s path and not the text you selected.
+ * The same applies to a file git ignores, as long as VS Code’s `search.useIgnoreFiles` setting and the extension’s `respectGitIgnore` setting are both on, which is the default.
+
+This filter covers the chat panel only. When Claude Code runs in the integrated terminal, Claude can receive text you select in these files. To keep a file’s contents from Claude there, add a [`Read` deny rule](</docs/en/permissions#read-and-edit>).
###
@@ -698,7 +739,8 @@
`preferredLocation`| `panel`| Where Claude opens: `sidebar` (right) or `panel` (new tab)
`lockEditorGroups`| `true`| Lock the editor groups Claude starts for its tabs, so files you open while a Claude tab is focused go to another group. When off, the extension never locks an editor group. Requires Claude Code v2.1.274 or later
`autosave`| `true`| Auto-save files before Claude reads or writes them
-`attachOpenFile`| `true`| Add the file that is open in the editor to your messages and show it in the prompt box. When off, only your selected text is added. Requires Claude Code v2.1.271 or later
+`attachOpenFile`| `true`| Add the file that is open in the editor to your messages and show it in the prompt box. When off, the file is added only along with text you select. Requires Claude Code v2.1.271 or later
+`attachSelection`| `true`| Add the text you select in the editor to your messages and show it in the prompt box. When off, you can still add a selection as an @-mention. Requires Claude Code v2.1.300 or later
`useCtrlEnterToSend`| `false`| Use Ctrl/Cmd+Enter instead of Enter to send prompts
`scrollToBottomOnSend`| `true`| Scroll the conversation to the bottom when you send a message. When off, the conversation stays where you left it. Requires Claude Code v2.1.275 or later
`showMessageTimestamps`| `true`| Show when each message was sent. A date line marks where the day changes. Requires Claude Code v2.1.284 or later. Before v2.1.290, the default was `false`
@@ -847,9 +889,10 @@
The server is named `ide` and is hidden from `/mcp` because there’s nothing to configure. If your organization uses a `PreToolUse` hook to allowlist MCP tools, though, you’ll need to know it exists. **Selection and open-file context.** While connected, the CLI includes your current editor selection and the path of the active file as context on each prompt you send. The transcript shows a `⧉ Selected N lines from <file>` line when this happens. These cases change that context:
+ * **Attach Selection setting off**: the CLI doesn’t include your selection as context.
+ * **Attach Open File setting off** : the CLI includes the active file’s path only when it also includes a selection.
* **Queued messages** : if you [queue a message while Claude works](</docs/en/interactive-mode#queue-messages-while-claude-works>), it keeps the selection you had when you pressed `Enter`, whatever you select afterward.
* **Sensitive files** : to exclude a sensitive file such as `.env`, add a [`Read` deny rule](</docs/en/permissions#read-and-edit>) for its path. A matching deny rule prevents both the selected text and the open-file notice for that file from reaching Claude.
- * **Attach Open File turned off** : if you turn off the Attach Open File setting, the CLI receives the active file’s path only while you have text selected in it.
**Transport and authentication.** The server binds to `127.0.0.1` on a random port in the range 10000–65535, and the port is not configurable. The transport and the auth token work as follows:
--- a/web-quickstart.md
+++ b/web-quickstart.md
@@ -200,7 +200,7 @@
Leave inline comments
-Select any line in the diff, type your feedback, and press Enter. Comments queue up until you send your next message, then they’re bundled with it. Claude sees “at `src/auth.ts:47`, don’t catch the error here” alongside your main instruction, so you don’t have to describe where the problem is.
+Hover over a line in the diff and click the **+** that appears beside its line number to open a comment box, then type your feedback and press Enter. Comments queue up until you send your next message, then they’re bundled with it. Claude sees “at `src/auth.ts:47`, don’t catch the error here” alongside your main instruction, so you don’t have to describe where the problem is.
3
--- a/workflows.md
+++ b/workflows.md
@@ -159,7 +159,7 @@
* The session’s [concurrent subagent limit](</docs/en/sub-agents#concurrent-subagent-limit>) isn’t enforced for the subagents Claude spawns with the Agent tool
* In auto permission mode, you aren’t asked to approve the first workflow launch
-`/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Turn it off with `/effort ultracode off` when you return to routine work. The `/effort` slider offers the toggle only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>).
+`/effort ultracode` lasts for the current session; to have every session start with it, set the [`ultracode`](</docs/en/settings-reference#ultracode>) setting. Turn it off with `/effort ultracode off` when you return to routine work. The `/effort` slider offers the toggle only [when ultracode is available](</docs/en/model-config#when-ultracode-is-available>). Before v2.1.284, `/effort ultracode` set the session to `xhigh`, and `/effort ultracode off` failed with `Invalid argument`.
###
@@ -345,7 +345,7 @@
How a workflow runs
-The workflow runtime executes the script in an isolated environment, separate from your conversation. Intermediate results stay in script variables instead of landing in Claude’s context. Every run writes its script to a file under your session’s directory in `~/.claude/projects/`. Claude receives the path when the run starts, so you can ask for it. You can open that file to read the orchestration Claude wrote, diff it against a previous run’s script, or edit it and ask Claude to relaunch from the edited version. Claude can start a workflow only from a script file the session is already allowed to read. To run a script kept outside your working directory, add its directory with [`/add-dir`](</docs/en/permissions#working-directories>) or a [Read allow rule](</docs/en/permissions#read-and-edit>) first. The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session.
+The workflow runtime executes the script in an isolated environment, separate from your conversation. Intermediate results stay in script variables instead of landing in Claude’s context. Unless Claude starts a run from a script file’s path, Claude Code writes the run’s script to a file under your session’s directory in `~/.claude/projects/`. Claude receives the script’s path when the run starts, so you can ask for it. You can open that file to read the orchestration Claude wrote, diff it against a previous run’s script, or edit it and ask Claude to relaunch from the edited version. Claude can start a workflow only from a script file the session is already allowed to read. To run a script kept outside your working directory, add its directory with [`/add-dir`](</docs/en/permissions#working-directories>) or a [Read allow rule](</docs/en/permissions#read-and-edit>) first. The runtime tracks each agent’s result as the run progresses, which is what makes a run resumable within the same session.
###
@@ -409,10 +409,11 @@
Resume after you leave the session
-You can resume a run within the same Claude Code session. What happens to a running workflow when you leave the session depends on how you leave:
-
- * If you [background the session](</docs/en/agent-view#what-carries-over-when-you-background>), Claude Code replays the run the same way in the background session and continues it.
- * If you exit Claude Code while a workflow is running and [agent view is on](</docs/en/agent-view#from-inside-a-session>), the exit dialog offers `Move to background and exit`, which carries the run over the same way. If you choose `Exit and stop tasks` instead, or the option isn’t offered, the run stops with the session. Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`, so a session you resume with `claude --resume` can replay them when you ask Claude to relaunch the workflow. In a session you start fresh, Claude has no earlier run to relaunch and starts the workflow over as a new run.
+If you background your session or exit Claude Code while a workflow run is in progress, the run doesn’t continue on its own. The run continues only when Claude relaunches it with a `Workflow` call, which replays the run from its saved results.
+
+ * **You backgrounded the session or chose[`Move to background and exit`](</docs/en/agent-view#from-inside-a-session>)**: if the run hasn’t continued when you check the [background session](</docs/en/agent-view#what-carries-over-when-you-background>), ask Claude there to relaunch the workflow. Depending on your permission mode, Claude Code asks you to approve the relaunch first. If the session shows under `Needs input` in agent view, [attach to it](</docs/en/agent-view#attach-to-a-session>) to answer the approval prompt.
+ * **The relaunch in the background session failed with`nothing to resume`**: ask Claude to start the workflow over as a new run. If Claude started the run from the path of a script file outside `~/.claude/projects/`, such as one in your working directory, Claude can’t relaunch it in the background session.
+ * **You chose`Exit and stop tasks`, or weren’t offered `Move to background and exit`**: the run stopped with the session, and Claude Code keeps the run’s saved results under that session’s directory in `~/.claude/projects/`. Resume the session with `claude --resume` in your shell, then ask Claude to relaunch the workflow. In a fresh session, Claude has no earlier run to relaunch and starts the workflow over.
In a [cloud session](</docs/en/claude-code-on-the-web>), Claude Code also saves the run’s results with the session’s conversation history, which survives when the session’s VM is reclaimed. When you [reopen such a session](</docs/en/claude-code-on-the-web#environment-expired>) and ask Claude to relaunch the workflow, completed agents still return their saved results. In local and cloud sessions alike, when Claude relaunches an earlier run and Claude Code can’t find that run’s saved results at all, the relaunch fails with a `nothing to resume` error instead of starting the run over on its own. Ask Claude to start the workflow over as a new run.