Follow Discord
Sweep 22 Oct 2026 · 21:04Z Build v2.1.309 528 read Stable v2.1.308 Latest v2.1.309 Next v2.1.309 Feeds RSS JSON llms.txt llms-full.txt Unofficial
HomeDocsSearch
Search the documentation

109 pages for /hooks.

Titles and paths first, then pages whose text carries it. Each row opens that page as this site last read it.

Monitoring Claude Code CLI · in the page monitoring-usage …e environment. When a `PreToolUse` hook [defers a tool call](/docs/en/hooks.md#defer-a-tool-call-for-later), Claude Code saves the trace context of the turn that deferred it. When you resume the sess… Output styles Claude Code CLI · in the page output-styles …ormatting after each edit or blocking a command, use a [hook](/docs/en/hooks-guide.md). > * For skills, subagents, and the other options, see [Choose between an output style and other features](#choos… Overview Claude Code CLI · in the page overview …an share, like `/review-pr` or `/deploy-staging`. > > [Hooks](/docs/en/hooks.md) let you run shell commands before or after Claude Code actions, like auto-formatting after every file edit or running l… Choose a permission mode Claude Code CLI · in the page permission-modes …ules](/docs/en/permissions#manage-permissions) or by a [hook](/docs/en/hooks.md#pretooluse-decision-control), because auto mode still shows you those prompts, so switching wouldn't remove them. **At… Configure permissions Claude Code CLI · in the page permissions …nonical name `TaskStop`. Permission rules and [hook matchers](/docs/en/hooks.md) don't match the label, so a rule written as `Stop Task` doesn't match. For deny and ask rules, a [startup warning](/doc… Add components to a plugin Claude Code CLI · in the page plugins/components …on, authentication, and secrets-handling risks. ``` A [hook](/docs/en/hooks-guide.md) runs something automatically at a point in Claude Code's lifecycle, such as after every file edit: a shell comman… Create a Claude Code plugin Claude Code CLI · in the page plugins/create …own directory, called the plugin root, as `skills/`, `agents/`, `hooks/hooks.json`, and `.mcp.json`. * **How they're named**: plugin skills and agents get the plugin name as a prefix, such as `/my-plu… Plugin loading reference Claude Code CLI · in the page plugins/loading …em are left out. One plugin per name registers the hooks in its `hooks/hooks.json`, and one plugin per name loads a [hooks module](/docs/en/plugins/mods/overview.md). When your organization's managed… Plugin manifest reference Claude Code CLI · in the page plugins/manifest-reference …`.json` hook files or inline hook config. Loaded together with `hooks/hooks.json` | | [`mcpServers`](#mcpservers) | Path, object, or array of either | `.json` MCP config files, `.mcpb` or `.dxt` bund… Marketplace reference Claude Code CLI · in the page plugins/marketplace-reference …error for the plugin. Put file-based hooks in the plugin's own [`hooks/hooks.json`](/docs/en/plugins/components) or `plugin.json`. #### Display fields Both the entry and the plugin's own `plugin.jso… Manage mods for your organization Claude Code CLI · in the page plugins/mods/admin …ustomizations keep working**: their [hooks in settings files](/docs/en/hooks.md) and in plugins' `hooks/hooks.json`, status lines, and `/goal` aren't affected * **Built-in mods keep running**: mods bu… Use the mods API Claude Code CLI · in the page plugins/mods/api …reaches a running session, the user's [`Notification` hooks](/docs/en/hooks#notification) run with the type `plugin_notification`. They run even when the answer is `disabled`, and in a session with n… Create a mod Claude Code CLI · in the page plugins/mods/create …sh** ```bash theme={null} mkdir -p first-mod/.claude-plugin first-mod/hooks ``` **PowerShell** ```powershell theme={null} New-Item -ItemType Directory -Force first-mod\.claude-plugin, first-mod\hoo… React to events with a mod Claude Code CLI · in the page plugins/mods/events …* **When `tool.check` fires**: after the [`PreToolUse` hooks](/docs/en/hooks#pretooluse) run, and before the permission prompt, [auto mode](/docs/en/permission-modes.md#eliminate-prompts-with-auto-mod… Interface gallery for mods Claude Code CLI · in the page plugins/mods/gallery …hor": { "name": "Your Name" } } ``` Name your entry point in `gallery/hooks/hooks.json`: ```json gallery/hooks/hooks.json theme={null} { "modules": ["./register.js"] } ``` Save the code as `galle… Draw in the interface with a mod Claude Code CLI · in the page plugins/mods/interface …": { "name": "Your Name" } } ``` Name your entry point in `hello-tabs/hooks/hooks.json`: ```json hello-tabs/hooks/hooks.json theme={null} { "modules": ["./register.js"] } ``` **2. Write the code*… Mods overview Claude Code CLI · in the page plugins/mods/overview …w-a-mod-works). > [!NOTE] > > Claude Code's existing [hooks](/docs/en/hooks.md) also run on events, as a shell command, HTTP request, or prompt you configure in a settings file. A mod's handlers are… Mods reference Claude Code CLI · in the page plugins/mods/reference …lugins/manifest-reference.md). Mods add no required fields. | | `hooks/hooks.json` | Yes | `modules`: an array with one path, relative to this file, to the hooks module, as in `"modules": ["./register… Test a mod Claude Code CLI · in the page plugins/mods/test …nd](/docs/en/plugins/mods/api.md#add-a-command): ```javascript grader/hooks/register.js theme={null} export function register(on) { on('command.run', { command: 'grade' }, async ($, e) => { //… Troubleshoot a mod Claude Code CLI · in the page plugins/mods/troubleshoot …denied call | ### `validate` passes and lists no `hooks` line `hooks/hooks.json` has no `modules` key, or the key is misspelled. Add `"modules": ["./register.js"]`. ### `hooks module did not load`… Plugins overview Claude Code CLI · in the page plugins/overview …-plugin/plugin.json, skills/review/SKILL.md, agents/reviewer.md, hooks/hooks.json, .mcp.json, and other components. Right, what each file gives you in your session: the manifest sets the plugin name,… Plugin security and trust Claude Code CLI · in the page plugins/security …an installed plugin can do: * **Hooks**: a plugin's [hooks](/docs/en/hooks.md) run as shell commands at points in Claude Code's lifecycle, such as before or after a tool call. * **Monitors**: a plug… Troubleshoot plugins Claude Code CLI · in the page plugins/troubleshooting …messages: * **`Failed to load hooks from <path>: <reason>`**: `hooks/hooks.json` isn't valid JSON or fails the hooks schema. The reason names the parse or validation error. Fix the file. To catch a… How Claude Code uses prompt caching Claude Code CLI · in the page prompt-caching …ire this confirmation or skip it with a [PreModelSwitch hook](/docs/en/hooks.md#premodelswitch-decision-control). The [`opusplan` model setting](/docs/en/model-config#opusplan-model-setting) resolves… Prompt library Claude Code CLI · in the page prompt-library …Describe the trigger and action and Claude writes the [hook](/docs/en/hooks) configuration.", prompt: "write a hook that {action} after every {event}", slots: { action: "runs prettier",… Continue local sessions from any device with Remote Control Claude Code CLI · in the page remote-control …s.md). Requires a git repository or a [`WorktreeCreate` hook](/docs/en/hooks#worktreecreate). • `session`: single-session mode. Serves exactly one session and rejects additional connections. Set at st… Choose a sandbox environment Claude Code CLI · in the page sandbox-environments …em instead. * [MCP](/docs/en/mcp.md) servers, [command hooks](/docs/en/hooks.md#command-hook-fields), and [plugin monitors](/docs/en/plugins/components.md#monitors) are separate processes that run unc… Configure the sandboxed Bash tool Claude Code CLI · in the page sandboxing …tch * **Other processes Claude Code starts**: command [hooks](/docs/en/hooks.md), local [MCP servers](/docs/en/mcp.md), [plugin monitors](/docs/en/plugins/components.md#monitors), [LSP servers](/docs/… Security Claude Code CLI · in the page security …settings changes during sessions with [`ConfigChange` hooks](/docs/en/hooks#configchange) ### Reporting security issues If you discover a security vulnerability in Claude Code: 1. Do not disclose… Catch security issues as Claude writes code Claude Code CLI · in the page security-guidance …forcement, pair the plugin with a [hook that blocks the edit](/docs/en/hooks-guide.md#block-edits-to-protected-files) or a CI check. ### Add custom per-edit patterns Create `.claude/security-pattern… Customize sessions in self-hosted environments Claude Code CLI · in the page self-hosted-environments-configuration …ployment). These hooks are distinct from [Claude Code hooks](/docs/en/hooks.md), which run inside the session; lifecycle hooks run on the runner, around the session. ### checkout Runs once per repo… Test self-hosted environments end to end Claude Code CLI · in the page self-hosted-environments-testing …runner The read-back works through a Claude Code [Stop hook](/docs/en/hooks.md#stop): when Claude finishes a turn, the hook receives the final assistant message as `last_assistant_message` in its std… Configure server-managed settings Claude Code CLI · in the page server-managed-settings …rrent-limitations) for that short list. This includes [hooks](/docs/en/hooks.md), [environment variables](/docs/en/env-vars.md), and [managed-only settings](/docs/en/managed-settings.md#managed-only-s… Manage sessions Claude Code CLI · in the page sessions …ssion events**: read the `transcript_path` field that [hooks](/docs/en/hooks.md#common-input-fields) and [status line commands](/docs/en/statusline.md#available-data) receive as input. A `SessionEnd`… Claude Code settings Claude Code CLI · in the page settings …t, local, and managed settings, and the [`ConfigChange` hook](/docs/en/hooks#configchange) fires for each detected change. A few keys are read once at session start and apply on the next restart inst… Example settings files Claude Code CLI · in the page settings-example …* **The hook is a script in the repo.** This file's hook runs `.claude/hooks/block-rm.sh`; [How a hook resolves](/docs/en/hooks.md#how-a-hook-resolves) walks through writing it. * **Rules match the co… All settings Claude Code CLI · in the page settings-reference …kUrls`](#allowedhttphookurls) | Limit which URLs [HTTP hooks](/docs/en/hooks.md) can target | Hooks and automation | Any file | | [`allowedMcpServers`](#allowedmcpservers) | Allowlist which [MCP serve… Extend Claude with skills Claude Code CLI · in the page skills …nd plugins compared with their context cost, and slow [hooks](/docs/en/hooks.md) * **`CLAUDE.md` files**: local `CLAUDE.md` files that duplicate checked-in ones, checked-in [`CLAUDE.md` content Claude… Customize your status line Claude Code CLI · in the page statusline …ON object on stdin. The input includes the [base hook fields](/docs/en/hooks.md#common-input-fields), a `columns` field with the usable row width, and a `tasks` array with one entry per row, described… Create custom subagents Claude Code CLI · in the page sub-agents …If you're the plugin's author, ship the hooks in the plugin's [`hooks/hooks.json`](/docs/en/plugins/components#hooks) and the MCP servers in its [`.mcp.json`](/docs/en/plugins/components#mcp-servers)… Configure your terminal for Claude Code Claude Code CLI · in the page terminal-config …a notification event. See [when each notification type fires](/docs/en/hooks.md#notification) for the exact timing. Surfacing this as a terminal bell or desktop notification lets you switch to other w… Tools reference Claude Code CLI · in the page tools-reference …gent tool lists](/docs/en/sub-agents.md), and [hook matchers](/docs/en/hooks.md). To control which tools Claude can use and when it asks first, configure [permission rules](/docs/en/permissions.md#to… Use Claude Code in VS Code Claude Code CLI · in the page vs-code …Select **Hooks** in the Customize section to view the [hooks](/docs/en/hooks.md) loaded in the session, grouped by event. You can add, edit, or remove hooks saved in your user, project, and local sett… Week 13 · March 23–27, 2026 Claude Code CLI · in the page whats-new/2026-w13 …git commit *)", "type": "command", "command": ".claude/hooks/lint-staged.sh" }] }] } } ``` [Hooks reference](/docs/en/hooks.md) Other wins Plugin `userConfig` now public… Week 17 · April 20–24, 2026 Claude Code CLI · in the page whats-new/2026-w17 …ooks can now call MCP tools directly via [`type: "mcp_tool"`](/docs/en/hooks#mcp-tool-hook-fields), so a hook can hit an already-connected server without spawning a process`/cost` and `/stats` are mer… Week 23 · June 1–5, 2026 Claude Code CLI · in the page whats-new/2026-w23 …hlighted in violet in the prompt[Stop and SubagentStop hooks](/docs/en/hooks.md) can return `hookSpecificOutput.additionalContext` to give Claude feedback and keep the turn going instead of being trea… Week 36 · August 31 – September 4, 2026 Claude Code CLI · in the page whats-new/2026-w36 …ills.md#find-unused-skills) Other wins A [`PreModelSwitch`](/docs/en/hooks#premodelswitch) hook can block a model switch you request, and a [`PostModelSwitch`](/docs/en/hooks#postmodelswitch) hook c… Orchestrate subagents at scale with dynamic workflows Claude Code CLI · in the page workflows …A hook**: return `"allow"` for the call from a [`PreToolUse`](/docs/en/hooks#pretooluse) hook. In [plan mode](/docs/en/permission-modes.md#analyze-before-you-edit-with-plan-mode), the workflow doesn't… Run parallel sessions with worktrees Claude Code CLI · in the page worktrees …ee, Claude Code keeps `${CLAUDE_PROJECT_DIR}` in your [hooks](/docs/en/hooks.md#reference-scripts-by-path) where it was and passes the worktree path to them a different way: > > * **`${CLAUDE_PROJECT_… Configure GitHub access Claude Documentation · in the page claude-tag/admins/configure-github …e can use them in the session [Hooks](https://code.claude.com/docs/en/hooks) in a repository's `.claude/settings.json` don't run in the session. A repository's `.mcp.json` is never loaded. Repositor…
Feedback