SpyBara
Go Premium

Documentation 2026-03-25 21:08 UTC to 2026-03-26 21:07 UTC

26 files changed +422 −116. View all changes and history on the product overview
2026
Tue 31 21:09 Mon 30 21:13 Sat 28 18:04 Fri 27 21:09 Thu 26 21:07 Wed 25 21:08 Tue 24 18:15 Mon 23 21:08 Sun 22 18:04 Sat 21 18:03 Fri 20 21:05 Thu 19 06:17 Wed 18 18:16 Tue 17 21:10 Mon 16 21:10 Sat 14 03:44 Fri 13 21:07 Thu 12 21:07 Wed 11 03:43 Tue 10 03:43 Mon 9 21:06 Sat 7 03:37 Fri 6 06:10 Thu 5 06:12 Wed 4 21:06 Sun 1 06:10

agent-teams.md +2 −1

Details

186 186 

187### Enforce quality gates with hooks187### Enforce quality gates with hooks

188 188 

189Use [hooks](/en/hooks) to enforce rules when teammates finish work or tasks complete:189Use [hooks](/en/hooks) to enforce rules when teammates finish work or tasks are created or completed:

190 190 

191* [`TeammateIdle`](/en/hooks#teammateidle): runs when a teammate is about to go idle. Exit with code 2 to send feedback and keep the teammate working.191* [`TeammateIdle`](/en/hooks#teammateidle): runs when a teammate is about to go idle. Exit with code 2 to send feedback and keep the teammate working.

192* [`TaskCreated`](/en/hooks#taskcreated): runs when a task is being created. Exit with code 2 to prevent creation and send feedback.

192* [`TaskCompleted`](/en/hooks#taskcompleted): runs when a task is being marked complete. Exit with code 2 to prevent completion and send feedback.193* [`TaskCompleted`](/en/hooks#taskcompleted): runs when a task is being marked complete. Exit with code 2 to prevent completion and send feedback.

193 194 

194## How agent teams work195## How agent teams work

Details

37 37 

381. Visit [claude.ai/code](https://claude.ai/code)381. Visit [claude.ai/code](https://claude.ai/code)

392. Connect your GitHub account392. Connect your GitHub account

403. Install the Claude GitHub app in your repositories403. Install the Claude GitHub App in your repositories

414. Select your default environment414. Select your default environment

425. Submit your coding task425. Submit your coding task

436. Review changes in diff view, iterate with comments, then create a pull request436. Review changes in diff view, iterate with comments, then create a pull request


67 67 

68This lets you refine changes through multiple rounds of feedback without creating draft PRs or switching to GitHub.68This lets you refine changes through multiple rounds of feedback without creating draft PRs or switching to GitHub.

69 69 

70## Auto-fix pull requests

71 

72Claude can watch a pull request and automatically respond to CI failures and review comments. Claude subscribes to GitHub activity on the PR, and when a check fails or a reviewer leaves a comment, Claude investigates and pushes a fix if one is clear.

73 

74<Note>

75 Auto-fix requires the Claude GitHub App to be installed on your repository. If you haven't already, install it from the [GitHub App page](https://github.com/apps/claude) or when prompted during [setup](#getting-started).

76</Note>

77 

78There are a few ways to turn on auto-fix depending on where the PR came from and what device you're using:

79 

80* **PRs created in Claude Code on the web**: open the CI status bar and select **Auto-fix**

81* **From the mobile app**: tell Claude to auto-fix the PR, for example "watch this PR and fix any CI failures or review comments"

82* **Any existing PR**: paste the PR URL into a session and tell Claude to auto-fix it

83 

84### How Claude responds to PR activity

85 

86When auto-fix is active, Claude receives GitHub events for the PR including new review comments and CI check failures. For each event, Claude investigates and decides how to proceed:

87 

88* **Clear fixes**: if Claude is confident in a fix and it doesn't conflict with earlier instructions, Claude makes the change, pushes it, and explains what was done in the session

89* **Ambiguous requests**: if a reviewer's comment could be interpreted multiple ways or involves something architecturally significant, Claude asks you before acting

90* **Duplicate or no-action events**: if an event is a duplicate or requires no change, Claude notes it in the session and moves on

91 

92Claude may reply to review comment threads on GitHub as part of resolving them. These replies are posted using your GitHub account, so they appear under your username, but each reply is labeled as coming from Claude Code so reviewers know it was written by the agent and not by you directly.

93 

70## Moving tasks between web and terminal94## Moving tasks between web and terminal

71 95 

72You can start new tasks on the web from your terminal, or pull web sessions into your terminal to continue locally. Web sessions persist even if you close your laptop, and you can monitor them from anywhere including the Claude mobile app.96You can start new tasks on the web from your terminal, or pull web sessions into your terminal to continue locally. Web sessions persist even if you close your laptop, and you can monitor them from anywhere including the Claude mobile app.

Details

11You can start sessions, pipe content, resume conversations, and manage updates with these commands:11You can start sessions, pipe content, resume conversations, and manage updates with these commands:

12 12 

13| Command | Description | Example |13| Command | Description | Example |

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

15| `claude` | Start interactive session | `claude` |15| `claude` | Start interactive session | `claude` |

16| `claude "query"` | Start interactive session with initial prompt | `claude "explain this project"` |16| `claude "query"` | Start interactive session with initial prompt | `claude "explain this project"` |

17| `claude -p "query"` | Query via SDK, then exit | `claude -p "explain this function"` |17| `claude -p "query"` | Query via SDK, then exit | `claude -p "explain this function"` |


26| `claude agents` | List all configured [subagents](/en/sub-agents), grouped by source | `claude agents` |26| `claude agents` | List all configured [subagents](/en/sub-agents), grouped by source | `claude agents` |

27| `claude auto-mode defaults` | Print the built-in [auto mode](/en/permission-modes#eliminate-prompts-with-auto-mode) classifier rules as JSON. Use `claude auto-mode config` to see your effective config with settings applied | `claude auto-mode defaults > rules.json` |27| `claude auto-mode defaults` | Print the built-in [auto mode](/en/permission-modes#eliminate-prompts-with-auto-mode) classifier rules as JSON. Use `claude auto-mode config` to see your effective config with settings applied | `claude auto-mode defaults > rules.json` |

28| `claude mcp` | Configure Model Context Protocol (MCP) servers | See the [Claude Code MCP documentation](/en/mcp). |28| `claude mcp` | Configure Model Context Protocol (MCP) servers | See the [Claude Code MCP documentation](/en/mcp). |

29| `claude plugin` | Manage Claude Code [plugins](/en/plugins). Alias: `claude plugins`. See [plugin reference](/en/plugins-reference#cli-commands-reference) for subcommands | `claude plugin install code-review@claude-plugins-official` |

29| `claude remote-control` | Start a [Remote Control](/en/remote-control) server to control Claude Code from Claude.ai or the Claude app. Runs in server mode (no local interactive session). See [Server mode flags](/en/remote-control#server-mode) | `claude remote-control --name "My Project"` |30| `claude remote-control` | Start a [Remote Control](/en/remote-control) server to control Claude Code from Claude.ai or the Claude app. Runs in server mode (no local interactive session). See [Server mode flags](/en/remote-control#server-mode) | `claude remote-control --name "My Project"` |

30 31 

31## CLI flags32## CLI flags

commands.md +5 −5

Details

8 8 

9Type `/` in Claude Code to see all available commands, or type `/` followed by any letters to filter. Not all commands are visible to every user. Some depend on your platform, plan, or environment. For example, `/desktop` only appears on macOS and Windows, `/upgrade` and `/privacy-settings` are only available on Pro and Max plans, and `/terminal-setup` is hidden when your terminal natively supports its keybindings.9Type `/` in Claude Code to see all available commands, or type `/` followed by any letters to filter. Not all commands are visible to every user. Some depend on your platform, plan, or environment. For example, `/desktop` only appears on macOS and Windows, `/upgrade` and `/privacy-settings` are only available on Pro and Max plans, and `/terminal-setup` is hidden when your terminal natively supports its keybindings.

10 10 

11Claude Code also includes [bundled skills](/en/skills#bundled-skills) like `/simplify`, `/batch`, and `/debug` that appear alongside built-in commands when you type `/`. To create your own commands, see [skills](/en/skills).11Claude Code also includes [bundled skills](/en/skills#bundled-skills) like `/simplify`, `/batch`, `/debug`, and `/loop` that appear alongside built-in commands when you type `/`. To create your own commands, see [skills](/en/skills).

12 12 

13In the table below, `<arg>` indicates a required argument and `[arg]` indicates an optional one.13In the table below, `<arg>` indicates a required argument and `[arg]` indicates an optional one.

14 14 

15| Command | Purpose |15| Command | Purpose |

16| :--------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |16| :--------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

17| `/add-dir <path>` | Add a new working directory to the current session |17| `/add-dir <path>` | Add a new working directory to the current session |

18| `/agents` | Manage [agent](/en/sub-agents) configurations |18| `/agents` | Manage [agent](/en/sub-agents) configurations |

19| `/btw <question>` | Ask a quick [side question](/en/interactive-mode#side-questions-with-btw) without adding to the conversation |19| `/btw <question>` | Ask a quick [side question](/en/interactive-mode#side-questions-with-btw) without adding to the conversation |


23| `/compact [instructions]` | Compact conversation with optional focus instructions |23| `/compact [instructions]` | Compact conversation with optional focus instructions |

24| `/config` | Open the [Settings](/en/settings) interface to adjust theme, model, [output style](/en/output-styles), and other preferences. Alias: `/settings` |24| `/config` | Open the [Settings](/en/settings) interface to adjust theme, model, [output style](/en/output-styles), and other preferences. Alias: `/settings` |

25| `/context` | Visualize current context usage as a colored grid. Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings |25| `/context` | Visualize current context usage as a colored grid. Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings |

26| `/copy [N]` | Copy the last assistant response to clipboard. Pass a number `N` to copy the Nth-latest response: `/copy 2` copies the second-to-last. When code blocks are present, shows an interactive picker to select individual blocks or the full response |26| `/copy [N]` | Copy the last assistant response to clipboard. Pass a number `N` to copy the Nth-latest response: `/copy 2` copies the second-to-last. When code blocks are present, shows an interactive picker to select individual blocks or the full response. Press `w` in the picker to write the selection to a file instead of the clipboard, which is useful over SSH |

27| `/cost` | Show token usage statistics. See [cost tracking guide](/en/costs#using-the-cost-command) for subscription-specific details |27| `/cost` | Show token usage statistics. See [cost tracking guide](/en/costs#using-the-cost-command) for subscription-specific details |

28| `/desktop` | Continue the current session in the Claude Code Desktop app. macOS and Windows only. Alias: `/app` |28| `/desktop` | Continue the current session in the Claude Code Desktop app. macOS and Windows only. Alias: `/app` |

29| `/diff` | Open an interactive diff viewer showing uncommitted changes and per-turn diffs. Use left/right arrows to switch between the current git diff and individual Claude turns, and up/down to browse files |29| `/diff` | Open an interactive diff viewer showing uncommitted changes and per-turn diffs. Use left/right arrows to switch between the current git diff and individual Claude turns, and up/down to browse files |


51| `/model [model]` | Select or change the AI model. For models that support it, use left/right arrows to [adjust effort level](/en/model-config#adjust-effort-level). The change takes effect immediately without waiting for the current response to finish |51| `/model [model]` | Select or change the AI model. For models that support it, use left/right arrows to [adjust effort level](/en/model-config#adjust-effort-level). The change takes effect immediately without waiting for the current response to finish |

52| `/passes` | Share a free week of Claude Code with friends. Only visible if your account is eligible |52| `/passes` | Share a free week of Claude Code with friends. Only visible if your account is eligible |

53| `/permissions` | View or update [permissions](/en/permissions#manage-permissions). Alias: `/allowed-tools` |53| `/permissions` | View or update [permissions](/en/permissions#manage-permissions). Alias: `/allowed-tools` |

54| `/plan` | Enter plan mode directly from the prompt |54| `/plan [description]` | Enter plan mode directly from the prompt. Pass an optional description to enter plan mode and immediately start with that task, for example `/plan fix the auth bug` |

55| `/plugin` | Manage Claude Code [plugins](/en/plugins) |55| `/plugin` | Manage Claude Code [plugins](/en/plugins) |

56| `/pr-comments [PR]` | Fetch and display comments from a GitHub pull request. Automatically detects the PR for the current branch, or pass a PR URL or number. Requires the `gh` CLI |56| `/pr-comments [PR]` | Fetch and display comments from a GitHub pull request. Automatically detects the PR for the current branch, or pass a PR URL or number. Requires the `gh` CLI |

57| `/privacy-settings` | View and update your privacy settings. Only available for Pro and Max plan subscribers |57| `/privacy-settings` | View and update your privacy settings. Only available for Pro and Max plan subscribers |


61| `/remote-env` | Configure the default remote environment for [web sessions started with `--remote`](/en/claude-code-on-the-web#environment-configuration) |61| `/remote-env` | Configure the default remote environment for [web sessions started with `--remote`](/en/claude-code-on-the-web#environment-configuration) |

62| `/rename [name]` | Rename the current session and show the name on the prompt bar. Without a name, auto-generates one from conversation history |62| `/rename [name]` | Rename the current session and show the name on the prompt bar. Without a name, auto-generates one from conversation history |

63| `/resume [session]` | Resume a conversation by ID or name, or open the session picker. Alias: `/continue` |63| `/resume [session]` | Resume a conversation by ID or name, or open the session picker. Alias: `/continue` |

64| `/review` | Deprecated. Install the [`code-review` plugin](https://github.com/anthropics/claude-code-marketplace/blob/main/code-review/README.md) instead: `claude plugin install code-review@claude-code-marketplace` |64| `/review` | Deprecated. Install the [`code-review` plugin](https://github.com/anthropics/claude-plugins-official/tree/main/plugins/code-review) instead: `claude plugin install code-review@claude-plugins-official` |

65| `/rewind` | Rewind the conversation and/or code to a previous point, or summarize from a selected message. See [checkpointing](/en/checkpointing). Alias: `/checkpoint` |65| `/rewind` | Rewind the conversation and/or code to a previous point, or summarize from a selected message. See [checkpointing](/en/checkpointing). Alias: `/checkpoint` |

66| `/sandbox` | Toggle [sandbox mode](/en/sandboxing). Available on supported platforms only |66| `/sandbox` | Toggle [sandbox mode](/en/sandboxing). Available on supported platforms only |

67| `/schedule [description]` | Create, update, list, or run [Cloud scheduled tasks](/en/web-scheduled-tasks). Claude walks you through the setup conversationally |67| `/schedule [description]` | Create, update, list, or run [Cloud scheduled tasks](/en/web-scheduled-tasks). Claude walks you through the setup conversationally |

Details

687 Add `.claude/worktrees/` to your `.gitignore` to prevent worktree contents from appearing as untracked files in your main repository.687 Add `.claude/worktrees/` to your `.gitignore` to prevent worktree contents from appearing as untracked files in your main repository.

688</Tip>688</Tip>

689 689 

690### Copy gitignored files to worktrees

691 

692Git worktrees are fresh checkouts, so they don't include untracked files like `.env` or `.env.local` from your main repository. To automatically copy these files when Claude creates a worktree, add a `.worktreeinclude` file to your project root.

693 

694The file uses `.gitignore` syntax to list which files to copy. Only files that match a pattern and are also gitignored get copied, so tracked files are never duplicated.

695 

696```text .worktreeinclude theme={null}

697.env

698.env.local

699config/secrets.json

700```

701 

702This applies to worktrees created with `--worktree`, subagent worktrees, and parallel sessions in the [desktop app](/en/desktop#work-in-parallel-with-sessions).

703 

690### Manage worktrees manually704### Manage worktrees manually

691 705 

692For more control over worktree location and branch configuration, create worktrees with Git directly. This is useful when you need to check out a specific existing branch or place the worktree outside the repository.706For more control over worktree location and branch configuration, create worktrees with Git directly. This is useful when you need to check out a specific existing branch or place the worktree outside the repository.

desktop.md +2 −0

Details

187 187 

188Worktrees are stored in `<project-root>/.claude/worktrees/` by default. You can change this to a custom directory in Settings → Claude Code under "Worktree location". You can also set a branch prefix that gets prepended to every worktree branch name, which is useful for keeping Claude-created branches organized. To remove a worktree when you're done, hover over the session in the sidebar and click the archive icon.188Worktrees are stored in `<project-root>/.claude/worktrees/` by default. You can change this to a custom directory in Settings → Claude Code under "Worktree location". You can also set a branch prefix that gets prepended to every worktree branch name, which is useful for keeping Claude-created branches organized. To remove a worktree when you're done, hover over the session in the sidebar and click the archive icon.

189 189 

190To include gitignored files like `.env` in new worktrees, create a [`.worktreeinclude` file](/en/common-workflows#copy-gitignored-files-to-worktrees) in your project root.

191 

190<Note>192<Note>

191 Session isolation requires [Git](https://git-scm.com/downloads). Most Macs include Git by default. Run `git --version` in Terminal to check. On Windows, Git is required for the Code tab to work: [download Git for Windows](https://git-scm.com/downloads/win), install it, and restart the app. If you run into Git errors, try a Cowork session to help troubleshoot your setup.193 Session isolation requires [Git](https://git-scm.com/downloads). Most Macs include Git by default. Run `git --version` in Terminal to check. On Windows, Git is required for the Code tab to work: [download Git for Windows](https://git-scm.com/downloads/win), install it, and restart the app. If you run into Git errors, try a Cowork session to help troubleshoot your setup.

192</Note>194</Note>

env-vars.md +13 −2

Details

9Claude Code supports the following environment variables to control its behavior. Set them in your shell before launching `claude`, or configure them in [`settings.json`](/en/settings#available-settings) under the `env` key to apply them to every session or roll them out across your team.9Claude Code supports the following environment variables to control its behavior. Set them in your shell before launching `claude`, or configure them in [`settings.json`](/en/settings#available-settings) under the `env` key to apply them to every session or roll them out across your team.

10 10 

11| Variable | Purpose |11| Variable | Purpose |

12| :--------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |12| :------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

13| `ANTHROPIC_API_KEY` | API key sent as `X-Api-Key` header. When set, this key is used instead of your Claude Pro, Max, Team, or Enterprise subscription even if you are logged in. In non-interactive mode (`-p`), the key is always used when present. In interactive mode, you are prompted to approve the key once before it overrides your subscription. To use your subscription instead, run `unset ANTHROPIC_API_KEY` |13| `ANTHROPIC_API_KEY` | API key sent as `X-Api-Key` header. When set, this key is used instead of your Claude Pro, Max, Team, or Enterprise subscription even if you are logged in. In non-interactive mode (`-p`), the key is always used when present. In interactive mode, you are prompted to approve the key once before it overrides your subscription. To use your subscription instead, run `unset ANTHROPIC_API_KEY` |

14| `ANTHROPIC_AUTH_TOKEN` | Custom value for the `Authorization` header (the value you set here will be prefixed with `Bearer `) |14| `ANTHROPIC_AUTH_TOKEN` | Custom value for the `Authorization` header (the value you set here will be prefixed with `Bearer `) |

15| `ANTHROPIC_BASE_URL` | Override the API endpoint to route requests through a proxy or gateway. When set to a non-first-party host, [MCP tool search](/en/mcp#scale-with-mcp-tool-search) is disabled by default. Set `ENABLE_TOOL_SEARCH=true` if your proxy forwards `tool_reference` blocks |15| `ANTHROPIC_BASE_URL` | Override the API endpoint to route requests through a proxy or gateway. When set to a non-first-party host, [MCP tool search](/en/mcp#scale-with-mcp-tool-search) is disabled by default. Set `ENABLE_TOOL_SEARCH=true` if your proxy forwards `tool_reference` blocks |


18| `ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION` | Display description for the custom model entry in the `/model` picker. Defaults to `Custom model (<model-id>)` when not set |18| `ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION` | Display description for the custom model entry in the `/model` picker. Defaults to `Custom model (<model-id>)` when not set |

19| `ANTHROPIC_CUSTOM_MODEL_OPTION_NAME` | Display name for the custom model entry in the `/model` picker. Defaults to the model ID when not set |19| `ANTHROPIC_CUSTOM_MODEL_OPTION_NAME` | Display name for the custom model entry in the `/model` picker. Defaults to the model ID when not set |

20| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | See [Model configuration](/en/model-config#environment-variables) |20| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | See [Model configuration](/en/model-config#environment-variables) |

21| `ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

22| `ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

23| `ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

21| `ANTHROPIC_DEFAULT_OPUS_MODEL` | See [Model configuration](/en/model-config#environment-variables) |24| `ANTHROPIC_DEFAULT_OPUS_MODEL` | See [Model configuration](/en/model-config#environment-variables) |

25| `ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

26| `ANTHROPIC_DEFAULT_OPUS_MODEL_NAME` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

27| `ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

22| `ANTHROPIC_DEFAULT_SONNET_MODEL` | See [Model configuration](/en/model-config#environment-variables) |28| `ANTHROPIC_DEFAULT_SONNET_MODEL` | See [Model configuration](/en/model-config#environment-variables) |

29| `ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

30| `ANTHROPIC_DEFAULT_SONNET_MODEL_NAME` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

31| `ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES` | See [Model configuration](/en/model-config#customize-pinned-model-display-and-capabilities) |

23| `ANTHROPIC_FOUNDRY_API_KEY` | API key for Microsoft Foundry authentication (see [Microsoft Foundry](/en/microsoft-foundry)) |32| `ANTHROPIC_FOUNDRY_API_KEY` | API key for Microsoft Foundry authentication (see [Microsoft Foundry](/en/microsoft-foundry)) |

24| `ANTHROPIC_FOUNDRY_BASE_URL` | Full base URL for the Foundry resource (for example, `https://my-resource.services.ai.azure.com/anthropic`). Alternative to `ANTHROPIC_FOUNDRY_RESOURCE` (see [Microsoft Foundry](/en/microsoft-foundry)) |33| `ANTHROPIC_FOUNDRY_BASE_URL` | Full base URL for the Foundry resource (for example, `https://my-resource.services.ai.azure.com/anthropic`). Alternative to `ANTHROPIC_FOUNDRY_RESOURCE` (see [Microsoft Foundry](/en/microsoft-foundry)) |

25| `ANTHROPIC_FOUNDRY_RESOURCE` | Foundry resource name (for example, `my-resource`). Required if `ANTHROPIC_FOUNDRY_BASE_URL` is not set (see [Microsoft Foundry](/en/microsoft-foundry)) |34| `ANTHROPIC_FOUNDRY_RESOURCE` | Foundry resource name (for example, `my-resource`). Required if `ANTHROPIC_FOUNDRY_BASE_URL` is not set (see [Microsoft Foundry](/en/microsoft-foundry)) |


84| `CLAUDE_CODE_USER_EMAIL` | Email address for the authenticated user. Used by SDK callers to provide account information synchronously. Requires `CLAUDE_CODE_ACCOUNT_UUID` and `CLAUDE_CODE_ORGANIZATION_UUID` to also be set |93| `CLAUDE_CODE_USER_EMAIL` | Email address for the authenticated user. Used by SDK callers to provide account information synchronously. Requires `CLAUDE_CODE_ACCOUNT_UUID` and `CLAUDE_CODE_ORGANIZATION_UUID` to also be set |

85| `CLAUDE_CODE_USE_BEDROCK` | Use [Bedrock](/en/amazon-bedrock) |94| `CLAUDE_CODE_USE_BEDROCK` | Use [Bedrock](/en/amazon-bedrock) |

86| `CLAUDE_CODE_USE_FOUNDRY` | Use [Microsoft Foundry](/en/microsoft-foundry) |95| `CLAUDE_CODE_USE_FOUNDRY` | Use [Microsoft Foundry](/en/microsoft-foundry) |

96| `CLAUDE_CODE_USE_POWERSHELL_TOOL` | Set to `1` to enable the PowerShell tool on Windows (opt-in preview). When enabled, Claude can run PowerShell commands natively instead of routing through Git Bash. Only supported on native Windows, not WSL. See [PowerShell tool](/en/tools-reference#powershell-tool) |

87| `CLAUDE_CODE_USE_VERTEX` | Use [Vertex](/en/google-vertex-ai) |97| `CLAUDE_CODE_USE_VERTEX` | Use [Vertex](/en/google-vertex-ai) |

88| `CLAUDE_CONFIG_DIR` | Customize where Claude Code stores its configuration and data files |98| `CLAUDE_CONFIG_DIR` | Customize where Claude Code stores its configuration and data files |

89| `CLAUDE_ENV_FILE` | Path to a shell script that Claude Code sources before each Bash command. Use to persist virtualenv or conda activation across commands. Also populated dynamically by [SessionStart](/en/hooks#persist-environment-variables), [CwdChanged](/en/hooks#cwdchanged), and [FileChanged](/en/hooks#filechanged) hooks |99| `CLAUDE_ENV_FILE` | Path to a shell script that Claude Code sources before each Bash command. Use to persist virtualenv or conda activation across commands. Also populated dynamically by [SessionStart](/en/hooks#persist-environment-variables), [CwdChanged](/en/hooks#cwdchanged), and [FileChanged](/en/hooks#filechanged) hooks |

100| `CLAUDE_STREAM_IDLE_TIMEOUT_MS` | Timeout in milliseconds before the streaming idle watchdog closes a stalled connection. Default: `90000` (90 seconds). Increase this value if long-running tools or slow networks cause premature timeout errors |

90| `DISABLE_AUTOUPDATER` | Set to `1` to disable automatic updates. |101| `DISABLE_AUTOUPDATER` | Set to `1` to disable automatic updates. |

91| `DISABLE_COST_WARNINGS` | Set to `1` to disable cost warning messages |102| `DISABLE_COST_WARNINGS` | Set to `1` to disable cost warning messages |

92| `DISABLE_ERROR_REPORTING` | Set to `1` to opt out of Sentry error reporting |103| `DISABLE_ERROR_REPORTING` | Set to `1` to opt out of Sentry error reporting |


97| `DISABLE_PROMPT_CACHING_OPUS` | Set to `1` to disable prompt caching for Opus models |108| `DISABLE_PROMPT_CACHING_OPUS` | Set to `1` to disable prompt caching for Opus models |

98| `DISABLE_PROMPT_CACHING_SONNET` | Set to `1` to disable prompt caching for Sonnet models |109| `DISABLE_PROMPT_CACHING_SONNET` | Set to `1` to disable prompt caching for Sonnet models |

99| `DISABLE_TELEMETRY` | Set to `1` to opt out of Statsig telemetry (note that Statsig events do not include user data like code, file paths, or bash commands) |110| `DISABLE_TELEMETRY` | Set to `1` to opt out of Statsig telemetry (note that Statsig events do not include user data like code, file paths, or bash commands) |

100| `ENABLE_CLAUDEAI_MCP_SERVERS` | Set to `false` to disable [claude.ai MCP servers](/en/mcp#use-mcp-servers-from-claudeai) in Claude Code. Enabled by default for logged-in users |111| `ENABLE_CLAUDEAI_MCP_SERVERS` | Set to `false` to disable [claude.ai MCP servers](/en/mcp#use-mcp-servers-from-claude-ai) in Claude Code. Enabled by default for logged-in users |

101| `ENABLE_TOOL_SEARCH` | Controls [MCP tool search](/en/mcp#scale-with-mcp-tool-search). Unset: enabled by default, but disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host. Values: `true` (always on including proxies), `auto` (enables at 10% context), `auto:N` (custom threshold, e.g., `auto:5` for 5%), `false` (disabled) |112| `ENABLE_TOOL_SEARCH` | Controls [MCP tool search](/en/mcp#scale-with-mcp-tool-search). Unset: enabled by default, but disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host. Values: `true` (always on including proxies), `auto` (enables at 10% context), `auto:N` (custom threshold, e.g., `auto:5` for 5%), `false` (disabled) |

102| `FORCE_AUTOUPDATE_PLUGINS` | Set to `true` to force plugin auto-updates even when the main auto-updater is disabled via `DISABLE_AUTOUPDATER` |113| `FORCE_AUTOUPDATE_PLUGINS` | Set to `true` to force plugin auto-updates even when the main auto-updater is disabled via `DISABLE_AUTOUPDATER` |

103| `HTTP_PROXY` | Specify HTTP proxy server for network connections |114| `HTTP_PROXY` | Specify HTTP proxy server for network connections |

Details

81 81 

82 **Put it in a skill** if it's reference material Claude needs sometimes (API docs, style guides) or a workflow you trigger with `/<name>` (deploy, review, release).82 **Put it in a skill** if it's reference material Claude needs sometimes (API docs, style guides) or a workflow you trigger with `/<name>` (deploy, review, release).

83 83 

84 **Rule of thumb:** Keep CLAUDE.md under 200 lines. If it's growing, move reference content to skills or split into [`.claude/rules/`](/en/memory#organize-rules-with-clauderules) files.84 **Rule of thumb:** Keep CLAUDE.md under 200 lines. If it's growing, move reference content to skills or split into [`.claude/rules/`](/en/memory#organize-rules-with-claude/rules/) files.

85 </Tab>85 </Tab>

86 86 

87 <Tab title="CLAUDE.md vs Rules vs Skills">87 <Tab title="CLAUDE.md vs Rules vs Skills">

hooks.md +157 −71

Details

18 18 

19<div style={{maxWidth: "500px", margin: "0 auto"}}>19<div style={{maxWidth: "500px", margin: "0 auto"}}>

20 <Frame>20 <Frame>

21 <img src="https://mintcdn.com/claude-code/JCMefyZyaJwkJgv-/images/hooks-lifecycle.svg?fit=max&auto=format&n=JCMefyZyaJwkJgv-&q=85&s=f004f3fc7324fa2a4630e8d6559cf6dd" alt="Hook lifecycle diagram showing the sequence of hooks from SessionStart through the agentic loop (PreToolUse, PermissionRequest, PostToolUse, SubagentStart/Stop, TaskCompleted) to Stop or StopFailure, TeammateIdle, PreCompact, PostCompact, and SessionEnd, with Elicitation and ElicitationResult nested inside MCP tool execution and WorktreeCreate, WorktreeRemove, Notification, ConfigChange, InstructionsLoaded, CwdChanged, and FileChanged as standalone async events" width="520" height="1100" data-path="images/hooks-lifecycle.svg" />21 <img src="https://mintcdn.com/claude-code/1wr0LPds6lVWZkQB/images/hooks-lifecycle.svg?fit=max&auto=format&n=1wr0LPds6lVWZkQB&q=85&s=53a826e7bb64c6bff5f867506c0530ad" alt="Hook lifecycle diagram showing the sequence of hooks from SessionStart through the agentic loop (PreToolUse, PermissionRequest, PostToolUse, SubagentStart/Stop, TaskCreated, TaskCompleted) to Stop or StopFailure, TeammateIdle, PreCompact, PostCompact, and SessionEnd, with Elicitation and ElicitationResult nested inside MCP tool execution and WorktreeCreate, WorktreeRemove, Notification, ConfigChange, InstructionsLoaded, CwdChanged, and FileChanged as standalone async events" width="520" height="1155" data-path="images/hooks-lifecycle.svg" />

22 </Frame>22 </Frame>

23</div>23</div>

24 24 


35| `Notification` | When Claude Code sends a notification |35| `Notification` | When Claude Code sends a notification |

36| `SubagentStart` | When a subagent is spawned |36| `SubagentStart` | When a subagent is spawned |

37| `SubagentStop` | When a subagent finishes |37| `SubagentStop` | When a subagent finishes |

38| `TaskCreated` | When a task is being created via `TaskCreate` |

39| `TaskCompleted` | When a task is being marked as completed |

38| `Stop` | When Claude finishes responding |40| `Stop` | When Claude finishes responding |

39| `StopFailure` | When the turn ends due to an API error. Output and exit code are ignored |41| `StopFailure` | When the turn ends due to an API error. Output and exit code are ignored |

40| `TeammateIdle` | When an [agent team](/en/agent-teams) teammate is about to go idle |42| `TeammateIdle` | When an [agent team](/en/agent-teams) teammate is about to go idle |

41| `TaskCompleted` | When a task is being marked as completed |

42| `InstructionsLoaded` | When a CLAUDE.md or `.claude/rules/*.md` file is loaded into context. Fires at session start and when files are lazily loaded during a session |43| `InstructionsLoaded` | When a CLAUDE.md or `.claude/rules/*.md` file is loaded into context. Fires at session start and when files are lazily loaded during a session |

43| `ConfigChange` | When a configuration file changes during a session |44| `ConfigChange` | When a configuration file changes during a session |

44| `CwdChanged` | When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv |45| `CwdChanged` | When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv |


169The `matcher` field is a regex string that filters when hooks fire. Use `"*"`, `""`, or omit `matcher` entirely to match all occurrences. Each event type matches on a different field:170The `matcher` field is a regex string that filters when hooks fire. Use `"*"`, `""`, or omit `matcher` entirely to match all occurrences. Each event type matches on a different field:

170 171 

171| Event | What the matcher filters | Example matcher values |172| Event | What the matcher filters | Example matcher values |

172| :---------------------------------------------------------------------------------------------- | :-------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ |173| :------------------------------------------------------------------------------------------------------------- | :-------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ |

173| `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest` | tool name | `Bash`, `Edit\|Write`, `mcp__.*` |174| `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest` | tool name | `Bash`, `Edit\|Write`, `mcp__.*` |

174| `SessionStart` | how the session started | `startup`, `resume`, `clear`, `compact` |175| `SessionStart` | how the session started | `startup`, `resume`, `clear`, `compact` |

175| `SessionEnd` | why the session ended | `clear`, `resume`, `logout`, `prompt_input_exit`, `bypass_permissions_disabled`, `other` |176| `SessionEnd` | why the session ended | `clear`, `resume`, `logout`, `prompt_input_exit`, `bypass_permissions_disabled`, `other` |


184| `InstructionsLoaded` | load reason | `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact` |185| `InstructionsLoaded` | load reason | `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact` |

185| `Elicitation` | MCP server name | your configured MCP server names |186| `Elicitation` | MCP server name | your configured MCP server names |

186| `ElicitationResult` | MCP server name | same values as `Elicitation` |187| `ElicitationResult` | MCP server name | same values as `Elicitation` |

187| `UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove` | no matcher support | always fires on every occurrence |188| `UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCreated`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove` | no matcher support | always fires on every occurrence |

188 189 

189The matcher is a regex, so `Edit|Write` matches either tool and `Notebook.*` matches any tool starting with Notebook. The matcher runs against a field from the [JSON input](#hook-input-and-output) that Claude Code sends to your hook on stdin. For tool events, that field is `tool_name`. Each [hook event](#hook-events) section lists the full set of matcher values and the input schema for that event.190The matcher is a regex, so `Edit|Write` matches either tool and `Notebook.*` matches any tool starting with Notebook. The matcher runs against a field from the [JSON input](#hook-input-and-output) that Claude Code sends to your hook on stdin. For tool events, that field is `tool_name`. Each [hook event](#hook-events) section lists the full set of matcher values and the input schema for that event.

190 191 


208}209}

209```210```

210 211 

211`UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove`, and `CwdChanged` don't support matchers and always fire on every occurrence. If you add a `matcher` field to these events, it is silently ignored.212`UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCreated`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove`, and `CwdChanged` don't support matchers and always fire on every occurrence. If you add a `matcher` field to these events, it is silently ignored.

212 213 

213#### Match MCP tools214#### Match MCP tools

214 215 


279In addition to the [common fields](#common-fields), command hooks accept these fields:280In addition to the [common fields](#common-fields), command hooks accept these fields:

280 281 

281| Field | Required | Description |282| Field | Required | Description |

282| :-------- | :------- | :------------------------------------------------------------------------------------------------------------------ |283| :-------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

283| `command` | yes | Shell command to execute |284| `command` | yes | Shell command to execute |

284| `async` | no | If `true`, runs in the background without blocking. See [Run hooks in the background](#run-hooks-in-the-background) |285| `async` | no | If `true`, runs in the background without blocking. See [Run hooks in the background](#run-hooks-in-the-background) |

286| `shell` | no | Shell to use for this hook. Accepts `"bash"` (default) or `"powershell"`. Setting `"powershell"` runs the command via PowerShell on Windows. Does not require `CLAUDE_CODE_USE_POWERSHELL_TOOL` since hooks spawn PowerShell directly |

285 287 

286#### HTTP hook fields288#### HTTP hook fields

287 289 


521| `Stop` | Yes | Prevents Claude from stopping, continues the conversation |523| `Stop` | Yes | Prevents Claude from stopping, continues the conversation |

522| `SubagentStop` | Yes | Prevents the subagent from stopping |524| `SubagentStop` | Yes | Prevents the subagent from stopping |

523| `TeammateIdle` | Yes | Prevents the teammate from going idle (teammate continues working) |525| `TeammateIdle` | Yes | Prevents the teammate from going idle (teammate continues working) |

526| `TaskCreated` | Yes | Prevents the task from being created |

524| `TaskCompleted` | Yes | Prevents the task from being marked as completed |527| `TaskCompleted` | Yes | Prevents the task from being marked as completed |

525| `ConfigChange` | Yes | Blocks the configuration change from taking effect (except `policy_settings`) |528| `ConfigChange` | Yes | Blocks the configuration change from taking effect (except `policy_settings`) |

526| `StopFailure` | No | Output and exit code are ignored |529| `StopFailure` | No | Output and exit code are ignored |


588| Events | Decision pattern | Key fields |591| Events | Decision pattern | Key fields |

589| :-------------------------------------------------------------------------------------------------------------------------- | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |592| :-------------------------------------------------------------------------------------------------------------------------- | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

590| UserPromptSubmit, PostToolUse, PostToolUseFailure, Stop, SubagentStop, ConfigChange | Top-level `decision` | `decision: "block"`, `reason` |593| UserPromptSubmit, PostToolUse, PostToolUseFailure, Stop, SubagentStop, ConfigChange | Top-level `decision` | `decision: "block"`, `reason` |

591| TeammateIdle, TaskCompleted | Exit code or `continue: false` | Exit code 2 blocks the action with stderr feedback. JSON `{"continue": false, "stopReason": "..."}` also stops the teammate entirely, matching `Stop` hook behavior |594| TeammateIdle, TaskCreated, TaskCompleted | Exit code or `continue: false` | Exit code 2 blocks the action with stderr feedback. JSON `{"continue": false, "stopReason": "..."}` also stops the teammate entirely, matching `Stop` hook behavior |

592| PreToolUse | `hookSpecificOutput` | `permissionDecision` (allow/deny/ask), `permissionDecisionReason` |595| PreToolUse | `hookSpecificOutput` | `permissionDecision` (allow/deny/ask), `permissionDecisionReason` |

593| PermissionRequest | `hookSpecificOutput` | `decision.behavior` (allow/deny) |596| PermissionRequest | `hookSpecificOutput` | `decision.behavior` (allow/deny) |

594| WorktreeCreate | stdout path | Hook prints absolute path to created worktree. Non-zero exit fails creation |597| WorktreeCreate | path return | Command hook prints path on stdout; HTTP hook returns `hookSpecificOutput.worktreePath`. Hook failure or missing path fails creation |

595| Elicitation | `hookSpecificOutput` | `action` (accept/decline/cancel), `content` (form field values for accept) |598| Elicitation | `hookSpecificOutput` | `action` (accept/decline/cancel), `content` (form field values for accept) |

596| ElicitationResult | `hookSpecificOutput` | `action` (accept/decline/cancel), `content` (form field values override) |599| ElicitationResult | `hookSpecificOutput` | `action` (accept/decline/cancel), `content` (form field values override) |

597| WorktreeRemove, Notification, SessionEnd, PreCompact, PostCompact, InstructionsLoaded, StopFailure, CwdChanged, FileChanged | None | No decision control. Used for side effects like logging or cleanup |600| WorktreeRemove, Notification, SessionEnd, PreCompact, PostCompact, InstructionsLoaded, StopFailure, CwdChanged, FileChanged | None | No decision control. Used for side effects like logging or cleanup |


1264 1267 

1265SubagentStop hooks use the same decision control format as [Stop hooks](#stop-decision-control).1268SubagentStop hooks use the same decision control format as [Stop hooks](#stop-decision-control).

1266 1269 

1270### TaskCreated

1271 

1272Runs when a task is being created via the `TaskCreate` tool. Use this to enforce naming conventions, require task descriptions, or prevent certain tasks from being created.

1273 

1274When a `TaskCreated` hook exits with code 2, the task is not created and the stderr message is fed back to the model as feedback. To stop the teammate entirely instead of re-running it, return JSON with `{"continue": false, "stopReason": "..."}`. TaskCreated hooks do not support matchers and fire on every occurrence.

1275 

1276#### TaskCreated input

1277 

1278In addition to the [common input fields](#common-input-fields), TaskCreated hooks receive `task_id`, `task_subject`, and optionally `task_description`, `teammate_name`, and `team_name`.

1279 

1280```json theme={null}

1281{

1282 "session_id": "abc123",

1283 "transcript_path": "/Users/.../.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",

1284 "cwd": "/Users/...",

1285 "permission_mode": "default",

1286 "hook_event_name": "TaskCreated",

1287 "task_id": "task-001",

1288 "task_subject": "Implement user authentication",

1289 "task_description": "Add login and signup endpoints",

1290 "teammate_name": "implementer",

1291 "team_name": "my-project"

1292}

1293```

1294 

1295| Field | Description |

1296| :----------------- | :---------------------------------------------------- |

1297| `task_id` | Identifier of the task being created |

1298| `task_subject` | Title of the task |

1299| `task_description` | Detailed description of the task. May be absent |

1300| `teammate_name` | Name of the teammate creating the task. May be absent |

1301| `team_name` | Name of the team. May be absent |

1302 

1303#### TaskCreated decision control

1304 

1305TaskCreated hooks support two ways to control task creation:

1306 

1307* **Exit code 2**: the task is not created and the stderr message is fed back to the model as feedback.

1308* **JSON `{"continue": false, "stopReason": "..."}`**: stops the teammate entirely, matching `Stop` hook behavior. The `stopReason` is shown to the user.

1309 

1310This example blocks tasks whose subjects don't follow the required format:

1311 

1312```bash theme={null}

1313#!/bin/bash

1314INPUT=$(cat)

1315TASK_SUBJECT=$(echo "$INPUT" | jq -r '.task_subject')

1316 

1317if [[ ! "$TASK_SUBJECT" =~ ^\[TICKET-[0-9]+\] ]]; then

1318 echo "Task subject must start with a ticket number, e.g. '[TICKET-123] Add feature'" >&2

1319 exit 2

1320fi

1321 

1322exit 0

1323```

1324 

1325### TaskCompleted

1326 

1327Runs when a task is being marked as completed. This fires in two situations: when any agent explicitly marks a task as completed through the TaskUpdate tool, or when an [agent team](/en/agent-teams) teammate finishes its turn with in-progress tasks. Use this to enforce completion criteria like passing tests or lint checks before a task can close.

1328 

1329When a `TaskCompleted` hook exits with code 2, the task is not marked as completed and the stderr message is fed back to the model as feedback. To stop the teammate entirely instead of re-running it, return JSON with `{"continue": false, "stopReason": "..."}`. TaskCompleted hooks do not support matchers and fire on every occurrence.

1330 

1331#### TaskCompleted input

1332 

1333In addition to the [common input fields](#common-input-fields), TaskCompleted hooks receive `task_id`, `task_subject`, and optionally `task_description`, `teammate_name`, and `team_name`.

1334 

1335```json theme={null}

1336{

1337 "session_id": "abc123",

1338 "transcript_path": "/Users/.../.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",

1339 "cwd": "/Users/...",

1340 "permission_mode": "default",

1341 "hook_event_name": "TaskCompleted",

1342 "task_id": "task-001",

1343 "task_subject": "Implement user authentication",

1344 "task_description": "Add login and signup endpoints",

1345 "teammate_name": "implementer",

1346 "team_name": "my-project"

1347}

1348```

1349 

1350| Field | Description |

1351| :----------------- | :------------------------------------------------------ |

1352| `task_id` | Identifier of the task being completed |

1353| `task_subject` | Title of the task |

1354| `task_description` | Detailed description of the task. May be absent |

1355| `teammate_name` | Name of the teammate completing the task. May be absent |

1356| `team_name` | Name of the team. May be absent |

1357 

1358#### TaskCompleted decision control

1359 

1360TaskCompleted hooks support two ways to control task completion:

1361 

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

1363* **JSON `{"continue": false, "stopReason": "..."}`**: stops the teammate entirely, matching `Stop` hook behavior. The `stopReason` is shown to the user.

1364 

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

1366 

1367```bash theme={null}

1368#!/bin/bash

1369INPUT=$(cat)

1370TASK_SUBJECT=$(echo "$INPUT" | jq -r '.task_subject')

1371 

1372# Run the test suite

1373if ! npm test 2>&1; then

1374 echo "Tests not passing. Fix failing tests before completing: $TASK_SUBJECT" >&2

1375 exit 2

1376fi

1377 

1378exit 0

1379```

1380 

1267### Stop1381### Stop

1268 1382 

1269Runs when the main Claude Code agent has finished responding. Does not run if1383Runs when the main Claude Code agent has finished responding. Does not run if


1377exit 01491exit 0

1378```1492```

1379 1493 

1380### TaskCompleted

1381 

1382Runs when a task is being marked as completed. This fires in two situations: when any agent explicitly marks a task as completed through the TaskUpdate tool, or when an [agent team](/en/agent-teams) teammate finishes its turn with in-progress tasks. Use this to enforce completion criteria like passing tests or lint checks before a task can close.

1383 

1384When a `TaskCompleted` hook exits with code 2, the task is not marked as completed and the stderr message is fed back to the model as feedback. To stop the teammate entirely instead of re-running it, return JSON with `{"continue": false, "stopReason": "..."}`. TaskCompleted hooks do not support matchers and fire on every occurrence.

1385 

1386#### TaskCompleted input

1387 

1388In addition to the [common input fields](#common-input-fields), TaskCompleted hooks receive `task_id`, `task_subject`, and optionally `task_description`, `teammate_name`, and `team_name`.

1389 

1390```json theme={null}

1391{

1392 "session_id": "abc123",

1393 "transcript_path": "/Users/.../.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",

1394 "cwd": "/Users/...",

1395 "permission_mode": "default",

1396 "hook_event_name": "TaskCompleted",

1397 "task_id": "task-001",

1398 "task_subject": "Implement user authentication",

1399 "task_description": "Add login and signup endpoints",

1400 "teammate_name": "implementer",

1401 "team_name": "my-project"

1402}

1403```

1404 

1405| Field | Description |

1406| :----------------- | :------------------------------------------------------ |

1407| `task_id` | Identifier of the task being completed |

1408| `task_subject` | Title of the task |

1409| `task_description` | Detailed description of the task. May be absent |

1410| `teammate_name` | Name of the teammate completing the task. May be absent |

1411| `team_name` | Name of the team. May be absent |

1412 

1413#### TaskCompleted decision control

1414 

1415TaskCompleted hooks support two ways to control task completion:

1416 

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

1418* **JSON `{"continue": false, "stopReason": "..."}`**: stops the teammate entirely, matching `Stop` hook behavior. The `stopReason` is shown to the user.

1419 

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

1421 

1422```bash theme={null}

1423#!/bin/bash

1424INPUT=$(cat)

1425TASK_SUBJECT=$(echo "$INPUT" | jq -r '.task_subject')

1426 

1427# Run the test suite

1428if ! npm test 2>&1; then

1429 echo "Tests not passing. Fix failing tests before completing: $TASK_SUBJECT" >&2

1430 exit 2

1431fi

1432 

1433exit 0

1434```

1435 

1436### ConfigChange1494### ConfigChange

1437 1495 

1438Runs when a configuration file changes during a session. Use this to audit settings changes, enforce security policies, or block unauthorized modifications to configuration files.1496Runs when a configuration file changes during a session. Use this to audit settings changes, enforce security policies, or block unauthorized modifications to configuration files.


1574 1632 

1575When you run `claude --worktree` or a [subagent uses `isolation: "worktree"`](/en/sub-agents#choose-the-subagent-scope), Claude Code creates an isolated working copy using `git worktree`. If you configure a WorktreeCreate hook, it replaces the default git behavior, letting you use a different version control system like SVN, Perforce, or Mercurial.1633When you run `claude --worktree` or a [subagent uses `isolation: "worktree"`](/en/sub-agents#choose-the-subagent-scope), Claude Code creates an isolated working copy using `git worktree`. If you configure a WorktreeCreate hook, it replaces the default git behavior, letting you use a different version control system like SVN, Perforce, or Mercurial.

1576 1634 

1577The hook must print the absolute path to the created worktree directory on stdout. Claude Code uses this path as the working directory for the isolated session.1635The hook must return the absolute path to the created worktree directory. Claude Code uses this path as the working directory for the isolated session. Command hooks print it on stdout; HTTP hooks return it via `hookSpecificOutput.worktreePath`.

1578 1636 

1579This example creates an SVN working copy and prints the path for Claude Code to use. Replace the repository URL with your own:1637This example creates an SVN working copy and prints the path for Claude Code to use. Replace the repository URL with your own:

1580 1638 


1613 1671 

1614#### WorktreeCreate output1672#### WorktreeCreate output

1615 1673 

1616The hook must print the absolute path to the created worktree directory on stdout. If the hook fails or produces no output, worktree creation fails with an error.1674WorktreeCreate hooks do not use the standard allow/block decision model. Instead, the hook's success or failure determines the outcome. The hook must return the absolute path to the created worktree directory:

1617 1675 

1618WorktreeCreate hooks do not use the standard allow/block decision model. Instead, the hook's success or failure determines the outcome. Only `type: "command"` hooks are supported.1676* **Command hooks** (`type: "command"`): print the path on stdout.

1677* **HTTP hooks** (`type: "http"`): return `{ "hookSpecificOutput": { "hookEventName": "WorktreeCreate", "worktreePath": "/absolute/path" } }` in the response body.

1678 

1679If the hook fails or produces no path, worktree creation fails with an error.

1619 1680 

1620### WorktreeRemove1681### WorktreeRemove

1621 1682 

1622The cleanup counterpart to [WorktreeCreate](#worktreecreate). This hook fires when a worktree is being removed, either when you exit a `--worktree` session and choose to remove it, or when a subagent with `isolation: "worktree"` finishes. For git-based worktrees, Claude handles cleanup automatically with `git worktree remove`. If you configured a WorktreeCreate hook for a non-git version control system, pair it with a WorktreeRemove hook to handle cleanup. Without one, the worktree directory is left on disk.1683The cleanup counterpart to [WorktreeCreate](#worktreecreate). This hook fires when a worktree is being removed, either when you exit a `--worktree` session and choose to remove it, or when a subagent with `isolation: "worktree"` finishes. For git-based worktrees, Claude handles cleanup automatically with `git worktree remove`. If you configured a WorktreeCreate hook for a non-git version control system, pair it with a WorktreeRemove hook to handle cleanup. Without one, the worktree directory is left on disk.

1623 1684 

1624Claude Code passes the path that WorktreeCreate printed on stdout as `worktree_path` in the hook input. This example reads that path and removes the directory:1685Claude Code passes the path returned by WorktreeCreate as `worktree_path` in the hook input. This example reads that path and removes the directory:

1625 1686 

1626```json theme={null}1687```json theme={null}

1627{1688{


1654}1715}

1655```1716```

1656 1717 

1657WorktreeRemove hooks have no decision control. They cannot block worktree removal but can perform cleanup tasks like removing version control state or archiving changes. Hook failures are logged in debug mode only. Only `type: "command"` hooks are supported.1718WorktreeRemove hooks have no decision control. They cannot block worktree removal but can perform cleanup tasks like removing version control state or archiving changes. Hook failures are logged in debug mode only.

1658 1719 

1659### PreCompact1720### PreCompact

1660 1721 


1877* `Stop`1938* `Stop`

1878* `SubagentStop`1939* `SubagentStop`

1879* `TaskCompleted`1940* `TaskCompleted`

1941* `TaskCreated`

1880* `UserPromptSubmit`1942* `UserPromptSubmit`

1881 1943 

1882Events that only support `type: "command"` hooks:1944Events that support `command` and `http` hooks but not `prompt` or `agent`:

1883 1945 

1884* `ConfigChange`1946* `ConfigChange`

1885* `CwdChanged`1947* `CwdChanged`


1891* `PostCompact`1953* `PostCompact`

1892* `PreCompact`1954* `PreCompact`

1893* `SessionEnd`1955* `SessionEnd`

1894* `SessionStart`

1895* `StopFailure`1956* `StopFailure`

1896* `SubagentStart`1957* `SubagentStart`

1897* `TeammateIdle`1958* `TeammateIdle`

1898* `WorktreeCreate`1959* `WorktreeCreate`

1899* `WorktreeRemove`1960* `WorktreeRemove`

1900 1961 

1962`SessionStart` supports only `command` hooks.

1963 

1901### How prompt-based hooks work1964### How prompt-based hooks work

1902 1965 

1903Instead of executing a Bash command, prompt-based hooks:1966Instead of executing a Bash command, prompt-based hooks:


2141* **Use absolute paths**: specify full paths for scripts, using `"$CLAUDE_PROJECT_DIR"` for the project root2204* **Use absolute paths**: specify full paths for scripts, using `"$CLAUDE_PROJECT_DIR"` for the project root

2142* **Skip sensitive files**: avoid `.env`, `.git/`, keys, etc.2205* **Skip sensitive files**: avoid `.env`, `.git/`, keys, etc.

2143 2206 

2207## Windows PowerShell tool

2208 

2209On Windows, you can run individual hooks in PowerShell by setting `"shell": "powershell"` on a command hook. Hooks spawn PowerShell directly, so this works regardless of whether `CLAUDE_CODE_USE_POWERSHELL_TOOL` is set. Claude Code auto-detects `pwsh.exe` (PowerShell 7+) with a fallback to `powershell.exe` (5.1).

2210 

2211```json theme={null}

2212{

2213 "hooks": {

2214 "PostToolUse": [

2215 {

2216 "matcher": "Write",

2217 "hooks": [

2218 {

2219 "type": "command",

2220 "shell": "powershell",

2221 "command": "Write-Host 'File written'"

2222 }

2223 ]

2224 }

2225 ]

2226 }

2227}

2228```

2229 

2144## Debug hooks2230## Debug hooks

2145 2231 

2146Run `claude --debug` to see hook execution details, including which hooks matched, their exit codes, and output. Toggle verbose mode with `Ctrl+O` to see hook progress in the transcript.2232Run `claude --debug` to see hook execution details, including which hooks matched, their exit codes, and output. Toggle verbose mode with `Ctrl+O` to see hook progress in the transcript.

hooks-guide.md +4 −3

Details

389| `Notification` | When Claude Code sends a notification |389| `Notification` | When Claude Code sends a notification |

390| `SubagentStart` | When a subagent is spawned |390| `SubagentStart` | When a subagent is spawned |

391| `SubagentStop` | When a subagent finishes |391| `SubagentStop` | When a subagent finishes |

392| `TaskCreated` | When a task is being created via `TaskCreate` |

393| `TaskCompleted` | When a task is being marked as completed |

392| `Stop` | When Claude finishes responding |394| `Stop` | When Claude finishes responding |

393| `StopFailure` | When the turn ends due to an API error. Output and exit code are ignored |395| `StopFailure` | When the turn ends due to an API error. Output and exit code are ignored |

394| `TeammateIdle` | When an [agent team](/en/agent-teams) teammate is about to go idle |396| `TeammateIdle` | When an [agent team](/en/agent-teams) teammate is about to go idle |

395| `TaskCompleted` | When a task is being marked as completed |

396| `InstructionsLoaded` | When a CLAUDE.md or `.claude/rules/*.md` file is loaded into context. Fires at session start and when files are lazily loaded during a session |397| `InstructionsLoaded` | When a CLAUDE.md or `.claude/rules/*.md` file is loaded into context. Fires at session start and when files are lazily loaded during a session |

397| `ConfigChange` | When a configuration file changes during a session |398| `ConfigChange` | When a configuration file changes during a session |

398| `CwdChanged` | When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv |399| `CwdChanged` | When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv |


512Each event type matches on a specific field. Matchers support exact strings and regex patterns:513Each event type matches on a specific field. Matchers support exact strings and regex patterns:

513 514 

514| Event | What the matcher filters | Example matcher values |515| Event | What the matcher filters | Example matcher values |

515| :------------------------------------------------------------------------------------------------------------ | :-------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ |516| :--------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ |

516| `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest` | tool name | `Bash`, `Edit\|Write`, `mcp__.*` |517| `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest` | tool name | `Bash`, `Edit\|Write`, `mcp__.*` |

517| `SessionStart` | how the session started | `startup`, `resume`, `clear`, `compact` |518| `SessionStart` | how the session started | `startup`, `resume`, `clear`, `compact` |

518| `SessionEnd` | why the session ended | `clear`, `resume`, `logout`, `prompt_input_exit`, `bypass_permissions_disabled`, `other` |519| `SessionEnd` | why the session ended | `clear`, `resume`, `logout`, `prompt_input_exit`, `bypass_permissions_disabled`, `other` |


526| `Elicitation` | MCP server name | your configured MCP server names |527| `Elicitation` | MCP server name | your configured MCP server names |

527| `ElicitationResult` | MCP server name | same values as `Elicitation` |528| `ElicitationResult` | MCP server name | same values as `Elicitation` |

528| `FileChanged` | filename (basename of the changed file) | `.envrc`, `.env`, any filename you want to watch |529| `FileChanged` | filename (basename of the changed file) | `.envrc`, `.env`, any filename you want to watch |

529| `UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove`, `CwdChanged` | no matcher support | always fires on every occurrence |530| `UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCreated`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove`, `CwdChanged` | no matcher support | always fires on every occurrence |

530 531 

531A few more examples showing matchers on different event types:532A few more examples showing matchers on different event types:

532 533 

Details

69* **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too.69* **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too.

70* **Your git state.** Current branch, uncommitted changes, and recent commit history.70* **Your git state.** Current branch, uncommitted changes, and recent commit history.

71* **Your [CLAUDE.md](/en/memory).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session.71* **Your [CLAUDE.md](/en/memory).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session.

72* **[Auto memory](/en/memory#auto-memory).** Learnings Claude saves automatically as you work, like project patterns and your preferences. The first 200 lines of MEMORY.md are loaded at the start of each session.72* **[Auto memory](/en/memory#auto-memory).** Learnings Claude saves automatically as you work, like project patterns and your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of each session.

73* **Extensions you configure.** [MCP servers](/en/mcp) for external services, [skills](/en/skills) for workflows, [subagents](/en/sub-agents) for delegated work, and [Claude in Chrome](/en/chrome) for browser interaction.73* **Extensions you configure.** [MCP servers](/en/mcp) for external services, [skills](/en/skills) for workflows, [subagents](/en/sub-agents) for delegated work, and [Claude in Chrome](/en/chrome) for browser interaction.

74 74 

75Because Claude sees your whole project, it can work across it. When you ask Claude to "fix the authentication bug," it searches for relevant files, reads multiple files to understand context, makes coordinated edits across them, runs tests to verify the fix, and commits the changes if you ask. This is different from inline code assistants that only see the current file.75Because Claude sees your whole project, it can work across it. When you ask Claude to "fix the authentication bug," it searches for relevant files, reads multiple files to understand context, makes coordinated edits across them, runs tests to verify the fix, and commits the changes if you ask. This is different from inline code assistants that only see the current file.

Details

45### Text editing45### Text editing

46 46 

47| Shortcut | Description | Context |47| Shortcut | Description | Context |

48| :----------------------- | :--------------------------- | :------------------------------------------------------------------------------------------------------------ |48| :----------------------- | :------------------------------- | :------------------------------------------------------------------------------------------------------------ |

49| `Ctrl+K` | Delete to end of line | Stores deleted text for pasting |49| `Ctrl+K` | Delete to end of line | Stores deleted text for pasting |

50| `Ctrl+U` | Delete entire line | Stores deleted text for pasting |50| `Ctrl+U` | Delete from cursor to line start | Stores deleted text for pasting. Repeat to clear across lines in multiline input |

51| `Ctrl+Y` | Paste deleted text | Paste text deleted with `Ctrl+K` or `Ctrl+U` |51| `Ctrl+Y` | Paste deleted text | Paste text deleted with `Ctrl+K` or `Ctrl+U` |

52| `Alt+Y` (after `Ctrl+Y`) | Cycle paste history | After pasting, cycle through previously deleted text. Requires [Option as Meta](#keyboard-shortcuts) on macOS |52| `Alt+Y` (after `Ctrl+Y`) | Cycle paste history | After pasting, cycle through previously deleted text. Requires [Option as Meta](#keyboard-shortcuts) on macOS |

53| `Alt+B` | Move cursor back one word | Word navigation. Requires [Option as Meta](#keyboard-shortcuts) on macOS |53| `Alt+B` | Move cursor back one word | Word navigation. Requires [Option as Meta](#keyboard-shortcuts) on macOS |

keybindings.md +25 −3

Details

97Actions available in the `Chat` context:97Actions available in the `Chat` context:

98 98 

99| Action | Default | Description |99| Action | Default | Description |

100| :-------------------- | :------------------------ | :------------------------- |100| :-------------------- | :------------------------ | :---------------------------------- |

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

102| `chat:killAgents` | Ctrl+X Ctrl+K | Kill all background agents |102| `chat:killAgents` | Ctrl+X Ctrl+K | Kill all background agents |

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


105| `chat:fastMode` | Meta+O | Toggle fast mode |105| `chat:fastMode` | Meta+O | Toggle fast mode |

106| `chat:thinkingToggle` | Cmd+T / Meta+T | Toggle extended thinking |106| `chat:thinkingToggle` | Cmd+T / Meta+T | Toggle extended thinking |

107| `chat:submit` | Enter | Submit message |107| `chat:submit` | Enter | Submit message |

108| `chat:newline` | (unbound) | Insert a newline without submitting |

108| `chat:undo` | Ctrl+\_ | Undo last action |109| `chat:undo` | Ctrl+\_ | Undo last action |

109| `chat:externalEditor` | Ctrl+G, Ctrl+X Ctrl+E | Open in external editor |110| `chat:externalEditor` | Ctrl+G, Ctrl+X Ctrl+E | Open in external editor |

110| `chat:stash` | Ctrl+S | Stash current prompt |111| `chat:stash` | Ctrl+S | Stash current prompt |


215Actions available in the `Footer` context:216Actions available in the `Footer` context:

216 217 

217| Action | Default | Description |218| Action | Default | Description |

218| :---------------------- | :------ | :------------------------ |219| :---------------------- | :------ | :--------------------------------------- |

219| `footer:next` | Right | Next footer item |220| `footer:next` | Right | Next footer item |

220| `footer:previous` | Left | Previous footer item |221| `footer:previous` | Left | Previous footer item |

222| `footer:up` | Up | Navigate up in footer (deselects at top) |

223| `footer:down` | Down | Navigate down in footer |

221| `footer:openSelected` | Enter | Open selected footer item |224| `footer:openSelected` | Enter | Open selected footer item |

222| `footer:clearSelection` | Escape | Clear footer selection |225| `footer:clearSelection` | Escape | Clear footer selection |

223 226 


317 320 

318A standalone uppercase letter implies Shift. For example, `K` is equivalent to `shift+k`. This is useful for vim-style bindings where uppercase and lowercase keys have different meanings.321A standalone uppercase letter implies Shift. For example, `K` is equivalent to `shift+k`. This is useful for vim-style bindings where uppercase and lowercase keys have different meanings.

319 322 

320Uppercase letters with modifiers (e.g., `ctrl+K`) are treated as stylistic and do **not** imply Shift `ctrl+K` is the same as `ctrl+k`.323Uppercase letters with modifiers (e.g., `ctrl+K`) are treated as stylistic and do **not** imply Shift: `ctrl+K` is the same as `ctrl+k`.

321 324 

322### Chords325### Chords

323 326 


353}356}

354```357```

355 358 

359This also works for chord bindings. Unbinding every chord that shares a prefix frees that prefix for use as a single-key binding:

360 

361```json theme={null}

362{

363 "bindings": [

364 {

365 "context": "Chat",

366 "bindings": {

367 "ctrl+x ctrl+k": null,

368 "ctrl+x ctrl+e": null,

369 "ctrl+x": "chat:newline"

370 }

371 }

372 ]

373}

374```

375 

376If you unbind some but not all chords on a prefix, pressing the prefix still enters chord-wait mode for the remaining bindings.

377 

356## Reserved shortcuts378## Reserved shortcuts

357 379 

358These shortcuts cannot be rebound:380These shortcuts cannot be rebound:

mcp.md +4 −0

Details

498 498 

499MCP server configurations follow a clear precedence hierarchy. When servers with the same name exist at multiple scopes, the system resolves conflicts by prioritizing local-scoped servers first, followed by project-scoped servers, and finally user-scoped servers. This design ensures that personal configurations can override shared ones when needed.499MCP server configurations follow a clear precedence hierarchy. When servers with the same name exist at multiple scopes, the system resolves conflicts by prioritizing local-scoped servers first, followed by project-scoped servers, and finally user-scoped servers. This design ensures that personal configurations can override shared ones when needed.

500 500 

501If a server is configured both locally and through a [claude.ai connector](#use-mcp-servers-from-claude-ai), the local configuration takes precedence and the connector entry is skipped.

502 

501### Environment variable expansion in `.mcp.json`503### Environment variable expansion in `.mcp.json`

502 504 

503Claude Code supports environment variable expansion in `.mcp.json` files, allowing teams to share configurations while maintaining flexibility for machine-specific paths and sensitive values like API keys.505Claude Code supports environment variable expansion in `.mcp.json` files, allowing teams to share configurations while maintaining flexibility for machine-specific paths and sensitive values like API keys.


1070* When Claude should search for your tools1072* When Claude should search for your tools

1071* Key capabilities your server provides1073* Key capabilities your server provides

1072 1074 

1075Claude Code truncates tool descriptions and server instructions at 2KB each. Keep them concise to avoid truncation, and put critical details near the start.

1076 

1073### Configure tool search1077### Configure tool search

1074 1078 

1075Tool search is enabled by default: MCP tools are deferred and discovered on demand. When `ANTHROPIC_BASE_URL` points to a non-first-party host, tool search is disabled by default because most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly if your proxy does. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search.1079Tool search is enabled by default: MCP tools are deferred and discovered on demand. When `ANTHROPIC_BASE_URL` points to a non-first-party host, tool search is disabled by default because most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly if your proxy does. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search.

memory.md +22 −8

Details

14This page covers how to:14This page covers how to:

15 15 

16* [Write and organize CLAUDE.md files](#claude-md-files)16* [Write and organize CLAUDE.md files](#claude-md-files)

17* [Scope rules to specific file types](#organize-rules-with-clauderules) with `.claude/rules/`17* [Scope rules to specific file types](#organize-rules-with-claude/rules/) with `.claude/rules/`

18* [Configure auto memory](#auto-memory) so Claude takes notes automatically18* [Configure auto memory](#auto-memory) so Claude takes notes automatically

19* [Troubleshoot](#troubleshoot-memory-issues) when instructions aren't being followed19* [Troubleshoot](#troubleshoot-memory-issues) when instructions aren't being followed

20 20 


27| **Who writes it** | You | Claude |27| **Who writes it** | You | Claude |

28| **What it contains** | Instructions and rules | Learnings and patterns |28| **What it contains** | Instructions and rules | Learnings and patterns |

29| **Scope** | Project, user, or org | Per working tree |29| **Scope** | Project, user, or org | Per working tree |

30| **Loaded into** | Every session | Every session (first 200 lines) |30| **Loaded into** | Every session | Every session (first 200 lines or 25KB) |

31| **Use for** | Coding standards, workflows, project architecture | Build commands, debugging insights, preferences Claude discovers |31| **Use for** | Coding standards, workflows, project architecture | Build commands, debugging insights, preferences Claude discovers |

32 32 

33Use CLAUDE.md files when you want to guide Claude's behavior. Auto memory lets Claude learn from your corrections without manual effort.33Use CLAUDE.md files when you want to guide Claude's behavior. Auto memory lets Claude learn from your corrections without manual effort.


50 50 

51CLAUDE.md files in the directory hierarchy above the working directory are loaded in full at launch. CLAUDE.md files in subdirectories load on demand when Claude reads files in those directories. See [How CLAUDE.md files load](#how-claude-md-files-load) for the full resolution order.51CLAUDE.md files in the directory hierarchy above the working directory are loaded in full at launch. CLAUDE.md files in subdirectories load on demand when Claude reads files in those directories. See [How CLAUDE.md files load](#how-claude-md-files-load) for the full resolution order.

52 52 

53For large projects, you can break instructions into topic-specific files using [project rules](#organize-rules-with-clauderules). Rules let you scope instructions to specific file types or subdirectories.53For large projects, you can break instructions into topic-specific files using [project rules](#organize-rules-with-claude/rules/). Rules let you scope instructions to specific file types or subdirectories.

54 54 

55### Set up a project CLAUDE.md55### Set up a project CLAUDE.md

56 56 


66 66 

67CLAUDE.md files are loaded into the context window at the start of every session, consuming tokens alongside your conversation. Because they're context rather than enforced configuration, how you write instructions affects how reliably Claude follows them. Specific, concise, well-structured instructions work best.67CLAUDE.md files are loaded into the context window at the start of every session, consuming tokens alongside your conversation. Because they're context rather than enforced configuration, how you write instructions affects how reliably Claude follows them. Specific, concise, well-structured instructions work best.

68 68 

69**Size**: target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence. If your instructions are growing large, split them using [imports](#import-additional-files) or [`.claude/rules/`](#organize-rules-with-clauderules) files.69**Size**: target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence. If your instructions are growing large, split them using [imports](#import-additional-files) or [`.claude/rules/`](#organize-rules-with-claude/rules/) files.

70 70 

71**Structure**: use markdown headers and bullets to group related instructions. Claude scans structure the same way readers do: organized sections are easier to follow than dense paragraphs.71**Structure**: use markdown headers and bullets to group related instructions. Claude scans structure the same way readers do: organized sections are easier to follow than dense paragraphs.

72 72 


76* "Run `npm test` before committing" instead of "Test your changes"76* "Run `npm test` before committing" instead of "Test your changes"

77* "API handlers live in `src/api/handlers/`" instead of "Keep files organized"77* "API handlers live in `src/api/handlers/`" instead of "Keep files organized"

78 78 

79**Consistency**: if two rules contradict each other, Claude may pick one arbitrarily. Review your CLAUDE.md files, nested CLAUDE.md files in subdirectories, and [`.claude/rules/`](#organize-rules-with-clauderules) periodically to remove outdated or conflicting instructions. In monorepos, use [`claudeMdExcludes`](#exclude-specific-claude-md-files) to skip CLAUDE.md files from other teams that aren't relevant to your work.79**Consistency**: if two rules contradict each other, Claude may pick one arbitrarily. Review your CLAUDE.md files, nested CLAUDE.md files in subdirectories, and [`.claude/rules/`](#organize-rules-with-claude/rules/) periodically to remove outdated or conflicting instructions. In monorepos, use [`claudeMdExcludes`](#exclude-specific-claude-md-files) to skip CLAUDE.md files from other teams that aren't relevant to your work.

80 80 

81### Import additional files81### Import additional files

82 82 


104 The first time Claude Code encounters external imports in a project, it shows an approval dialog listing the files. If you decline, the imports stay disabled and the dialog does not appear again.104 The first time Claude Code encounters external imports in a project, it shows an approval dialog listing the files. If you decline, the imports stay disabled and the dialog does not appear again.

105</Warning>105</Warning>

106 106 

107For a more structured approach to organizing instructions, see [`.claude/rules/`](#organize-rules-with-clauderules).107For a more structured approach to organizing instructions, see [`.claude/rules/`](#organize-rules-with-claude/rules/).

108 

109### AGENTS.md

110 

111Claude Code reads `CLAUDE.md`, not `AGENTS.md`. If your repository already uses `AGENTS.md` for other coding agents, create a `CLAUDE.md` that imports it so both tools read the same instructions without duplicating them. You can also add Claude-specific instructions below the import. Claude loads the imported file at session start, then appends the rest:

112 

113```markdown CLAUDE.md theme={null}

114@AGENTS.md

115 

116## Claude Code

117 

118Use plan mode for changes under `src/billing/`.

119```

108 120 

109### How CLAUDE.md files load121### How CLAUDE.md files load

110 122 


114 126 

115If you work in a large monorepo where other teams' CLAUDE.md files get picked up, use [`claudeMdExcludes`](#exclude-specific-claude-md-files) to skip them.127If you work in a large monorepo where other teams' CLAUDE.md files get picked up, use [`claudeMdExcludes`](#exclude-specific-claude-md-files) to skip them.

116 128 

129Block-level HTML comments (`<!-- maintainer notes -->`) in CLAUDE.md files are stripped before the content is injected into Claude's context. Use them to leave notes for human maintainers without spending context tokens on them. Comments inside code blocks are preserved. When you open a CLAUDE.md file directly with the Read tool, comments remain visible.

130 

117#### Load from additional directories131#### Load from additional directories

118 132 

119The `--add-dir` flag gives Claude access to additional directories outside your main working directory. By default, CLAUDE.md files from these directories are not loaded.133The `--add-dir` flag gives Claude access to additional directories outside your main working directory. By default, CLAUDE.md files from these directories are not loaded.


313 327 

314### How it works328### How it works

315 329 

316The first 200 lines of `MEMORY.md` are loaded at the start of every conversation. Content beyond line 200 is not loaded at session start. Claude keeps `MEMORY.md` concise by moving detailed notes into separate topic files.330The first 200 lines of `MEMORY.md`, or the first 25KB, whichever comes first, are loaded at the start of every conversation. Content beyond that threshold is not loaded at session start. Claude keeps `MEMORY.md` concise by moving detailed notes into separate topic files.

317 331 

318This 200-line limit applies only to `MEMORY.md`. CLAUDE.md files are loaded in full regardless of length, though shorter files produce better adherence.332This limit applies only to `MEMORY.md`. CLAUDE.md files are loaded in full regardless of length, though shorter files produce better adherence.

319 333 

320Topic files like `debugging.md` or `patterns.md` are not loaded at startup. Claude reads them on demand using its standard file tools when it needs the information.334Topic files like `debugging.md` or `patterns.md` are not loaded at startup. Claude reads them on demand using its standard file tools when it needs the information.

321 335 

model-config.md +35 −0

Details

253 The `settings.availableModels` allowlist still applies when using third-party providers. Filtering matches on the model alias (`opus`, `sonnet`, `haiku`), not the provider-specific model ID.253 The `settings.availableModels` allowlist still applies when using third-party providers. Filtering matches on the model alias (`opus`, `sonnet`, `haiku`), not the provider-specific model ID.

254</Note>254</Note>

255 255 

256### Customize pinned model display and capabilities

257 

258When you pin a model on a third-party provider, the provider-specific ID appears as-is in the `/model` picker and Claude Code may not recognize which features the model supports. You can override the display name and declare capabilities with companion environment variables for each pinned model.

259 

260These variables only take effect on third-party providers such as Bedrock, Vertex AI, and Foundry. They have no effect when using the Anthropic API directly.

261 

262| Environment variable | Description |

263| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |

264| `ANTHROPIC_DEFAULT_OPUS_MODEL_NAME` | Display name for the pinned Opus model in the `/model` picker. Defaults to the model ID when not set |

265| `ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION` | Display description for the pinned Opus model in the `/model` picker. Defaults to `Custom Opus model` when not set |

266| `ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES` | Comma-separated list of capabilities the pinned Opus model supports |

267 

268The same `_NAME`, `_DESCRIPTION`, and `_SUPPORTED_CAPABILITIES` suffixes are available for `ANTHROPIC_DEFAULT_SONNET_MODEL` and `ANTHROPIC_DEFAULT_HAIKU_MODEL`.

269 

270Claude Code enables features like [effort levels](#adjust-effort-level) and [extended thinking](/en/common-workflows#use-extended-thinking-thinking-mode) by matching the model ID against known patterns. Provider-specific IDs such as Bedrock ARNs or custom deployment names often don't match these patterns, leaving supported features disabled. Set `_SUPPORTED_CAPABILITIES` to tell Claude Code which features the model actually supports:

271 

272| Capability value | Enables |

273| ---------------------- | ------------------------------------------------------------------------------- |

274| `effort` | [Effort levels](#adjust-effort-level) and the `/effort` command |

275| `max_effort` | The `max` effort level |

276| `thinking` | [Extended thinking](/en/common-workflows#use-extended-thinking-thinking-mode) |

277| `adaptive_thinking` | Adaptive reasoning that dynamically allocates thinking based on task complexity |

278| `interleaved_thinking` | Thinking between tool calls |

279 

280When `_SUPPORTED_CAPABILITIES` is set, listed capabilities are enabled and unlisted capabilities are disabled for the matching pinned model. When the variable is unset, Claude Code falls back to built-in detection based on the model ID.

281 

282This example pins Opus to a Bedrock custom model ARN, sets a friendly name, and declares its capabilities:

283 

284```bash theme={null}

285export ANTHROPIC_DEFAULT_OPUS_MODEL='arn:aws:bedrock:us-east-1:123456789012:custom-model/abc'

286export ANTHROPIC_DEFAULT_OPUS_MODEL_NAME='Opus via Bedrock'

287export ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION='Opus 4.6 routed through a Bedrock custom endpoint'

288export ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES='effort,max_effort,thinking,adaptive_thinking,interleaved_thinking'

289```

290 

256### Override model IDs per version291### Override model IDs per version

257 292 

258The family-level environment variables above configure one model ID per family alias. If you need to map several versions within the same family to distinct provider IDs, use the `modelOverrides` setting instead.293The family-level environment variables above configure one model ID per family alias. If you need to map several versions within the same family to distinct provider IDs, use the `modelOverrides` setting instead.

permissions.md +2 −1

Details

237Some settings are only effective in managed settings:237Some settings are only effective in managed settings:

238 238 

239| Setting | Description |239| Setting | Description |

240| :--------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |240| :--------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

241| `allowManagedPermissionRulesOnly` | When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply |241| `allowManagedPermissionRulesOnly` | When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply |

242| `allowManagedHooksOnly` | When `true`, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed |242| `allowManagedHooksOnly` | When `true`, prevents loading of user, project, and plugin hooks. Only managed hooks and SDK hooks are allowed |

243| `allowManagedMcpServersOnly` | When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](/en/mcp#managed-mcp-configuration) |243| `allowManagedMcpServersOnly` | When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](/en/mcp#managed-mcp-configuration) |

244| `allowedChannelPlugins` | Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](/en/channels#restrict-which-channel-plugins-can-run) |

244| `blockedMarketplaces` | Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](/en/plugin-marketplaces#managed-marketplace-restrictions) |245| `blockedMarketplaces` | Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](/en/plugin-marketplaces#managed-marketplace-restrictions) |

245| `sandbox.network.allowManagedDomainsOnly` | When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources |246| `sandbox.network.allowManagedDomainsOnly` | When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources |

246| `sandbox.filesystem.allowManagedReadPathsOnly` | When `true`, only `allowRead` paths from managed settings are respected. `allowRead` entries from user, project, and local settings are ignored |247| `sandbox.filesystem.allowManagedReadPathsOnly` | When `true`, only `allowRead` paths from managed settings are respected. `allowRead` entries from user, project, and local settings are ignored |

plugins.md +1 −1

Details

131 You'll see Claude respond with a greeting. Run `/help` to see your skill listed under the plugin namespace.131 You'll see Claude respond with a greeting. Run `/help` to see your skill listed under the plugin namespace.

132 132 

133 <Note>133 <Note>

134 **Why namespacing?** Plugin skills are always namespaced (like `/greet:hello`) to prevent conflicts when multiple plugins have skills with the same name.134 **Why namespacing?** Plugin skills are always namespaced (like `/my-first-plugin:hello`) to prevent conflicts when multiple plugins have skills with the same name.

135 135 

136 To change the namespace prefix, update the `name` field in `plugin.json`.136 To change the namespace prefix, update the `name` field in `plugin.json`.

137 </Note>137 </Note>

Details

119| `Notification` | When Claude Code sends a notification |119| `Notification` | When Claude Code sends a notification |

120| `SubagentStart` | When a subagent is spawned |120| `SubagentStart` | When a subagent is spawned |

121| `SubagentStop` | When a subagent finishes |121| `SubagentStop` | When a subagent finishes |

122| `TaskCreated` | When a task is being created via `TaskCreate` |

123| `TaskCompleted` | When a task is being marked as completed |

122| `Stop` | When Claude finishes responding |124| `Stop` | When Claude finishes responding |

123| `StopFailure` | When the turn ends due to an API error. Output and exit code are ignored |125| `StopFailure` | When the turn ends due to an API error. Output and exit code are ignored |

124| `TeammateIdle` | When an [agent team](/en/agent-teams) teammate is about to go idle |126| `TeammateIdle` | When an [agent team](/en/agent-teams) teammate is about to go idle |

125| `TaskCompleted` | When a task is being marked as completed |

126| `InstructionsLoaded` | When a CLAUDE.md or `.claude/rules/*.md` file is loaded into context. Fires at session start and when files are lazily loaded during a session |127| `InstructionsLoaded` | When a CLAUDE.md or `.claude/rules/*.md` file is loaded into context. Fires at session start and when files are lazily loaded during a session |

127| `ConfigChange` | When a configuration file changes during a session |128| `ConfigChange` | When a configuration file changes during a session |

128| `CwdChanged` | When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv |129| `CwdChanged` | When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv |


340 341 

341| Field | Type | Description | Example |342| Field | Type | Description | Example |

342| :------------- | :-------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------- |343| :------------- | :-------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------- |

343| `commands` | string\|array | Additional command files/directories | `"./custom/cmd.md"` or `["./cmd1.md"]` |344| `commands` | string\|array | Custom command files/directories (replaces default `commands/`) | `"./custom/cmd.md"` or `["./cmd1.md"]` |

344| `agents` | string\|array | Additional agent files | `"./custom/agents/reviewer.md"` |345| `agents` | string\|array | Custom agent files (replaces default `agents/`) | `"./custom/agents/reviewer.md"` |

345| `skills` | string\|array | Additional skill directories | `"./custom/skills/"` |346| `skills` | string\|array | Custom skill directories (replaces default `skills/`) | `"./custom/skills/"` |

346| `hooks` | string\|array\|object | Hook config paths or inline config | `"./my-extra-hooks.json"` |347| `hooks` | string\|array\|object | Hook config paths or inline config | `"./my-extra-hooks.json"` |

347| `mcpServers` | string\|array\|object | MCP config paths or inline config | `"./my-extra-mcp-config.json"` |348| `mcpServers` | string\|array\|object | MCP config paths or inline config | `"./my-extra-mcp-config.json"` |

348| `outputStyles` | string\|array | Additional output style files/directories | `"./styles/"` |349| `outputStyles` | string\|array | Custom output style files/directories (replaces default `output-styles/`) | `"./styles/"` |

349| `lspServers` | string\|array\|object | [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) configs for code intelligence (go to definition, find references, etc.) | `"./.lsp.json"` |350| `lspServers` | string\|array\|object | [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) configs for code intelligence (go to definition, find references, etc.) | `"./.lsp.json"` |

350| `userConfig` | object | User-configurable values prompted at enable time. See [User configuration](#user-configuration) | See below |351| `userConfig` | object | User-configurable values prompted at enable time. See [User configuration](#user-configuration) | See below |

351| `channels` | array | Channel declarations for message injection (Telegram, Slack, Discord style). See [Channels](#channels) | See below |352| `channels` | array | Channel declarations for message injection (Telegram, Slack, Discord style). See [Channels](#channels) | See below |


395 396 

396### Path behavior rules397### Path behavior rules

397 398 

398**Important**: Custom paths supplement default directories - they don't replace them.399For `commands`, `agents`, `skills`, and `outputStyles`, custom paths replace the default directory. If the manifest specifies `commands`, the default `commands/` directory is not scanned. [Hooks](#hooks), [MCP servers](#mcp-servers), and [LSP servers](#lsp-servers) have different semantics for handling multiple sources.

399 400 

400* If `commands/` exists, it's loaded in addition to custom command paths401* All paths must be relative to the plugin root and start with `./`

401* All paths must be relative to plugin root and start with `./`402* Components from custom paths use the same naming and namespacing rules

402* Commands from custom paths use the same naming and namespacing rules403* Multiple paths can be specified as arrays

403* Multiple paths can be specified as arrays for flexibility404* To keep the default directory and add more paths for commands, agents, skills, or output styles, include the default in your array: `"commands": ["./commands/", "./extras/deploy.md"]`

404 405 

405**Path examples**:406**Path examples**:

406 407 


538│ └── pdf-processor/539│ └── pdf-processor/

539│ ├── SKILL.md540│ ├── SKILL.md

540│ └── scripts/541│ └── scripts/

542├── output-styles/ # Output style definitions

543│ └── terse.md

541├── hooks/ # Hook configurations544├── hooks/ # Hook configurations

542│ ├── hooks.json # Main hook config545│ ├── hooks.json # Main hook config

543│ └── security-hooks.json # Additional hooks546│ └── security-hooks.json # Additional hooks


553```556```

554 557 

555<Warning>558<Warning>

556 The `.claude-plugin/` directory contains the `plugin.json` file. All other directories (commands/, agents/, skills/, hooks/) must be at the plugin root, not inside `.claude-plugin/`.559 The `.claude-plugin/` directory contains the `plugin.json` file. All other directories (commands/, agents/, skills/, output-styles/, hooks/) must be at the plugin root, not inside `.claude-plugin/`.

557</Warning>560</Warning>

558 561 

559### File locations reference562### File locations reference

560 563 

561| Component | Default Location | Purpose |564| Component | Default Location | Purpose |

562| :-------------- | :--------------------------- | :------------------------------------------------------------------------------------------------------------------------ |565| :---------------- | :--------------------------- | :------------------------------------------------------------------------------------------------------------------------ |

563| **Manifest** | `.claude-plugin/plugin.json` | Plugin metadata and configuration (optional) |566| **Manifest** | `.claude-plugin/plugin.json` | Plugin metadata and configuration (optional) |

564| **Commands** | `commands/` | Skill Markdown files (legacy; use `skills/` for new skills) |567| **Commands** | `commands/` | Skill Markdown files (legacy; use `skills/` for new skills) |

565| **Agents** | `agents/` | Subagent Markdown files |568| **Agents** | `agents/` | Subagent Markdown files |

566| **Skills** | `skills/` | Skills with `<name>/SKILL.md` structure |569| **Skills** | `skills/` | Skills with `<name>/SKILL.md` structure |

570| **Output styles** | `output-styles/` | Output style definitions |

567| **Hooks** | `hooks/hooks.json` | Hook configuration |571| **Hooks** | `hooks/hooks.json` | Hook configuration |

568| **MCP servers** | `.mcp.json` | MCP server definitions |572| **MCP servers** | `.mcp.json` | MCP server definitions |

569| **LSP servers** | `.lsp.json` | Language server configurations |573| **LSP servers** | `.lsp.json` | Language server configurations |


696 700 

697### Debugging commands701### Debugging commands

698 702 

699Use `claude --debug` (or `/debug` within the TUI) to see plugin loading details:703Use `claude --debug` to see plugin loading details:

700 704 

701This shows:705This shows:

702 706 

Details

137 137 

138## Troubleshooting138## Troubleshooting

139 139 

140### "Remote Control requires a claude.ai subscription"

141 

142You're not authenticated with a claude.ai account. Run `claude auth login` and choose the claude.ai option. If `ANTHROPIC_API_KEY` is set in your environment, unset it first.

143 

144### "Remote Control requires a full-scope login token"

145 

146You're authenticated with a long-lived token from `claude setup-token` or the `CLAUDE_CODE_OAUTH_TOKEN` environment variable. These tokens are limited to inference-only and cannot establish Remote Control sessions. Run `claude auth login` to authenticate with a full-scope session token instead.

147 

148### "Unable to determine your organization for Remote Control eligibility"

149 

150Your cached account information is stale or incomplete. Run `claude auth login` to refresh it.

151 

140### "Remote Control is not yet enabled for your account"152### "Remote Control is not yet enabled for your account"

141 153 

142The eligibility check can fail with certain environment variables present:154The eligibility check can fail with certain environment variables present:

settings.md +1 −0

Details

167| `disableAutoMode` | Set to `"disable"` to prevent [auto mode](/en/permission-modes#eliminate-prompts-with-auto-mode) from being activated. Removes `auto` from the `Shift+Tab` cycle and rejects `--permission-mode auto` at startup. Most useful in [managed settings](/en/permissions#managed-settings) where users cannot override it | `"disable"` |167| `disableAutoMode` | Set to `"disable"` to prevent [auto mode](/en/permission-modes#eliminate-prompts-with-auto-mode) from being activated. Removes `auto` from the `Shift+Tab` cycle and rejects `--permission-mode auto` at startup. Most useful in [managed settings](/en/permissions#managed-settings) where users cannot override it | `"disable"` |

168| `useAutoModeDuringPlan` | Whether plan mode uses auto mode semantics when auto mode is available. Default: `true`. Not read from shared project settings. Appears in `/config` as "Use auto mode during plan" | `false` |168| `useAutoModeDuringPlan` | Whether plan mode uses auto mode semantics when auto mode is available. Default: `true`. Not read from shared project settings. Appears in `/config` as "Use auto mode during plan" | `false` |

169| `hooks` | Configure custom commands to run at lifecycle events. See [hooks documentation](/en/hooks) for format | See [hooks](/en/hooks) |169| `hooks` | Configure custom commands to run at lifecycle events. See [hooks documentation](/en/hooks) for format | See [hooks](/en/hooks) |

170| `defaultShell` | Default shell for input-box `!` commands. Accepts `"bash"` (default) or `"powershell"`. Setting `"powershell"` routes interactive `!` commands through PowerShell on Windows. Requires `CLAUDE_CODE_USE_POWERSHELL_TOOL=1`. See [PowerShell tool](/en/tools-reference#powershell-tool) | `"powershell"` |

170| `disableAllHooks` | Disable all [hooks](/en/hooks) and any custom [status line](/en/statusline) | `true` |171| `disableAllHooks` | Disable all [hooks](/en/hooks) and any custom [status line](/en/statusline) | `true` |

171| `allowManagedHooksOnly` | (Managed settings only) Prevent loading of user, project, and plugin hooks. Only allows managed hooks and SDK hooks. See [Hook configuration](#hook-configuration) | `true` |172| `allowManagedHooksOnly` | (Managed settings only) Prevent loading of user, project, and plugin hooks. Only allows managed hooks and SDK hooks. See [Hook configuration](#hook-configuration) | `true` |

172| `allowedHttpHookUrls` | Allowlist of URL patterns that HTTP hooks may target. Supports `*` as a wildcard. When set, hooks with non-matching URLs are blocked. Undefined = no restriction, empty array = block all HTTP hooks. Arrays merge across settings sources. See [Hook configuration](#hook-configuration) | `["https://hooks.example.com/*"]` |173| `allowedHttpHookUrls` | Allowlist of URL patterns that HTTP hooks may target. Supports `*` as a wildcard. When set, hooks with non-matching URLs are blocked. Undefined = no restriction, empty array = block all HTTP hooks. Arrays merge across settings sources. See [Hook configuration](#hook-configuration) | `["https://hooks.example.com/*"]` |

setup.md +2 −0

Details

111}111}

112```112```

113 113 

114Claude Code can also run PowerShell natively on Windows as an opt-in preview. See [PowerShell tool](/en/tools-reference#powershell-tool) for setup and limitations.

115 

114**Option 2: WSL**116**Option 2: WSL**

115 117 

116Both WSL 1 and WSL 2 are supported. WSL 2 supports [sandboxing](/en/sandboxing) for enhanced security. WSL 1 does not support sandboxing.118Both WSL 1 and WSL 2 are supported. WSL 2 supports [sandboxing](/en/sandboxing) for enhanced security. WSL 1 does not support sandboxing.

skills.md +4 −2

Details

26| :-------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |26| :-------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

27| `/batch <instruction>` | Orchestrate large-scale changes across a codebase in parallel. Researches the codebase, decomposes the work into 5 to 30 independent units, and presents a plan. Once approved, spawns one background agent per unit in an isolated [git worktree](/en/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees). Each agent implements its unit, runs tests, and opens a pull request. Requires a git repository. Example: `/batch migrate src/ from Solid to React` |27| `/batch <instruction>` | Orchestrate large-scale changes across a codebase in parallel. Researches the codebase, decomposes the work into 5 to 30 independent units, and presents a plan. Once approved, spawns one background agent per unit in an isolated [git worktree](/en/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees). Each agent implements its unit, runs tests, and opens a pull request. Requires a git repository. Example: `/batch migrate src/ from Solid to React` |

28| `/claude-api` | Load Claude API reference material for your project's language (Python, TypeScript, Java, Go, Ruby, C#, PHP, or cURL) and Agent SDK reference for Python and TypeScript. Covers tool use, streaming, batches, structured outputs, and common pitfalls. Also activates automatically when your code imports `anthropic`, `@anthropic-ai/sdk`, or `claude_agent_sdk` |28| `/claude-api` | Load Claude API reference material for your project's language (Python, TypeScript, Java, Go, Ruby, C#, PHP, or cURL) and Agent SDK reference for Python and TypeScript. Covers tool use, streaming, batches, structured outputs, and common pitfalls. Also activates automatically when your code imports `anthropic`, `@anthropic-ai/sdk`, or `claude_agent_sdk` |

29| `/debug [description]` | Troubleshoot your current Claude Code session by reading the session debug log. Optionally describe the issue to focus the analysis |29| `/debug [description]` | Enable debug logging for the current session and troubleshoot issues by reading the session debug log. Debug logging is off by default unless you started with `claude --debug`, so running `/debug` mid-session starts capturing logs from that point forward. Optionally describe the issue to focus the analysis |

30| `/loop [interval] <prompt>` | Run a prompt repeatedly on an interval while the session stays open. Useful for polling a deployment, babysitting a PR, or periodically re-running another skill. Example: `/loop 5m check if the deploy finished`. See [Run prompts on a schedule](/en/scheduled-tasks) |30| `/loop [interval] <prompt>` | Run a prompt repeatedly on an interval while the session stays open. Useful for polling a deployment, babysitting a PR, or periodically re-running another skill. Example: `/loop 5m check if the deploy finished`. See [Run prompts on a schedule](/en/scheduled-tasks) |

31| `/simplify [focus]` | Review your recently changed files for code reuse, quality, and efficiency issues, then fix them. Spawns three review agents in parallel, aggregates their findings, and applies fixes. Pass text to focus on specific concerns: `/simplify focus on memory efficiency` |31| `/simplify [focus]` | Review your recently changed files for code reuse, quality, and efficiency issues, then fix them. Spawns three review agents in parallel, aggregates their findings, and applies fixes. Pass text to focus on specific concerns: `/simplify focus on memory efficiency` |

32 32 


187All fields are optional. Only `description` is recommended so Claude knows when to use the skill.187All fields are optional. Only `description` is recommended so Claude knows when to use the skill.

188 188 

189| Field | Required | Description |189| Field | Required | Description |

190| :------------------------- | :---------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |190| :------------------------- | :---------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

191| `name` | No | Display name for the skill. If omitted, uses the directory name. Lowercase letters, numbers, and hyphens only (max 64 characters). |191| `name` | No | Display name for the skill. If omitted, uses the directory name. Lowercase letters, numbers, and hyphens only (max 64 characters). |

192| `description` | Recommended | What the skill does and when to use it. Claude uses this to decide when to apply the skill. If omitted, uses the first paragraph of markdown content. |192| `description` | Recommended | What the skill does and when to use it. Claude uses this to decide when to apply the skill. If omitted, uses the first paragraph of markdown content. |

193| `argument-hint` | No | Hint shown during autocomplete to indicate expected arguments. Example: `[issue-number]` or `[filename] [format]`. |193| `argument-hint` | No | Hint shown during autocomplete to indicate expected arguments. Example: `[issue-number]` or `[filename] [format]`. |


199| `context` | No | Set to `fork` to run in a forked subagent context. |199| `context` | No | Set to `fork` to run in a forked subagent context. |

200| `agent` | No | Which subagent type to use when `context: fork` is set. |200| `agent` | No | Which subagent type to use when `context: fork` is set. |

201| `hooks` | No | Hooks scoped to this skill's lifecycle. See [Hooks in skills and agents](/en/hooks#hooks-in-skills-and-agents) for configuration format. |201| `hooks` | No | Hooks scoped to this skill's lifecycle. See [Hooks in skills and agents](/en/hooks#hooks-in-skills-and-agents) for configuration format. |

202| `paths` | No | Glob patterns that limit when this skill is activated. Accepts a comma-separated string or a YAML list. When set, Claude loads the skill automatically only when working with files matching the patterns. Uses the same format as [path-specific rules](/en/memory#path-specific-rules). |

203| `shell` | No | Shell to use for `` !`command` `` blocks in this skill. Accepts `bash` (default) or `powershell`. Setting `powershell` runs inline shell commands via PowerShell on Windows. Requires `CLAUDE_CODE_USE_POWERSHELL_TOOL=1`. |

202 204 

203#### Available string substitutions205#### Available string substitutions

204 206 

sub-agents.md +7 −0

Details

245* **inherit**: Use the same model as the main conversation245* **inherit**: Use the same model as the main conversation

246* **Omitted**: If not specified, defaults to `inherit` (uses the same model as the main conversation)246* **Omitted**: If not specified, defaults to `inherit` (uses the same model as the main conversation)

247 247 

248When Claude invokes a subagent, it can also pass a `model` parameter for that specific invocation. Claude Code resolves the subagent's model in this order:

249 

2501. The [`CLAUDE_CODE_SUBAGENT_MODEL`](/en/model-config#environment-variables) environment variable, if set

2512. The per-invocation `model` parameter

2523. The subagent definition's `model` frontmatter

2534. The main conversation's model

254 

248### Control subagent capabilities255### Control subagent capabilities

249 256 

250You can control what subagents can do through tool access, permission modes, and conditional rules.257You can control what subagents can do through tool access, permission modes, and conditional rules.

Details

26| `ListMcpResourcesTool` | Lists resources exposed by connected [MCP servers](/en/mcp) | No |26| `ListMcpResourcesTool` | Lists resources exposed by connected [MCP servers](/en/mcp) | No |

27| `LSP` | Code intelligence via language servers. Reports type errors and warnings automatically after file edits. Also supports navigation operations: jump to definitions, find references, get type info, list symbols, find implementations, trace call hierarchies. Requires a [code intelligence plugin](/en/discover-plugins#code-intelligence) and its language server binary | No |27| `LSP` | Code intelligence via language servers. Reports type errors and warnings automatically after file edits. Also supports navigation operations: jump to definitions, find references, get type info, list symbols, find implementations, trace call hierarchies. Requires a [code intelligence plugin](/en/discover-plugins#code-intelligence) and its language server binary | No |

28| `NotebookEdit` | Modifies Jupyter notebook cells | Yes |28| `NotebookEdit` | Modifies Jupyter notebook cells | Yes |

29| `PowerShell` | Executes PowerShell commands on Windows. Opt-in preview. See [PowerShell tool](#powershell-tool) | Yes |

29| `Read` | Reads the contents of files | No |30| `Read` | Reads the contents of files | No |

30| `ReadMcpResourceTool` | Reads a specific MCP resource by URI | No |31| `ReadMcpResourceTool` | Reads a specific MCP resource by URI | No |

31| `Skill` | Executes a [skill](/en/skills#control-who-invokes-a-skill) within the main conversation | Yes |32| `Skill` | Executes a [skill](/en/skills#control-who-invokes-a-skill) within the main conversation | Yes |


52 53 

53Activate your virtualenv or conda environment before launching Claude Code. To make environment variables persist across Bash commands, set [`CLAUDE_ENV_FILE`](/en/env-vars) to a shell script before launching Claude Code, or use a [SessionStart hook](/en/hooks#persist-environment-variables) to populate it dynamically.54Activate your virtualenv or conda environment before launching Claude Code. To make environment variables persist across Bash commands, set [`CLAUDE_ENV_FILE`](/en/env-vars) to a shell script before launching Claude Code, or use a [SessionStart hook](/en/hooks#persist-environment-variables) to populate it dynamically.

54 55 

56## PowerShell tool

57 

58On Windows, Claude Code can run PowerShell commands natively instead of routing through Git Bash. This is an opt-in preview.

59 

60### Enable the PowerShell tool

61 

62Set `CLAUDE_CODE_USE_POWERSHELL_TOOL=1` in your environment or in `settings.json`:

63 

64```json theme={null}

65{

66 "env": {

67 "CLAUDE_CODE_USE_POWERSHELL_TOOL": "1"

68 }

69}

70```

71 

72Claude Code auto-detects `pwsh.exe` (PowerShell 7+) with a fallback to `powershell.exe` (PowerShell 5.1). The Bash tool remains registered alongside the PowerShell tool, so you may need to ask Claude to use PowerShell.

73 

74### Shell selection in settings, hooks, and skills

75 

76Three additional settings control where PowerShell is used:

77 

78* `"defaultShell": "powershell"` in [`settings.json`](/en/settings#available-settings): routes interactive `!` commands through PowerShell. Requires the PowerShell tool to be enabled.

79* `"shell": "powershell"` on individual [command hooks](/en/hooks#command-hook-fields): runs that hook in PowerShell. Hooks spawn PowerShell directly, so this works regardless of `CLAUDE_CODE_USE_POWERSHELL_TOOL`.

80* `shell: powershell` in [skill frontmatter](/en/skills#frontmatter-reference): runs `` !`command` `` blocks in PowerShell. Requires the PowerShell tool to be enabled.

81 

82### Preview limitations

83 

84The PowerShell tool has the following known limitations during the preview:

85 

86* Auto mode does not work with the PowerShell tool yet

87* PowerShell profiles are not loaded

88* Sandboxing is not supported

89* Only supported on native Windows, not WSL

90* Git Bash is still required to start Claude Code

91 

55## See also92## See also

56 93 

57* [Permissions](/en/permissions): permission system, rule syntax, and tool-specific patterns94* [Permissions](/en/permissions): permission system, rule syntax, and tool-specific patterns

vs-code.md +25 −0

Details

234| Show Logs | - | View extension debug logs |234| Show Logs | - | View extension debug logs |

235| Logout | - | Sign out of your Anthropic account |235| Logout | - | Sign out of your Anthropic account |

236 236 

237### Launch a VS Code tab from other tools

238 

239The extension registers a URI handler at `vscode://anthropic.claude-code/open`. Use it to open a new Claude Code tab from your own tooling: a shell alias, a browser bookmarklet, or any script that can open a URL. If VS Code isn't already running, opening the URL launches it first. If VS Code is already running, the URL opens in whichever window is currently focused.

240 

241Invoke the handler with your operating system's URL opener. On macOS:

242 

243```bash theme={null}

244open "vscode://anthropic.claude-code/open"

245```

246 

247Use `xdg-open` on Linux or `start` on Windows.

248 

249The handler accepts two optional query parameters:

250 

251| Parameter | Description |

252| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

253| `prompt` | Text to pre-fill in the prompt box. Must be URL-encoded. The prompt is pre-filled but not submitted automatically. |

254| `session` | A session ID to resume instead of starting a new conversation. The session must belong to the workspace currently open in VS Code. If the session isn't found, a fresh conversation starts instead. If the session is already open in a tab, that tab is focused. To capture a session ID programmatically, see [Continue conversations](/en/headless#continue-conversations). |

255 

256For example, to open a tab pre-filled with "review my changes":

257 

258```text theme={null}

259vscode://anthropic.claude-code/open?prompt=review%20my%20changes

260```

261 

237## Configure settings262## Configure settings

238 263 

239The extension has two types of settings:264The extension has two types of settings: