modified Manage multiple agents with agent view View current →
Show diff (115 lines)
--- a/agent-view.md +++ b/agent-view.md @@ -87,7 +87,7 @@ State| Icon shows as| What it means ---|---|--- Working| Animated| Claude is actively running tools or generating a response -Needs input| Yellow| Claude is waiting on something only you can provide: an answer to a question, a permission decision, a [sandbox](</docs/en/sandboxing>) prompt to allow a network host, an MCP server’s [request for input](</docs/en/mcp#respond-to-mcp-elicitation-requests>), a managed-settings prompt, or an MCP authentication or settings request held by a session with no terminal attached +Needs input| Yellow| Claude is waiting on something only you can provide: an answer to a question, a permission decision, a [sandbox](</docs/en/sandboxing>) prompt to allow a network host, an MCP server’s [request for input](</docs/en/mcp#respond-to-mcp-elicitation-requests>), a managed-settings prompt, or an MCP authentication or settings request, or an `/install-github-app` request, held by a session with no terminal attached Idle| Dimmed| The session has nothing to do and is ready for your next prompt Completed| Green| The task finished successfully Failed| Red| The task ended with an error @@ -117,7 +117,7 @@ Pull request status -When a session opens a pull request, a `#1234` label appears at the right edge of the row, linked to the pull request in terminals that support hyperlinks. The label persists when you send a follow-up to the session, so the pull request remains visible while the row reverts to live progress. Background sessions that isolated their changes in a worktree open these pull requests themselves; How file edits are isolated covers when that happens and what a session never does without asking. A session that works on an existing pull request is linked to it the same way. Editing, commenting on, closing, or marking a pull request ready with `gh` links the pull request that the command’s own output names, so a `gh` command whose captured output names no pull request doesn’t create a link; `gh pr merge` is the common case, because it prints its result only to an interactive terminal. Checking a pull request out with `gh pr checkout`, or pushing to a branch that has an open pull request, links it by looking up that branch with `gh pr view` instead. When a session is linked to more than one pull request, the label shows a count instead, such as `3 PRs`, colored by the open pull request that most needs attention. Open the peek panel to see them all. The pull request number is colored by its status: +When a session opens a pull request, a `#1234` label appears at the right edge of the row, linked to the pull request. Claude Code emits the link even when it can’t detect hyperlink support, for example over SSH or tmux; set [`FORCE_HYPERLINK=0`](</docs/en/env-vars>) to render the label as plain text. The label persists when you send a follow-up to the session, so the pull request remains visible while the row reverts to live progress. Background sessions that isolated their changes in a worktree open these pull requests themselves; How file edits are isolated covers when that happens and what a session never does without asking. A session that works on an existing pull request is linked to it the same way. Editing, commenting on, closing, or marking a pull request ready with `gh` links the pull request that the command’s own output names, so a `gh` command whose captured output names no pull request doesn’t create a link; `gh pr merge` is the common case, because it prints its result only to an interactive terminal. Checking a pull request out with `gh pr checkout`, or pushing to a branch that has an open pull request, links it by looking up that branch with `gh pr view` instead. When a session is linked to more than one pull request, the label shows a count instead, such as `3 PRs`, colored by the open pull request that most needs attention. Open the peek panel to see them all. The pull request number is colored by its status: Color| Pull request status ---|--- @@ -154,7 +154,7 @@ * Press `Esc` to undo the switch and return to the conversation. If `Esc` shows `Still starting — try again in a moment`, the background session isn’t ready yet, so press `Esc` again in a moment. * Press `Ctrl+C` twice to exit to your shell. -When Claude Code can’t reopen the conversation, it exits and prints a `claude --resume` command that resumes it. [Claude’s task list](</docs/en/interactive-mode#task-list>) moves to the background session with the conversation, so the checklist is intact when you return to that row. The row you pressed `←` from also keeps a bold, undimmed name after you move the selection with the arrow keys or the mouse, so you can tell which session you came from. If a tool is running when you press `←`, Claude Code waits up to about ten seconds for it to finish before backgrounding, and the response continues in the background session. Press `←` again to background immediately instead of waiting. When in-flight work can’t carry over to the background session, the `Background this session?` dialog appears first, the same as with `/background`. The ten-second limit doesn’t apply while [subagents](</docs/en/sub-agents>) are running. Claude Code keeps waiting so their work carries over, and shows a `Still backgrounding after the current tool` notice while it waits; press `←` again to background without waiting, which restarts the subagents from the beginning. Pressing `←` creates the session’s row even when the conversation has no messages yet, so `→` still returns to it. You can turn this shortcut off with the `leftArrowOpensAgents` setting in `/config`. +When Claude Code can’t reopen the conversation, it exits and prints a `claude --resume` command that resumes it. [Claude’s task list](</docs/en/interactive-mode#task-list>) moves to the background session with the conversation, so the checklist is intact when you return to that row. The row you pressed `←` from also keeps a bold, undimmed name after you move the selection with the arrow keys or the mouse, so you can tell which session you came from. If a tool is running when you press `←`, Claude Code waits up to about ten seconds for it to finish before backgrounding, and the response continues in the background session. Press `←` again to background immediately instead of waiting. When in-flight work can’t carry over to the background session, the `Background this session?` dialog appears first, the same as with `/background`. The ten-second limit doesn’t apply while [subagents](</docs/en/sub-agents>) are running. Claude Code keeps waiting so their work carries over, and shows a `Still backgrounding after the current tool` notice while it waits; press `←` again to background without waiting, which restarts the subagents from the beginning. Claude Code doesn’t background the session while you have unsent text in the prompt input, because the text stays in your terminal’s input box and wouldn’t move to the background session. If you type into the input while Claude Code waits to background the session, it cancels the switch with `Backgrounding cancelled — you have unsent text in the input. Send it or clear it, then press ← again.` Pressing `←` creates the session’s row even when the conversation has no messages yet, so `→` still returns to it. You can turn this shortcut off with the `leftArrowOpensAgents` setting in `/config`. ### @@ -169,7 +169,13 @@ * Press `Ctrl+R` to rename a session * Press `Enter` on a group header to collapse it -To remove a session from the list, press `Ctrl+X` to stop it and `Ctrl+X` again within two seconds to delete it. Pressing `Ctrl+X` on a group header deletes every session in that group after confirmation. Deleting removes the session from agent view. If Claude created a worktree for the session, deleting removes that worktree too, including any uncommitted changes in it, so commit work you want to keep first. A worktree you created yourself and started the session inside is left in place. The conversation transcript stays on your local machine and remains available through `claude --resume`. Deleting never removes a worktree with commits that aren’t pushed anywhere, or one that another running session claims or has locked. Claude Code keeps the worktree and the session, and the footer names the kept path and the reason. Push the commits, or close the other session, then delete again. When a delete is refused, the session’s row shows `not deleted` with the reason, and a worktree that couldn’t be removed is reported with the underlying git error. A worktree that git no longer recognizes, for example one removed from git’s records by `git worktree prune`, doesn’t block deletion: the session is deleted, the worktree directory is left untouched on disk, and the footer names its path. Deleting also clears the session from the supervisor’s session list, whether you delete with `Ctrl+X` or with `claude rm` from the shell, so the removal persists across supervisor restarts. To bring a session back on Claude Code v2.1.212 or later, type `/resume` in the dispatch input. A picker opens with past sessions of the repository you opened agent view from, newest first, including sessions you deleted from the list; sessions that already have a row aren’t listed. `↑`/`↓` move the selection, `Enter` resumes the selected session as a background session so it rejoins the list as a row, and `Esc` closes the picker. The picker opens only for a bare `/resume`. A targeted, scoped, or restricted resume can’t be served by the picker, so agent view shows the `attach to a session to run it` hint instead when: +To remove a session from the list, press `Ctrl+X` to stop it and `Ctrl+X` again within two seconds to delete it. Pressing `Ctrl+X` on a group header deletes every session in that group after confirmation. The second press deletes the session even when the stop attempt fails, for example because the background service isn’t responding: the confirmation stays active for another two seconds, and the delete ends the session’s process itself. Press `Esc` to dismiss the confirmation without deleting. Deleting removes the session from agent view. If Claude created a worktree for the session, deleting removes that worktree too, including any uncommitted changes in it, so commit work you want to keep first. A worktree you created yourself and started the session inside is left in place. The conversation transcript stays on your local machine and remains available through `claude --resume`. Deleting never removes a worktree with commits that aren’t pushed anywhere, or one that another running session claims or has locked. Claude Code keeps the worktree and the session, and the footer names the kept path and the reason. Push the commits, or close the other session, then delete again. When a delete is refused, the session’s row shows `not deleted` with the reason, and a worktree that couldn’t be removed is reported with the underlying git error. A worktree that git no longer recognizes, for example one removed from git’s records by `git worktree prune`, doesn’t block deletion: the session is deleted, the worktree directory is left untouched on disk, and the footer names its path. You can also delete a session whose worktree directory doesn’t belong to any git repository, for example because the repository was deleted after the session started, or because a [WorktreeCreate hook](</docs/en/hooks#worktreecreate>) created the directory outside any git repository. What happens to the directory depends on what remains in it and whether another session references it: + + * If the directory is already gone, Claude Code deletes the session immediately. + * When files remain in it, no repository can verify them, so agent view asks for the `Ctrl+X` double-press as the confirmation to discard those files. For a worktree Claude Code created with git, the delete then removes the directory and everything in it. For a hook-created directory, Claude Code runs your [`WorktreeRemove` hook](</docs/en/hooks#worktreeremove>) instead; without one, it refuses the delete and keeps the session. `claude rm` keeps the session and worktree in every case and names the reason. + * Either way, Claude Code keeps a directory that another finished session’s records also name, since its files may be that session’s work. + +Deleting also clears the session from the supervisor’s session list, whether you delete with `Ctrl+X` or with `claude rm` from the shell, so the removal persists across supervisor restarts. To bring a session back on Claude Code v2.1.212 or later, type `/resume` in the dispatch input. A picker opens with past sessions of the repository you opened agent view from, newest first, including sessions you deleted from the list; sessions that already have a row aren’t listed. `↑`/`↓` move the selection, `Enter` resumes the selected session as a background session so it rejoins the list as a row, and `Esc` closes the picker. The picker opens only for a bare `/resume`. A targeted, scoped, or restricted resume can’t be served by the picker, so agent view shows the `attach to a session to run it` hint instead when: * `/resume` names an id or a search term * the view is scoped with `--cwd` @@ -297,7 +303,13 @@ Copy the session with /fork -Run `/fork` to copy the current conversation into a new background session while the original keeps running. The copy starts with everything in the conversation up to that point, plus the working directory, model, permission mode, effort level, and any directories or “don’t ask again” permission grants you added during the session, and appears as its own row in agent view. From that moment the two sessions are independent: what the copy does never reaches the original conversation. Requires Claude Code v2.1.212 or later; on v2.1.161 through v2.1.211, `/fork` starts a [forked subagent](</docs/en/sub-agents#fork-the-current-conversation>) instead, which is now `/subtask`. When agent view is turned off, `/fork` keeps the forked-subagent behavior and `/subtask` isn’t available. Pass a prompt such as `/fork open a draft pull request with the work so far` and the copy starts working on it immediately. Without a prompt the copy waits for its first instruction: select its row in `claude agents` and press `Space` to send one, or run `claude attach <id>`. The selected row shows `space to send it a prompt` while it waits. Like any dispatched session, the copy moves into its own worktree before editing files. When the current session is itself running inside a linked [worktree](</docs/en/worktrees>) that has a main working tree to return to, the copy runs in that main working tree, so the two sessions don’t edit the same checkout. In a bare-repository layout there is no main working tree, so the copy stays where it is and the `/fork` confirmation says it edits the same checkout. Sessions started with launch flags the copy wouldn’t inherit, such as a replaced system prompt or a `--tools` allowlist, can’t be forked; Claude Code says so instead of making a partial copy. A session dispatched from agent view forks normally: the copy is launched with the same [agent definition](</docs/en/sub-agents>) and appended instructions as the session it came from. +Run `/fork` to copy the current conversation into a new background session while the original keeps running. The copy starts with everything in the conversation up to that point, plus the working directory, model, permission mode, effort level, and any directories or “don’t ask again” permission grants you added during the session, and appears as its own row in agent view. From that moment the two sessions are independent: what the copy does never reaches the original conversation. Requires Claude Code v2.1.212 or later; on v2.1.161 through v2.1.211, `/fork` starts a [forked subagent](</docs/en/sub-agents#fork-the-current-conversation>) instead, which is now `/subtask`. When agent view is turned off, `/fork` keeps the forked-subagent behavior and `/subtask` isn’t available. Pass a prompt such as `/fork open a draft pull request with the work so far` and the copy starts working on it immediately. Without a prompt the copy waits for its first instruction: select its row in `claude agents` and press `Space` to send one, or run `claude attach <id>`. The selected row shows `space to send it a prompt` while it waits. The `/fork` confirmation is one line showing the copy’s state, such as `session running`, the name of its agent-view row, and its session ID for `claude attach`. Click the name to switch into the copy: this session moves to the background, the same as pressing `←`, and agent view opens the copy’s session. The checkout the copy edits depends on where the current session is running, and the confirmation names the location whenever the copy edits an existing checkout: + + * Like any dispatched session, the copy moves into its own worktree before editing files. In that case the confirmation doesn’t mention where the copy runs. + * When the current session is itself running inside a linked [worktree](</docs/en/worktrees>) that has a main working tree to return to, the copy runs in that main working tree, so the two sessions don’t edit the same checkout. The confirmation ends with `runs in the origin tree`. + * In a bare-repository layout there is no main working tree, so the copy stays where it is, and the confirmation ends with `edits this checkout`. The same note appears when worktree isolation is turned off, because the copy then edits the files you have open. + +Sessions started with launch flags the copy wouldn’t inherit, such as a replaced system prompt or a `--tools` allowlist, can’t be forked; Claude Code says so instead of making a partial copy. A session dispatched from agent view forks normally: the copy is launched with the same [agent definition](</docs/en/sub-agents>) and appended instructions as the session it came from. #### @@ -330,7 +342,7 @@ claude --agent code-reviewer --bg "address review comments on PR 1234" -If the name doesn’t match any of your subagents, the launch fails: Claude Code prints a `no agent named` warning and still reports the session as backgrounded, but the session exits immediately with an `--agent '<name>' not found` error. Before v2.1.191, Claude Code ran the session with the default agent instead. Pass `--name` to set the session’s display name in agent view instead of the auto-generated one: +If the name doesn’t match any of your subagents, the launch fails: Claude Code prints a `no agent named` warning and still reports the session as backgrounded, but the session exits immediately with an `--agent '<name>' not found` error. Before v2.1.191, Claude Code ran the session with the default agent instead. When the backgrounded session later resumes or restarts, Claude Code restores the agent’s system prompt and tool restrictions. It searches the session’s own directory for the agent first, provided you’ve [trusted that workspace](</docs/en/permissions#project-allow-rules-and-workspace-trust>), so a project-scoped agent still loads when the session is resumed from another directory. If the agent no longer exists, the session continues with the default tools and system prompt and its transcript opens with a [warning naming the agent](</docs/en/errors#session-agent-no-longer-available>). Pass `--name` to set the session’s display name in agent view instead of the auto-generated one: claude --bg --name "flaky-test-fix" "investigate the flaky SettingsChangeDetector test" @@ -379,6 +391,7 @@ * Deleting in agent view with `Ctrl+X` twice removes the worktree, including any uncommitted changes, so commit the changes you want to keep first. * Deleting from the shell with `claude rm` keeps a worktree that has uncommitted changes, along with its session row. * Neither path removes a worktree with commits that aren’t pushed anywhere: the worktree is kept together with its session and the output names the kept path and the reason. + * When the session’s worktree directory doesn’t belong to any git repository, because the repository was deleted later or a hook created the directory outside one, deletion depends on what remains in the directory and which path you use; Organize the list covers which path removes, keeps, or refuses the delete. * A worktree you created yourself and started the session inside is left in place either way. To find a session’s worktree path, peek the session or attach and check its working directory. A [subagent](</docs/en/sub-agents>) the background session spawns inherits the session’s working directory, so its file edits land in the session’s worktree rather than your working copy. To give a subagent its own separate worktree instead, set [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>) in its frontmatter or pass `isolation: "worktree"` when spawning it. A background session that isolated its code changes in a worktree also commits, pushes its own branch, and opens a draft pull request without stopping to ask. The `#N` label appears on its row when the pull request opens. It never pushes to `main` or `master`, never force-pushes or merges, and it skips the pull request when you told it not to open one or the repository has no remote. A session editing a checkout it didn’t isolate itself still asks before committing or switching branches. This applies when isolation is set to `"none"`, when the worktree move failed, or when the session started inside a worktree that already existed. @@ -494,7 +507,7 @@ * The supervisor was started from an environment with the same gateway. The supervisor captures its environment from the first shell that opens agent view or dispatches a background session, so starting from the gateway shell gives it that environment. * The session is dispatched into the directory you’re dispatching from, or is your own session backgrounded with `←` or `/background`. Dispatching into a different directory with `@repo` or `--cwd` doesn’t carry the shell’s gateway; that project’s `settings.json` `env` block supplies the endpoint instead. -When the supervisor’s environment carries a different gateway or none, the worker keeps your stored credentials against the default endpoint instead of mixing one environment’s credential with another’s endpoint. The forwarded endpoint applies only to that live process and is never written to disk. When the supervisor stops an idle session and you later wake it by attaching, peeking, or replying, your environment’s gateway is forwarded again under the same conditions as a fresh dispatch. Waking a session from a shell without the gateway restarts it against your settings and stored credentials instead. Each background session is its own Claude Code process, managed by the supervisor rather than tied to your terminal. A session that’s actively working, waiting for your input, or has a terminal attached keeps its process running. The supervisor counts a running background shell command, subagent, dynamic workflow, or monitor as active work, so a long-running process such as a dev server keeps the session alive. Once a session finishes and sits unattached for about an hour, the supervisor stops its process to free resources. A session you have pinned with `Ctrl+T` is exempt and keeps its process running while idle. The transcript and state stay on disk either way, and the next time you attach, peek, or reply to a stopped session, the supervisor starts a fresh process from where it left off. When every session has finished and no terminal is connected, the supervisor itself exits and starts again the next time you need it. The supervisor also restarts a session whose process exits unexpectedly, with three safeguards so a restart never overrides a stop or acts on stale input: +When the supervisor’s environment carries a different gateway or none, the worker keeps your stored credentials against the default endpoint instead of mixing one environment’s credential with another’s endpoint. The forwarded endpoint applies only to that live process and is never written to disk. When the supervisor stops an idle session and you later wake it by attaching, peeking, or replying, your environment’s gateway is forwarded again under the same conditions as a fresh dispatch. Waking a session from a shell without the gateway restarts it against your settings and stored credentials instead. Each background session is its own Claude Code process, managed by the supervisor rather than tied to your terminal. A session that’s actively working, waiting for your input, or has a terminal attached keeps its process running. The supervisor counts a running background shell command, subagent, dynamic workflow, or monitor as active work, so a long-running process such as a dev server keeps the session alive. Once a session finishes and sits unattached for about an hour, the supervisor stops its process to free resources. A session you have pinned with `Ctrl+T` is exempt and keeps its process running while idle. The transcript and state stay on disk either way, and the next time you attach, peek, or reply to a stopped session, the supervisor starts a fresh process from where it left off. When every session has finished and no terminal is connected, the supervisor itself exits and starts again the next time you need it. This also applies to a conversation you backgrounded with `←` or `/background` and then left idle with nothing running. The supervisor also restarts a session whose process exits unexpectedly, with three safeguards so a restart never overrides a stop or acts on stale input: * A session whose state on disk already shows it as done, failed, or stopped isn’t restarted, unless a reply you sent is still waiting to be delivered. * Ending the process of a session you backgrounded with `←` or `/background` yourself, for example with `kill`, marks the session stopped instead of restarting it. A session dispatched with a task, from the agent view input or `claude --bg`, is still restarted so the dispatched work completes. @@ -613,7 +626,7 @@ claude daemon stop --any --keep-workers -The new supervisor reconnects to the running sessions. Without `--keep-workers`, the command ends the background sessions too. The `--any` flag confirms you want to stop a supervisor that started on demand rather than as an installed service, which is the default. A supervisor that starts but can’t accept connections exits and releases its lock on its own, so the next `claude agents` starts a fresh one without this manual stop. The steps above apply when a running supervisor stalls. On Windows, if the supervisor doesn’t respond to the stop request, the command prints its process ID. End that process with `taskkill /PID <pid>` to finish the recovery. Background sessions are still preserved when you passed `--keep-workers`. +The new supervisor reconnects to the running sessions. Without `--keep-workers`, the command ends the background sessions too. The `--any` flag confirms you want to stop a supervisor that started on demand rather than as an installed service, which is the default. A supervisor that starts but can’t accept connections exits and releases its lock on its own, so the next `claude agents` starts a fresh one without this manual stop. The steps above apply when a running supervisor stalls. If the command instead exits saying the recorded process couldn’t be verified as the supervisor, check the reported process ID: if it’s a supervisor you own, stop it yourself, then delete `~/.claude/daemon.lock` so the next `claude agents` starts fresh. On Windows, if the supervisor doesn’t respond to the stop request, the command prints its process ID. End that process with `taskkill /PID <pid>` to finish the recovery. Background sessions are still preserved when you passed `--keep-workers`. ### @@ -693,8 +706,19 @@ Version| Change ---|--- +v2.1.219| With [vim editor mode](</docs/en/interactive-mode#vim-editor-mode>) on, pressing `←` on an empty prompt opens agent view from NORMAL mode as well as INSERT, and the footer’s `←` hint shows in NORMAL mode; before this release the gesture and hint were INSERT-only, and in NORMAL mode `←` on an empty prompt did nothing. Typing into the input while Claude Code waits to background the session cancels the switch with `Backgrounding cancelled — you have unsent text in the input. Send it or clear it, then press ← again.` so a typed draft isn’t lost. v2.1.218| Pressing `←` within two seconds of a deletion that emptied the prompt, or of moving through prompt history, shows `Press ← again to open agents`, or `Press ← again to go back to agents` in an attached session, and switches only on a second press at least a second later; before this release the press switched immediately. A `←` that arrives inside pasted or scripted input no longer triggers the switch. Backgrounding a foreground session with `←` shows `Your conversation moved to the background` above the list, and `Esc` at the root of agent view returns to that conversation instead of exiting to the shell, with double `Ctrl+C` remaining the exit; if the conversation can’t be reopened, Claude Code exits and prints a `claude --resume` command for it. On Windows, a `←` pressed within about half a second of attaching shows `Ambiguous ←, press again to detach` and detaches on the second press. -v2.1.216| A background session where `/install-github-app`, the [`/mcp`](</docs/en/mcp>) settings list, or an MCP authentication action needs a terminal appears under `Needs input` with a row such as `open this session to manage MCP servers` until you attach; run the command again to continue. From v2.1.208 through v2.1.215 the command was refused with a message and no `Needs input` row. +v2.1.217| The pull request badge on a session’s row renders as a hyperlink even when Claude Code can’t detect terminal hyperlink support, for example over SSH or tmux; set [`FORCE_HYPERLINK=0`](</docs/en/env-vars>) to render it as plain text. Before this release, the badge rendered as plain text when support wasn’t detected. +v2.1.216| `/fork`: the confirmation is one line, showing the copy’s state, the name of its agent-view row, and its session ID for `claude attach`, ending with `runs in the origin tree` or `edits this checkout` only when the copy runs in the main working tree or edits the checkout you have open. Clicking the name backgrounds this session and opens agent view in the copy’s session. The confirmation no longer restates the copy’s inherited permission mode; earlier versions printed a multi-line confirmation with no clickable name. + +Needs input: `/install-github-app` and the `/mcp` settings list, run while nobody is attached, show the session under `Needs input` with a row naming the command, and attaching and re-running the command continues; from v2.1.208 through v2.1.215 they were refused outright in that state. + +`--agent` restore: resuming or restarting a backgrounded `--agent` session restores the agent’s system prompt and tool restrictions, searching the session’s own directory for the agent first, when its workspace is trusted; a session whose agent no longer exists continues with the default tools and system prompt and opens with a visible warning, instead of silently reverting to the default agent. + +`Ctrl+X`: pressing it twice deletes a session even when the stop attempt fails, instead of a failed stop cancelling the pending delete, and a deleted session whose worker process had died no longer reappears on the next refresh. + +Worktree deletion: a session whose worktree directory belongs to no git repository can be deleted; before this release every attempt to delete such a session was refused. A directory that’s already gone clears immediately. The agent view double-press removes a directory that still has files, running your `WorktreeRemove` hook for a hook-created directory, unless another session’s records also name it. `claude rm` keeps such a directory whenever files remain. +v2.1.214| A session backgrounded with `←` or `/background` and left idle with nothing running has its process stopped like any other idle session, instead of keeping its process and the background service running indefinitely. A completed session can be removed with `claude rm` or from agent view after the background service has gone idle, and a session that entered a worktree after being dispatched from a directory that isn’t a git repository, such as a multi-repo workspace folder, can be deleted from agent view when the worktree itself belongs to a git repository, because the cleanup is resolved from the worktree instead of the directory the session was dispatched from; both removals were refused on every attempt before. Reopening a stopped session restores its saved conversation even when a folder in the transcript store can’t be read. v2.1.213| `/install-github-app`, the [`/mcp`](</docs/en/mcp>) settings list, and MCP authentication actions work in a background session while a terminal is attached, and are refused only when nobody is attached, with a message telling you to attach and run the command again; from v2.1.208 through v2.1.212 they were refused even with a terminal attached. v2.1.212| `/fork` in an interactive session copies the conversation into a new background session that appears as its own row, named after the session it came from or, for a prompted fork of an unnamed session, after the fork prompt, while the original keeps running; the earlier forked-subagent behavior of `/fork` moved to `/subtask`. With agent view turned off, `/fork` keeps the forked-subagent behavior. A focused row that is waiting for its first prompt shows `space to send it a prompt`. `Ctrl+J` inserts a newline in the dispatch input on terminals with extended key reporting, where the keypress was previously ignored, and the `?` overlay lists the shortcut. The `←` footer hint in an interactive session briefly shows `N done` when a background session finishes while none need your input. Typing a bare `/resume` in agent view opens a picker of past sessions of the repository you opened agent view from, including sessions deleted from the list, and picking one resumes it as a background session; before this release `/resume` wasn’t available in agent view and deleted sessions were reachable only with `claude --resume` or `/resume` from an interactive session. Targeted, scoped, and restricted forms keep the `attach to a session to run it` hint that earlier versions showed for every form. Sessions waiting on a sandbox network-host prompt, an MCP input request, or a managed-settings prompt show as `Needs input` instead of `Working`, in agent view and in `claude agents --json`, and a question from Claude reports `waitingFor: input needed` instead of `permission prompt`. Attaching to a session whose process has stopped shows its transcript formatted the way the live session renders it, instead of as raw text. A stopped session whose transcript is in an unexpected place resumes from it via a last-resort scan of your saved transcripts, and opening a row that has no saved transcript shows `Press enter again to restart this session fresh`, restarting it fresh on the second press; v2.1.211 showed the refusal with no way to restart from agent view. v2.1.211| Waking a stopped session by attaching, peeking, or replying from the directory it runs in forwards your shell’s gateway `ANTHROPIC_BASE_URL` again, under the same conditions as a fresh dispatch, so a session authenticated through a gateway `ANTHROPIC_AUTH_TOKEN` resumes on the gateway instead of reporting `Not logged in`. Attaching to a stopped session that was backgrounded from another conversation before its first response finished is refused with `This session has no saved transcript` instead of silently starting a blank conversation under the same session id; opening the same row from agent view showed the refusal in the footer. Ending the process of a `←` or `/background` session from outside Claude Code marks it stopped instead of the supervisor restarting it, a stop already recorded on disk is honored unless a reply you sent is still waiting to be delivered, a session restarted after a crash is told it was restarted, and a restarted `←` or `/background` session doesn’t resume an interrupted response older than about an hour. A session-naming reply that answers or refuses the prompt instead of labeling it, such as for a prompt that’s mostly a link, is discarded and the row keeps a name taken from the prompt text. Deleting a session whose worktree git no longer recognizes succeeds, leaving the worktree directory on disk and naming its path, instead of every attempt being refused. A refused delete shows the reason on the session’s row, including the underlying git error when the worktree couldn’t be removed, instead of the row silently reappearing.
modified Best practices for Claude Code View current →
--- a/best-practices.md +++ b/best-practices.md @@ -47,7 +47,7 @@ Explore -Enter plan mode. Claude reads files and answers questions without making changes. +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) @@ -71,7 +71,7 @@ Implement -Switch out of plan mode and let Claude code, verifying against its plan. +Switch out of plan mode by approving the plan or pressing `Shift+Tab`, then let Claude code, verifying against its plan. claude (default mode) @@ -219,7 +219,7 @@ Connect MCP servers -Run `claude mcp add` to connect external tools like Notion, Figma, or your database. +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. @@ -514,7 +514,7 @@ Generate a task list -Have Claude list all files that need migrating (e.g., `list all 2,000 Python files that need migrating`) +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
modified Claude Code changelog View current →
--- a/changelog.md +++ b/changelog.md @@ -1,4 +1,50 @@ This page is generated from the [CHANGELOG.md on GitHub](<https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md>). Run `claude --version` to check your installed version. + +​ + +2.1.221 + +August 4, 2026 + + * [VSCode] Added Focus view: a chat-menu toggle that hides tool activity behind an expandable per-turn summary with a live running-tool indicator, toggled with `Ctrl+Alt+F` or the “Claude Code: Toggle Focus view” command + * Added `mode: "mask"` for sandbox credential files on Linux and WSL — sandboxed commands read a sentinel copy (the whole file, or just the spans captured by an `extract` regex) while the sandbox proxy substitutes the real value on egress; on macOS file masking falls back to `deny` + * Added warnings to `claude plugin validate` when a marketplace or plugin name would be rejected by Claude Desktop’s managed marketplace sync + * Added a `prompt-audit` subcommand to the `claude-api` skill for auditing prompts and tool descriptions for patterns written for older models + * Fixed a Bash tool permission-check bypass where zsh could execute hidden commands in `[[ ]]` regex conditionals; affected commands now prompt for permission + * Fixed PowerShell permission checks mishandling paths containing quote characters on Windows; such paths now prompt for approval + * Fixed the thinking toggle having no effect for the rest of a session that started with thinking off; disabling an MCP server mid-connect no longer silently reverts + * Fixed MCP servers from `--mcp-config` not being connected before the first turn in print mode (`-p`), which made the model emit tool calls as literal text + * Fixed @-mentioned files being silently dropped when pressing Esc to retract a prompt and resubmitting it + * Fixed a crash when preparing API requests for SDK MCP tools named after built-in object properties such as `constructor` + * Fixed WebSearch failing with a 400 error at effort `xhigh`/`max` when thinking is disabled + * Fixed sandboxed large uploads failing with TLS errors through the sandbox proxy + * Fixed Team and Enterprise spend-limit message incorrectly blaming the org’s monthly limit instead of your individual spend limit + * Fixed Bedrock authentication with AWS SSO named profiles failing in desktop-managed sessions on Windows machines that set a stray `HOME` environment variable + * Fixed `CLAUDE_CODE_RESUME_INTERRUPTED_TURN=0` not disabling interrupted-turn auto-resume; falsy values are now honored + * Fixed a rare wake-from-sleep race where two Claude Code processes could both refresh the same MCP connector or WIF OAuth token at once, forcing re-authentication + * Fixed renaming a session from Claude Code Desktop or claude.ai not updating the CLI’s session name; session names from every rename surface are now sanitized + * Fixed plugin- and org-delivered skills named after terminal-only built-ins (e.g. `/help`, `/feedback`) being un-invocable in non-interactive sessions + * Fixed the “Plugins changed” notification lingering after plugins were reloaded instead of clearing + * Fixed Vim mode: the yank register now survives dialogs, history search, and the transcript view instead of being silently emptied + * Fixed Vim mode: undoing back to an empty prompt now arms the “press ← again” confirm before returning to the agent view + * Improved tool search on Google Vertex AI: re-enabled for Claude 4.5-generation and newer models + * Improved auto mode: permission checks for parallel tool calls are now cache-efficient, and switching modes while a check is pending reliably prompts instead of applying the stale result + * Reduced prompt-cache costs for auto-mode permission checks by reusing the cached conversation prefix across decisions + * Improved Stats panel to count cache tokens in its token totals, with a breakdown by input, output, cache read, and cache write + * Improved `/ultrareview` error messages when a repo shares no history with its base: a checkout with no branches is now refused up front with advice to create one, and refusal hints no longer suggest `git fetch --unshallow` on clones that are already complete + * Improved Windows startup: process creation times are now read via a native kernel32 call instead of spawning PowerShell, so endpoint security tools that gate `powershell.exe` no longer prompt + * Changed background sessions to commit and push to preserve work, open a draft PR only when the task calls for one, follow your CLAUDE.md git instructions, and always end by reporting where the work lives + * Changed `/plugin install` to refresh a stale marketplace catalog and retry before reporting a plugin not found + * Changed plugins installed from `/plugin` to activate immediately when safe, instead of always requiring `/reload-plugins` + * Changed plugins to accept `"."` as a `skills` path, and the root-level `SKILL.md` validation error now suggests using the plugin root + * Changed `/status` to show the session kind: `interactive`, or a background job that is `attached` or `unattended` + * Changed emoji autocomplete to accept common alternate shortcodes like `:thumbsup:`, `:thumbsdown:`, and `:love:` + * Changed sessions forked with `/fork` to create a new worktree of their own instead of working in the original session’s checkout + * Changed Claude in Chrome to close the browser tabs it opens once it no longer needs them + * Changed fast mode to report on the stream when usage credits run out mid-session, instead of failing silently + * Changed Monitor: a watch that exits without producing any output now says so instead of reporting “stream ended” + * Changed the Gateway `model` field validation: non-string values are rejected with a 400 instead of being forwarded + * Removed the repeated “Permission mode changed while the auto-mode classifier call was queued” notice from approval prompts ​
modified Commands View current →
--- a/commands.md +++ b/commands.md @@ -1,4 +1,4 @@ -Commands control Claude Code from inside a session. They provide a quick way to switch models, manage permissions, clear context, run a workflow, and more. Type `/` to see every command available to you, or type `/` followed by letters to filter. A command is only recognized at the start of your message. Text that follows the command name becomes its arguments. As of v2.1.199, [skills](</docs/en/skills#pass-arguments-to-skills>) are the exception: a skill invocation followed by more skills, such as `/skill-a /skill-b do XYZ`, loads every skill named at the start and passes the trailing text to each as arguments. Up to six skills can be chained. If you send a command while Claude is responding, it queues and runs after the current turn finishes. Some commands, such as `/status`, `/tasks`, and `/usage`, run immediately without interrupting the response. +Commands control Claude Code from inside a session. They provide a quick way to switch models, manage permissions, clear context, run a workflow, and more. Type `/` to see the commands available to you, or type `/` followed by letters to filter. A command is only recognized at the start of your message. Text that follows the command name becomes its arguments. As of v2.1.199, [skills](</docs/en/skills#pass-arguments-to-skills>) are the exception: a skill invocation followed by more skills, such as `/skill-a /skill-b do XYZ`, loads every skill named at the start and passes the trailing text to each as arguments. Up to six skills can be chained. If you send a command while Claude is responding, it queues and runs after the current turn finishes. Some commands, such as `/status`, `/tasks`, and `/usage`, run immediately without interrupting the response. ## @@ -63,7 +63,7 @@ `/focus`| Toggle the focus view, which shows only your last prompt, a one-line tool-call summary with edit diffstats, and the final response. As of v2.1.198, the tool-call summary also counts the subagents launched in the turn and collapses completed background-task notifications into a single count. The selection persists across sessions; set [`viewMode`](</docs/en/settings#available-settings>) in settings to override it. Only available in [fullscreen rendering](</docs/en/fullscreen>) `/fork [prompt]`| Copy the current conversation into a new [background session](</docs/en/agent-view#from-inside-a-session>) and keep working here. The copy starts with everything in this conversation up to now and runs as its own row in [agent view](</docs/en/agent-view>); the two sessions are independent from that point on. Pass a prompt and the copy starts working on it immediately; without one it waits in agent view for its first prompt. To hand a side task to a subagent whose result comes back into this conversation, use `/subtask`. To switch into a copy yourself, use `/branch`. Requires Claude Code v2.1.212 or later; on v2.1.161 through v2.1.211 `/fork` starts a [forked subagent](</docs/en/sub-agents#fork-the-current-conversation>) instead, and before v2.1.161 it is an alias for `/branch` unless forked subagents were enabled, by setting [`CLAUDE_CODE_FORK_SUBAGENT`](</docs/en/env-vars>) to `1` from v2.1.117 or by a server-side rollout. When [agent view is turned off](</docs/en/agent-view#turn-off-agent-view>), `/fork` keeps the forked-subagent behavior `/goal [condition|clear]`| Set a [goal](</docs/en/goal>): Claude keeps working across turns until the condition is met. With no argument, shows the current or most recently achieved goal. `clear`, `stop`, `off`, `reset`, `none`, or `cancel` removes an active goal early -`/heapdump`| Write a JavaScript heap snapshot and a memory breakdown to `~/Desktop`, or your home directory on Linux without a Desktop folder, for diagnosing high memory usage. The `.heapsnapshot` file contains your full conversation and credentials, so don’t share it. See [troubleshooting](</docs/en/troubleshooting#high-cpu-or-memory-usage>) +`/heapdump`| Write a JavaScript heap snapshot and a memory breakdown to `~/Desktop`, or your home directory on Linux without a Desktop folder, for diagnosing high memory usage. Attach only the `-diagnostics.json` file when reporting a memory issue; the `.heapsnapshot` contains your full conversation and credentials, so don’t share it. Doesn’t appear in the command menu; type it in full. See [what to do with the output](</docs/en/troubleshooting#high-cpu-or-memory-usage>) `/help`| Show help and available commands `/hooks`| View [hook](</docs/en/hooks>) configurations for tool events `/ide`| Manage IDE integrations and show status
modified Test iOS apps in the simulator View current →
--- a/desktop-ios-simulator.md +++ b/desktop-ios-simulator.md @@ -13,6 +13,7 @@ * Claude Desktop v1.24012.0 or later * A Mac, since Apple’s iOS Simulator runs only on macOS * [Xcode](<https://developer.apple.com/xcode/>) with the iOS platform installed, which provides the simulator devices. If Xcode lists no simulators yet, see The simulator pane says no simulators were found + * Use Xcode 26.x. The pane doesn’t yet work with Xcode 27, which replaces the Simulator app with Device Hub. If `xcode-select` points at Xcode 27 on your Mac, see The simulator pane fails with Xcode 27 On this page, “device” refers to a simulated iPhone or iPad, one of the same simulator devices you manage in Xcode under **Window → Devices and Simulators** , not physical hardware. @@ -136,7 +137,7 @@ Claude may not have recognized that you wanted to run or test the app, or the simulator tooling may be missing. Check the following: * State the goal explicitly, for example “run the app in the iOS Simulator and tap through the signup flow”. - * Confirm Xcode and the iOS Simulator are installed by launching the Simulator app on its own. + * Confirm Xcode and the iOS simulators are installed and that your Xcode version meets the requirements. * If your organization manages Claude Code, the simulator tools may be disabled by policy. * The simulator pane requires Claude Desktop v1.24012.0 or later. Open **Claude → Check for Updates** , then restart the app. @@ -146,7 +147,19 @@ The simulator pane says no simulators were found -Xcode is installed but has no iOS simulators to list. The simulator pane shows the setup steps to follow and checks them off as each one completes. To install the missing piece manually, download the iOS simulator runtime from Xcode’s settings, or run `xcodebuild -downloadPlatform iOS`. +If `xcode-select` points at Xcode 27, the pane can report no simulators even though devices exist; see The simulator pane fails with Xcode 27. Otherwise, Xcode is installed but has no iOS simulators to list. The simulator pane shows the setup steps to follow and checks them off as each one completes. To install the missing piece manually, download the iOS simulator runtime from Xcode’s settings, or run `xcodebuild -downloadPlatform iOS`. + +### + +​ + +The simulator pane fails with Xcode 27 + +The pane doesn’t yet work with Xcode 27, which replaces the Simulator app with Device Hub. With Xcode 27 selected, attaching a device fails, or the pane reports that no simulators were found even though devices exist. The pane uses whichever Xcode `xcode-select` points at. If Xcode 27 is your only install, install Xcode 26.x alongside it first. Then select the 26.x install by its path. For example, if it’s installed as `/Applications/Xcode-26.4.app`: + + sudo xcode-select -s /Applications/Xcode-26.4.app + +Run `xcode-select -p` to check which install is selected. ##
modified Speed up responses with fast mode View current →
--- a/fast-mode.md +++ b/fast-mode.md @@ -25,7 +25,15 @@ * A small `↯` icon appears next to the prompt while fast mode is active * Run `/fast` again at any time to check whether fast mode is on or off -When you disable fast mode with `/fast` again, you remain on Opus. The model does not revert to your previous model. To switch to a different model, use `/model`. When you switch to a model that doesn’t support fast mode, Claude Code turns fast mode off, except on Opus 4.7, where fast mode stays on and the API rejects the requests. Switching back to a supported Opus model turns it on again when your saved fast mode preference is on, the same preference a new session starts from by default; a model switch never turns fast mode on for a session whose saved preference is off. With per-session opt-in configured, switching back doesn’t turn fast mode on again; run `/fast` to re-enable it. Before v2.1.208, fast mode stayed off after you switched back until you ran `/fast` again. Whenever a model switch turns fast mode on or off, Claude Code shows a `Fast mode ON` or `Fast mode OFF` confirmation, and the `↯` icon appears while fast mode is on. This holds whether you switch with `/model`, with [`/config model=<model>`](</docs/en/settings>), or from a device connected through [Remote Control](</docs/en/remote-control>); before v2.1.218, switches through `/config model=<model>` or Remote Control changed fast mode without the confirmation. Opus 5 is the fast mode default in Claude Code v2.1.219 and later. Before v2.1.219, fast mode defaulted to Opus 4.8 on v2.1.154 through v2.1.218, and to Opus 4.7 on v2.1.142 through v2.1.153. +Opus 5 is the fast mode default in Claude Code v2.1.219 and later. Before v2.1.219, fast mode defaulted to Opus 4.8 on v2.1.154 through v2.1.218, and to Opus 4.7 on v2.1.142 through v2.1.153. When you disable fast mode with `/fast` again, you remain on Opus. The model does not revert to your previous model. To switch to a different model, use `/model`. + +### + +​ + +Switch models while fast mode is on + +When you switch to a model that doesn’t support fast mode, Claude Code turns fast mode off, except on Opus 4.7, where fast mode stays on and the API rejects the requests. Switching back to a supported Opus model turns it on again when your saved fast mode preference is on, the same preference a new session starts from by default; a model switch never turns fast mode on for a session whose saved preference is off. With per-session opt-in configured, switching back doesn’t turn fast mode on again; run `/fast` to re-enable it. Before v2.1.208, fast mode stayed off after you switched back until you ran `/fast` again. Whenever a model switch turns fast mode on or off, Claude Code shows a `Fast mode ON` or `Fast mode OFF` confirmation, and the `↯` icon appears while fast mode is on. This holds whether you switch with `/model`, with [`/config model=<model>`](</docs/en/settings>), or from a device connected through [Remote Control](</docs/en/remote-control>); before v2.1.218, switches through `/config model=<model>` or Remote Control changed fast mode without the confirmation. Claude Code resends the session’s fast mode status to devices connected through Remote Control after a model switch, a reconnection, or a failed availability check. ##
modified Glossary View current →
--- a/glossary.md +++ b/glossary.md @@ -74,7 +74,7 @@ Bare mode -A startup flag, `--bare`, that skips auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md. Only flags you pass explicitly take effect. Recommended for CI and scripted calls where you need identical behavior across machines regardless of local configuration. Learn more: [Start faster with bare mode](</docs/en/headless#start-faster-with-bare-mode>) +With `--bare`, Claude Code starts without loading hooks, skills, plugins, MCP servers, auto memory, or CLAUDE.md. Recommended for CI and scripted calls where you need the same result on every machine. Learn more: [Start faster with bare mode](</docs/en/headless#start-faster-with-bare-mode>) ###
modified Run Claude Code programmatically View current →
--- a/headless.md +++ b/headless.md @@ -28,11 +28,11 @@ Start faster with bare mode -Add `--bare` to reduce startup time by skipping auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md. Without it, `claude -p` loads the same [context](</docs/en/how-claude-code-works#the-context-window>) an interactive session would, including anything configured in the working directory or `~/.claude`. Bare mode is useful for CI and scripts where you need the same result on every machine. A hook in a teammate’s `~/.claude` or an MCP server in the project’s `.mcp.json` won’t run, because bare mode never reads them. Only flags you pass explicitly take effect. This example runs a one-off summarize task in bare mode and pre-approves the Read tool so the call completes without a permission prompt. Set `ANTHROPIC_API_KEY` before running it, because bare mode doesn’t use your subscription login: +Add `--bare` to reduce startup time by skipping auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md. Without it, `claude -p` loads the same [context](</docs/en/how-claude-code-works#the-context-window>) an interactive session would, including anything configured in the working directory or `~/.claude`. Bare mode is useful for CI and scripts where you need the same result on every machine. A hook in a teammate’s `~/.claude` or an MCP server in the project’s `.mcp.json` won’t run, because bare mode never reads them. This example runs a one-off summarize task in bare mode and pre-approves the Read tool so the call completes without a permission prompt. Set `ANTHROPIC_API_KEY` before running it, because bare mode doesn’t use your subscription login: claude --bare -p "Summarize README.md" --allowedTools "Read" -Bare mode skips OAuth and the system keychain, so Claude Code only sees credentials you pass explicitly. For the Anthropic API, set `ANTHROPIC_API_KEY` in the environment, with a key created in the [Claude Console](<https://platform.claude.com>), or supply an `apiKeyHelper` in the `--settings` JSON. Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry continue to read their own provider credentials as usual. In bare mode Claude has access to the Bash, file read, and file edit tools. Pass any context you need with a flag: +In bare mode, Claude Code never reads OAuth credentials or the system keychain. For the Anthropic API, set `ANTHROPIC_API_KEY` in the environment, with a key created in the [Claude Console](<https://platform.claude.com>), or supply an `apiKeyHelper` in the `--settings` JSON. Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry continue to read their own provider credentials as usual. In bare mode Claude has access to the Bash, file read, and file edit tools. Pass any context you need with a flag: To load| Use ---|--- @@ -58,7 +58,7 @@ Examples -These examples highlight common CLI patterns. Where a command names a file such as `auth.py` or `build-error.txt`, substitute a file from your own project. In CI or other scripted environments, add `--bare` so Claude Code ignores any local configuration on the host. +These examples highlight common CLI patterns. Where a command names a file such as `auth.py` or `build-error.txt`, substitute a file from your own project. In CI or other scripted environments, add `--bare` so Claude Code starts without loading the host’s hooks, plugins, auto memory, or `CLAUDE.md`. ###
modified Hooks reference View current →
--- a/hooks.md +++ b/hooks.md @@ -615,7 +615,7 @@ Exit code output -The exit code from your hook command tells Claude Code whether the action should proceed, be blocked, or be ignored. **Exit 0** means success. Claude Code parses stdout for JSON output fields. JSON output is only processed on exit 0. For most events, stdout is written to the debug log but not shown in the transcript. The exceptions are `UserPromptSubmit`, `UserPromptExpansion`, and `SessionStart`, where stdout is added as context that Claude can see and act on. **Exit 2** means a blocking error. Claude Code ignores stdout and any JSON in it. Instead, stderr text is fed back to Claude as an error message. The effect depends on the event: `PreToolUse` blocks the tool call, `UserPromptSubmit` rejects the prompt, and so on. See exit code 2 behavior for the full list. A hook that exits 2 while printing JSON that fails JSON output schema validation still blocks: Claude Code uses stderr as the blocking reason and records the validation failure in the debug log. Before v2.1.214, Claude Code treated that combination as a non-blocking error and the action proceeded. **Any other exit code** is a non-blocking error for most hook events. The transcript shows a `<hook name> hook error` notice followed by the first line of stderr, so you can identify the cause without `--debug`. Execution continues and the full stderr is written to the debug log. For example, a hook command script that blocks dangerous Bash commands: +The exit code from your hook command tells Claude Code whether the action should proceed, be blocked, or be ignored. **Exit 0** means success. Claude Code parses stdout for JSON output fields. JSON output is only processed on exit 0. For most events, stdout is written to the debug log but not shown in the transcript. The exceptions are `UserPromptSubmit`, `UserPromptExpansion`, and `SessionStart`, where stdout is added as context that Claude can see and act on. **Exit 2** means a blocking error. Claude Code ignores stdout and any JSON in it. Instead, stderr text is fed back to Claude as an error message. The effect depends on the event: `PreToolUse` blocks the tool call, `UserPromptSubmit` rejects the prompt, and so on. See exit code 2 behavior for the full list. A hook that exits 2 while printing JSON that fails JSON output schema validation still blocks: Claude Code uses stderr as the blocking reason and records the validation failure in the debug log. Before v2.1.214, Claude Code treated that combination as a non-blocking error and the action proceeded. **Any other exit code** is a non-blocking error for most hook events. The action proceeds, and the transcript shows a `<hook name> hook error` notice followed by the first line of stderr, prefixed with `Failed with non-blocking status code:`. To capture the full stderr, enable debug logging. For example, a hook command script that blocks dangerous Bash commands: #!/bin/bash # Reads JSON input from stdin, checks the command
modified Automate actions with hooks View current →
--- a/hooks-guide.md +++ b/hooks-guide.md @@ -129,6 +129,14 @@ } } +If no notification appears + +`notify-send` needs a desktop notification daemon, which headless servers, SSH sessions, and most containers don’t have. Test the command directly first: + + notify-send 'Claude Code' 'test' + +If the command isn’t found, install the `libnotify-bin` package on Debian and Ubuntu, or your distribution’s equivalent. + { "hooks": { "Notification": [ @@ -144,6 +152,10 @@ ] } } + +If no dialog appears + +This command opens a dialog box rather than a notification in the corner of your screen, so the dialog can open behind your terminal window. Test the command directly in PowerShell first. If you run Claude Code inside WSL, `powershell.exe` must be available on your `PATH` through Windows interop. The empty `matcher` fires on all notification types. To fire only on specific events, set it to one of these values: @@ -184,7 +196,7 @@ } } -To test the hook, ask Claude to add a line with single-quoted strings to a JavaScript file, then open the file: with Prettier’s default settings, the hook rewrites them to double quotes. On Claude Code v2.1.191 or later you can also write the matcher as `Edit,Write`, since `|` and `,` are interchangeable list separators for tool-name matchers on those versions. +To test the hook, ask Claude to add a line with single-quoted strings to a JavaScript file, then open the file: with Prettier’s default settings, the hook rewrites them to double quotes. On Claude Code v2.1.191 or later you can also write the matcher as `Edit,Write`, since `|` and `,` are interchangeable list separators for tool-name matchers on those versions. When the hook succeeds, Claude Code shows nothing in the conversation. To confirm the hook ran, check that the edited file is reformatted, or see Debug techniques. The Bash examples on this page use `jq` for JSON parsing. Install it with `brew install jq` on macOS, `apt-get install jq` on Debian and Ubuntu, or see [`jq` downloads](<https://jqlang.org/download/>). @@ -540,7 +552,9 @@ * **Exit 0** : the hook reports no objection and the action proceeds normally. For a `PreToolUse` hook this doesn’t approve the tool call: the normal [permission flow](</docs/en/permissions>) still applies. For `UserPromptSubmit`, `UserPromptExpansion`, and `SessionStart` hooks, anything you write to stdout is added to Claude’s context. * **Exit 2** : Claude Code blocks the action. Write a reason to stderr, and Claude receives it as feedback so it can adjust. Some events can’t be blocked: for `SessionStart`, `Setup`, `Notification`, and others, exit 2 shows stderr to the user and execution continues. See [exit code 2 behavior per event](</docs/en/hooks#exit-code-2-behavior-per-event>) for the full list. - * **Any other exit code** : the action proceeds. The transcript shows a `<hook name> hook error` notice followed by the first line of stderr; the full stderr goes to the [debug log](</docs/en/hooks#debug-hooks>). + * **Any other exit code** : the action proceeds + * The transcript shows a `<hook name> hook error` notice, then the first line of stderr prefixed with `Failed with non-blocking status code:` + * To capture the full stderr, enable [debug logging](</docs/en/hooks#debug-hooks>) with `claude --debug` or by running `/debug` mid-session #### @@ -956,7 +970,14 @@ Debug techniques -The transcript view, toggled with `Ctrl+O`, shows a one-line summary for each hook that fired: success is silent, blocking errors show stderr, and non-blocking errors show a `<hook name> hook error` notice followed by the first line of stderr. For full execution details including which hooks matched, their exit codes, stdout, and stderr, read the debug log. Start Claude Code with `claude --debug-file /tmp/claude.log` to write to a known path, then `tail -f /tmp/claude.log` in another terminal. If you started without that flag, run `/debug` mid-session to enable logging and find the log path. +Press `Ctrl+O` to open the transcript view to check the outcome of a hook run: + + * After a successful run, where the hook exited 0, you see nothing + * To confirm a hook ran, check for its effect, like a reformatted file, or turn on debug logging as described below and trigger the hook again + * After a blocking error, where the hook exited 2 and Claude Code stopped the action, you see the hook’s stderr + * After a non-blocking error, where the hook exited with any other code and the action proceeded, you see a `<hook name> hook error` notice followed by the first line of stderr, prefixed with `Failed with non-blocking status code:` + +For full execution details including which hooks matched, their exit codes, stdout, and stderr, read the debug log. Start Claude Code with `claude --debug-file /tmp/claude.log` to write to a known path, then `tail -f /tmp/claude.log` in another terminal. If you started without that flag, run `/debug` mid-session to enable logging and find the log path. ##
modified Claude Code settings View current →
--- a/settings.md +++ b/settings.md @@ -429,8 +429,8 @@ `filesystem.disabled`| Skip filesystem isolation while keeping network isolation: sandboxed commands get unrestricted read and write access to the host filesystem, and network egress stays confined to `network.allowedDomains`. Only honored from user, managed, or CLI `--settings` settings. Default: false. Requires Claude Code v2.1.216 or later. See [Disable filesystem isolation](</docs/en/sandboxing#disable-filesystem-isolation>) for which sources can set it and what changes when isolation is off| `true` `credentials.files`| Credential files or directories that sandboxed commands cannot read. Applies the same read block as `filesystem.denyRead`; the separate key keeps credential paths grouped with `credentials.envVars` and apart from general filesystem rules. Each entry is `{ "path": "...", "mode": "deny" }`, and `deny` is the only supported mode for files. Paths use the same prefixes as `filesystem.*` settings. Arrays are merged across all settings scopes. Requires Claude Code v2.1.187 or later.| `[{ "path": "~/.aws/credentials", "mode": "deny" }]` `credentials.envVars`| Environment variables to [protect from sandboxed commands](</docs/en/sandboxing#protect-credentials>). Each entry has a `name` and a `mode`; the name must start with a letter or underscore and contain only letters, digits, and underscores. `deny` removes the variable from the environment of sandboxed commands. Requires Claude Code v2.1.187 or later. `mask` replaces the variable with a per-session sentinel value inside the sandbox while the sandbox proxy substitutes the real value on outbound requests to that entry’s `injectHosts`; it requires `network.tlsTerminate` and Claude Code v2.1.199 or later. `mask` entries are only honored from user, managed, or CLI `--settings` settings, not from `.claude/settings.json` or `.claude/settings.local.json`. Arrays are merged across all settings scopes, and `deny` takes precedence when the same variable appears with both modes.| `[{ "name": "GITHUB_TOKEN", "mode": "deny" }]` -`credentials.envVars[].injectHosts`| Hosts where the sandbox proxy substitutes the real value of a `mask` entry. Each host must also be covered by `network.allowedDomains`, either exactly or by a wildcard. When unset, the proxy substitutes the value on requests to every host in `network.allowedDomains`. Accepted but ignored when `mode` is `deny`. Requires Claude Code v2.1.199 or later. | `["api.github.com"]` -`credentials.allowPlaintextInject`| Allow `mask` substitution on plain HTTP requests as well as TLS-terminated HTTPS. On plain HTTP the upstream identity is unverified and the credential travels in cleartext, so leave this off outside trusted test networks. Only honored from user, managed, or CLI `--settings` settings, not from `.claude/settings.json` or `.claude/settings.local.json`. Default: false. Requires Claude Code v2.1.199 or later. | `true` +`credentials.envVars[].injectHosts`| Hosts where the sandbox proxy substitutes the real value of a `mask` entry. Each host must also be covered by `network.allowedDomains`, either exactly or by a wildcard. When unset, the proxy substitutes the value on requests to every host in `network.allowedDomains`. Accepted but ignored when `mode` is `deny`. Requires Claude Code v2.1.199 or later.| `["api.github.com"]` +`credentials.allowPlaintextInject`| Allow `mask` substitution on plain HTTP requests as well as TLS-terminated HTTPS. On plain HTTP the upstream identity is unverified and the credential travels in cleartext, so leave this off outside trusted test networks. Only honored from user, managed, or CLI `--settings` settings, not from `.claude/settings.json` or `.claude/settings.local.json`. Default: false. Requires Claude Code v2.1.199 or later.| `true` `network.allowUnixSockets`| (macOS only) Unix socket paths accessible in sandbox. Ignored on Linux and WSL2, where the seccomp filter cannot inspect socket paths; use `allowAllUnixSockets` instead.| `["~/.ssh/agent-socket"]` `network.allowAllUnixSockets`| Allow all Unix socket connections in sandbox. On Linux and WSL2 this is the only way to permit Unix sockets, since it skips the seccomp filter that otherwise blocks `socket(AF_UNIX, ...)` calls. Default: false| `true` `network.allowLocalBinding`| Allow binding to localhost ports (macOS only). Default: false| `true` @@ -441,7 +441,7 @@ `network.allowManagedDomainsOnly`| (Managed settings only) Only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Domains from user, project, and local settings are ignored. Non-allowed domains are blocked automatically without prompting the user. Denied domains are still respected from all sources. Default: false| `true` `network.httpProxyPort`| HTTP proxy port used if you wish to bring your own proxy. If not specified, Claude will run its own proxy.| `8080` `network.socksProxyPort`| SOCKS5 proxy port used if you wish to bring your own proxy. If not specified, Claude will run its own proxy.| `8081` -`network.tlsTerminate`| Experimental. Terminate TLS inside the sandbox proxy so it can read the contents of HTTPS requests. Required for `mask` [credential substitution](</docs/en/sandboxing#protect-credentials>). Set `{}` to generate an ephemeral certificate authority for the session, or set `caCertPath` and `caKeyPath` to use your own. Only honored from user, managed, or CLI `--settings` settings, not from `.claude/settings.json` or `.claude/settings.local.json`. Requires Claude Code v2.1.199 or later. | `{}` +`network.tlsTerminate`| Experimental. Terminate TLS inside the sandbox proxy so it can read the contents of HTTPS requests. Required for `mask` [credential substitution](</docs/en/sandboxing#protect-credentials>). Set `{}` to generate an ephemeral certificate authority for the session, or set `caCertPath` and `caKeyPath` to use your own. Only honored from user, managed, or CLI `--settings` settings, not from `.claude/settings.json` or `.claude/settings.local.json`. Requires Claude Code v2.1.199 or later.| `{}` `enableWeakerNestedSandbox`| Enable weaker sandbox for unprivileged Docker environments (Linux and WSL2 only). **Reduces security.** Default: false| `true` `enableWeakerNetworkIsolation`| (macOS only) Allow access to the system TLS trust service (`com.apple.trustd.agent`) in the sandbox. Required for Go-based tools like `gh`, `gcloud`, and `terraform` to verify TLS certificates when using `httpProxyPort` with a MITM proxy and custom CA. **Reduces security** by opening a potential data exfiltration path. Default: false| `true` `allowAppleEvents`| (macOS only) Allow sandboxed commands to send Apple Events. Required for `open`, `osascript`, and tools that open URLs in a browser, which otherwise fail with error `-600`. **Removes code-execution isolation.** Sandboxed commands can launch other applications unsandboxed with no user prompt; they can also send AppleScript commands to running applications such as Terminal, subject to the per-app macOS automation-consent prompt (TCC). Only honored from user, managed, or CLI settings, not from project settings. Default: false| `true`
modified Create custom subagents View current →
--- a/sub-agents.md +++ b/sub-agents.md @@ -18,7 +18,7 @@ Built-in subagents -Claude Code includes built-in subagents that Claude automatically uses when appropriate. Each inherits the parent conversation’s permissions with additional tool restrictions. Explore and Plan skip your CLAUDE.md files and the parent session’s git status to keep research fast and inexpensive. Every other built-in and custom subagent loads both. For the full breakdown of what reaches a subagent, see what loads at startup. +Claude Code includes built-in subagents that Claude automatically uses when appropriate. Each inherits the parent conversation’s permissions; most run with a restricted tool set. Explore and Plan skip your CLAUDE.md files and the parent session’s git status to keep research fast and inexpensive. Every other built-in and custom subagent loads both. For the full breakdown of what reaches a subagent, see what loads at startup. * Explore @@ -56,9 +56,10 @@ Agent| Model| When Claude uses it ---|---|--- +claude| Inherits from main conversation| When a task doesn’t fit a more specialized agent. A catch-all with every tool available to subagents. Also the default agent for a dispatched [background session](</docs/en/agent-view>), which runs with your settings’ permission mode rather than a parent conversation’s statusline-setup| Sonnet| When you run `/statusline` to configure your status line claude-code-guide| Haiku| When you ask questions about Claude Code features -claude| Inherits| When you dispatch a [background session](</docs/en/agent-view>) from `claude agents` or `claude --bg` without naming an agent. Claude can also delegate to it like any other subagent +claude| Inherits| When you dispatch a [background session](</docs/en/agent-view>) from `claude agents` and the dispatch [resolves to it as the default agent](</docs/en/agent-view#permission-mode-model-and-effort>). Claude can also delegate to it like any other subagent Built-in subagents are registered by default in interactive sessions. To restrict them: @@ -116,7 +117,7 @@ Use the code-improver agent to suggest improvements in this project -Claude delegates to your new subagent, which scans the codebase and returns improvement suggestions.If Claude can’t find the new subagent, restart Claude Code and try again. This happens only when `~/.claude/agents/` didn’t exist before the session started, because a running session doesn’t detect a newly created `agents` directory. +Claude delegates to your new subagent, which scans the codebase and returns improvement suggestions. In the transcript, the delegation appears as a tool call row showing the subagent’s name followed by a short task description, such as `code-improver (Suggest code improvements)`.If Claude can’t find the new subagent, restart Claude Code and try again. This happens only when `~/.claude/agents/` didn’t exist before the session started, because a running session doesn’t detect a newly created `agents` directory. You now have a subagent you can use in any project on your machine to analyze codebases and suggest improvements. You can also write subagent files by hand, define them via CLI flags, or distribute them through plugins. The following sections cover all configuration options. @@ -198,6 +199,8 @@ * The watcher covers only directories that existed when the session started, so after creating a scope’s first agent file in a new `agents` directory, restart to load it. * Sessions started with `--disable-slash-commands` don’t watch these directories at all. + +.claude/agents/code-reviewer.md --- name: code-reviewer @@ -911,7 +914,7 @@ ---|--- `↑` / `↓`| Move between rows `Enter`| Open the selected fork’s transcript and send it follow-up messages -`x`| Dismiss a finished fork or stop a running one +`x`| Dismiss a finished fork or stop a running one. Acts on the selected fork row. On the main session row, or on the row of the fork whose transcript you opened with `Enter`, `x` types into the prompt instead `Esc`| Return focus to the prompt input With a fork’s or subagent’s transcript open, follow-up messages and [skills](</docs/en/skills>) go to that agent, but built-in commands still run in your main conversation. As of v2.1.199, typing `/model` or `/fast` in that view shows a notice that it changes the main conversation’s model or fast mode, not the viewed agent’s, instead of running it silently.
modified Troubleshooting View current →
--- a/troubleshooting.md +++ b/troubleshooting.md @@ -31,14 +31,21 @@ Claude Code is designed to work with most development environments, but may consume significant resources when processing large codebases. If you’re experiencing performance issues: - 1. Use `/compact` regularly to reduce context size + 1. Use `/compact` regularly to reduce context size. If it returns `Not enough messages to compact.`, the conversation has too few turns to summarize; that can happen even with a full context when a single large paste filled it 2. Close and restart Claude Code between major tasks 3. Consider adding large build directories to your `.gitignore` file 4. Restart with [`claude --safe-mode`](</docs/en/cli-reference#cli-flags>) to check whether a plugin, MCP server, or hook is the source. It disables all customizations for the session; if usage drops, see [Debug your configuration](</docs/en/debug-your-config#test-against-a-clean-configuration>) to find which one -If memory usage stays high after these steps, run `/heapdump` to write a JavaScript heap snapshot and a memory breakdown to `~/Desktop`. On Linux without a Desktop folder, the files are written to your home directory. The breakdown shows resident set size, JS heap, array buffers, and unaccounted native memory, which helps identify whether the growth is in JavaScript objects or in native code. To inspect retainers, open the `.heapsnapshot` file in Chrome DevTools under Memory → Load; the breakdown is the file ending in `-diagnostics.json`. +If memory usage stays high after these steps, run `/heapdump` to write two files to `~/Desktop`: a JavaScript heap snapshot named `<session-id>.heapsnapshot` and a memory breakdown named `<session-id>-diagnostics.json`. The command doesn’t appear in the command menu; type it in full. On Linux without a Desktop folder, the files are written to your home directory. -The `.heapsnapshot` file contains every string in the process. Don’t attach it to a public issue or share it. Attach only the `-diagnostics.json` file when reporting a memory issue on [GitHub](<https://github.com/anthropics/claude-code/issues>). That file contains memory statistics and no conversation content or credentials. +The `.heapsnapshot` file contains every string in the process, including your full conversation and credentials. Don’t attach it to a public issue or share it. + +The command also prints a summary in the conversation, showing resident set size, JS heap, array buffers, and unaccounted native memory, plus any leak indicators it detected, such as a high memory growth rate or an unusually high number of open handles. The summary says whether most memory is in the JS heap, which the snapshot captures, or in native memory, which it doesn’t. Do one of two things with the output: + + * **Report it** : open a [GitHub issue](<https://github.com/anthropics/claude-code/issues>) and attach only the `-diagnostics.json` file, which carries the statistics behind the printed summary and no conversation content or credentials + * **Investigate it yourself** : if the summary says most memory is JS heap, open the `.heapsnapshot` file in Chrome DevTools under Memory → Load and sort by retained size to see what’s holding the memory + +If the summary says most memory is native, the snapshot can’t show it; include the summary’s leak indicators in your report instead. ### @@ -112,7 +119,15 @@ winget install BurntSushi.ripgrep.MSVC -Then set `USE_BUILTIN_RIPGREP=0` in your [environment](</docs/en/env-vars>). To confirm the switch took effect, run `claude doctor` in your terminal and check that the Search line shows the path of your system ripgrep instead of `OK (bundled)`. +Then set `USE_BUILTIN_RIPGREP` to `0`, either in your shell [environment](</docs/en/env-vars>) or in the `env` block of your [`settings.json`](</docs/en/settings#available-settings>): + + { + "env": { + "USE_BUILTIN_RIPGREP": "0" + } + } + +To confirm the switch took effect, run `claude doctor` in your terminal and check that the Search line shows the path of your system ripgrep instead of `OK (bundled)`. ###
modified Agent SDK reference - TypeScript View current →
--- a/typescript.md +++ b/typescript.md @@ -6,7 +6,7 @@ npm install @anthropic-ai/claude-agent-sdk -The SDK bundles a native Claude Code binary for your platform as an optional dependency such as `@anthropic-ai/claude-agent-sdk-darwin-arm64`. You don’t need to install Claude Code separately. The SDK version tracks the bundled Claude Code version: SDK v0.3.191 bundles Claude Code v2.1.191, so a feature on this page that requires a Claude Code version needs the SDK release with the same patch number or later. If your package manager skips optional dependencies, the SDK throws `Native CLI binary for <platform> not found`; set `pathToClaudeCodeExecutable` to a separately installed `claude` binary instead. +The SDK bundles a native Claude Code binary for your platform as an optional dependency such as `@anthropic-ai/claude-agent-sdk-darwin-arm64`. You don’t need to install Claude Code separately. The SDK version tracks the bundled Claude Code version: SDK v0.3.191 bundles Claude Code v2.1.191, so a feature on this page that requires a Claude Code version needs the SDK release with the same patch number or later. If your package manager skips optional dependencies, the SDK throws `Native CLI binary for <platform> not found`; set `pathToClaudeCodeExecutable` to a separately installed `claude` binary instead.If your package manager doesn’t apply npm’s `libc` field, as Yarn 1.x doesn’t, you get both the glibc and musl platform packages on Linux, roughly doubling the install size. The SDK still launches the correct variant. To reclaim the space in a container image, delete the platform package that doesn’t match the libc where your app runs; for a glibc runtime on x64, that’s `rm -rf node_modules/@anthropic-ai/claude-agent-sdk-linux-x64-musl`. On a development machine the deletion is temporary, since Yarn reinstalls the package on the next dependency change. ###
modified Orchestrate subagents at scale with dynamic workflows View current →
--- a/workflows.md +++ b/workflows.md @@ -311,7 +311,7 @@ return audits.filter(Boolean) -The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent and `pipeline()` runs one per item in a list. If you want to edit a script by hand, ask Claude to walk you through the change, or see the Workflow tool entry in the [Agent SDK reference](</docs/en/agent-sdk/typescript>) for the full set of options. +The body is plain JavaScript with top-level `await`. `agent()` spawns one subagent and `pipeline()` runs one per item in a list. An `agent()` call resolves to `null` if you stop it mid-run or it hits an unrecoverable API error. `pipeline()` keeps that `null` in the results array, which is why the example ends with `.filter(Boolean)` to drop those entries. If you want to edit a script by hand, ask Claude to walk you through the change, or see the Workflow tool entry in the [Agent SDK reference](</docs/en/agent-sdk/typescript>) for the full set of options. ##