{"meta":{"title":"GitHub Copilot hooks reference","intro":"Find hook events, configuration formats, and input payloads for hooks in Второй пилот CLI and Copilot облачный агент.","product":"GitHub Copilot","breadcrumbs":[{"href":"/ru/copilot","title":"GitHub Copilot"},{"href":"/ru/copilot/reference","title":"Справочные материалы"},{"href":"/ru/copilot/reference/hooks-reference","title":"Hooks reference"}],"documentType":"article"},"body":"# GitHub Copilot hooks reference\n\nFind hook events, configuration formats, and input payloads for hooks in Второй пилот CLI and Copilot облачный агент.\n\n## Introduction\n\nHooks are external commands that execute at specific lifecycle points during a session, enabling custom automation, security controls, and integrations.\n\nHooks are supported in two Copilot surfaces: Второй пилот CLI and Copilot облачный агент. Most of the configuration format and event payloads are identical, but the execution environment and the set of events that can fire differ.\n\nThroughout this article, behavior that differs between the two surfaces is called out in \"CLI only\" and \"Cloud agent only\" notes. Anything not marked applies to both.\n\n## Hooks locations\n\nThe locations where hooks run, and where you can store hook configuration files, depend on the surface:\n\n* **Второй пилот CLI** — hooks run on the developer's local machine in the same shell as the CLI. All hook events described in this article are supported by the CLI.\n\n  Hooks are loaded from the following sources in order (user, then project, then plugins) and combined. When the same event appears in multiple sources, all hook entries from all sources are run.\n\n  * **Repository-level hook files** — `.github/hooks/*.json` in the repository root.\n  * **User-level hook files** — `*.json` files in the user-level hooks directory. By default this is `~/.copilot/hooks/` on macOS and Linux, or `%USERPROFILE%\\.copilot\\hooks\\` on Windows. If `COPILOT_HOME` is set, it is `$COPILOT_HOME/hooks/`.\n  * **Inline `hooks` block in repository settings** — the `hooks` field at the top level of `.github/copilot/settings.json` (Git committed) or `.github/copilot/settings.local.json` (typically gitignored and user specific) in the repository. Cross-tool `.claude/settings.json` and `.claude/settings.local.json` files in the repository are also read.\n  * **Inline `hooks` block in user-level config** — the `hooks` field at the top level of `~/.copilot/settings.json`.\n  * **Hooks contributed by installed plugins** — declared by each plugin in its own `hooks.json` (or under `hooks/hooks.json`) inside the plugin's installation directory.\n\n* **Copilot облачный агент** — hooks run inside the ephemeral Linux sandbox that cloud agent provisions for each job. The sandbox is non-interactive, has a constrained network, and is destroyed when the job ends. A subset of events fires, and only `bash` (or `command`) entries are honored.\n\n  Hook configuration is loaded from `.github/hooks/*.json` files in the cloned repository.\n\n## Cloud agent execution environment\n\nThis section applies to **Copilot облачный агент only**. It describes constraints that affect how you write hook scripts and configure hook entries for cloud agent jobs.\n\n| Property                        | Value                                                                                                                                                                                                                                                                                      |\n| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| Operating system                | Linux. Only the `bash` field on command hooks is honored; `powershell` entries are ignored. The cross-platform `command` field is honored as a fallback.                                                                                                                                   |\n| Working directory               | `/workspace` when a repository is cloned, otherwise `/root`. Use this path when setting `cwd` on a hook entry or when referencing files from a script.                                                                                                                                     |\n| Filesystem                      | Ephemeral. Files written by hooks (logs, CSVs, transcripts) are discarded when the job ends. To retain hook output, send it via an `http` hook entry.                                                                                                                                      |\n| Outbound network                | Restricted by the cloud agent firewall. By default only GitHub and Copilot hostnames are reachable; reaching any other host (for example `https://hooks.example.com`) requires an admin-configured firewall allow rule.                                                                    |\n| Available environment variables | `GITHUB_COPILOT_API_TOKEN` and `GITHUB_COPILOT_GIT_TOKEN` are set in the sandbox. `COPILOT_AGENT_PROMPT` holds the prompt the job was invoked with. `HOME` is set to `/root`, so any hook script that resolves `~/...` paths writes into the ephemeral sandbox. `GITHUB_TOKEN` is not set. |\n| Interactivity                   | Fully non-interactive. The agent runs with all tool permissions pre-granted, so no permission dialogs are shown and no notifications are surfaced to a user.                                                                                                                               |\n| Configuration discovery         | In a cloud agent job, the only hook configuration that exists by default is `.github/hooks/*.json` inside the cloned repository. The sandbox does not ship with user-level hook files, `settings.json`, `config.json`, or installed plugins.                                               |\n\n## Hook configuration format\n\nHook configuration files use JSON format with version `1`.\n\n### Command hooks\n\nCommand hooks run shell scripts and are supported on all hook types.\n\n> \\[!NOTE]\n> **Cloud agent only.** Cloud agent runs hooks in a Linux sandbox. Only the `bash` field is honored; `powershell` entries are ignored. The cross-platform `command` field is honored as a fallback.\n\n```json\n{\n  \"version\": 1,\n  \"hooks\": {\n    \"preToolUse\": [\n      {\n        \"type\": \"command\",\n        \"bash\": \"your-bash-command\",\n        \"powershell\": \"your-powershell-command\",\n        \"cwd\": \"optional/working/directory\",\n        \"env\": { \"VAR\": \"value\" },\n        \"timeoutSec\": 30\n      }\n    ]\n  }\n}\n```\n\n| Field        | Type        | Required                                  | Description                                                                                        |\n| ------------ | ----------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------- |\n| `bash`       | string      | One of `bash`, `powershell`, or `command` | Shell command for Unix.                                                                            |\n| `command`    | string      | One of `bash`, `powershell`, or `command` | Cross-platform fallback used when neither `bash` nor `powershell` is set for the current platform. |\n| `cwd`        | string      | No                                        | Working directory for the command (relative to repository root or absolute).                       |\n| `env`        | object      | No                                        | Environment variables to set (supports variable expansion).                                        |\n| `powershell` | string      | One of `bash`, `powershell`, or `command` | Shell command for Windows.                                                                         |\n| `timeoutSec` | number      | No                                        | Timeout in seconds. Default: `30`.                                                                 |\n| `type`       | `\"command\"` | Yes                                       | Must be `\"command\"`.                                                                               |\n\n### HTTP hooks\n\nHTTP hooks send the input payload as a JSON `POST` to a URL.\n\n> \\[!NOTE]\n> **Cloud agent only.** Outbound network from the sandbox is restricted by the cloud agent firewall, so `url` must target an allow-listed host.\n\n```json\n{\n  \"version\": 1,\n  \"hooks\": {\n    \"postToolUse\": [\n      {\n        \"type\": \"http\",\n        \"url\": \"https://hooks.example.com/copilot\",\n        \"headers\": { \"X-Source\": \"copilot-cli\" },\n        \"allowedEnvVars\": [\"GITHUB_TOKEN\"],\n        \"timeoutSec\": 30\n      }\n    ]\n  }\n}\n```\n\n| Field            | Type      | Required | Description                                                                                                                                              |\n| ---------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `allowedEnvVars` | string\\[] | No       | Environment variable names that may be expanded inside `headers` values. When set, `url` must use `https://`.                                            |\n| `headers`        | object    | No       | Request headers to include.                                                                                                                              |\n| `timeoutSec`     | number    | No       | Timeout in seconds. Default: `30`.                                                                                                                       |\n| `type`           | `\"http\"`  | Yes      | Must be `\"http\"`.                                                                                                                                        |\n| `url`            | string    | Yes      | Target URL. Must use `http:` or `https:`. For `preToolUse` and `permissionRequest`, must use `https://` because the response can grant tool permissions. |\n\n### Prompt hooks\n\nPrompt hooks auto-submit text as if the user typed it. They are only supported on `sessionStart`. The text can be a natural language prompt or a slash command.\n\n> \\[!NOTE]\n> **Второй пилот CLI only.** Prompt hooks fire only for **new interactive sessions**. They do not fire on resume, and they do not fire in non-interactive prompt mode (`-p`).\n\n> \\[!NOTE]\n> **Cloud agent.** Cloud agent jobs run non-interactively (similar to `-p`), so `prompt` hook entries may not fire. Confirm the behavior in your environment before relying on them.\n\n```json\n{\n  \"version\": 1,\n  \"hooks\": {\n    \"sessionStart\": [\n      {\n        \"type\": \"prompt\",\n        \"prompt\": \"Your prompt text or /slash-command\"\n      }\n    ]\n  }\n}\n```\n\n| Field    | Type       | Required | Description                                                          |\n| -------- | ---------- | -------- | -------------------------------------------------------------------- |\n| `type`   | `\"prompt\"` | Yes      | Must be `\"prompt\"`.                                                  |\n| `prompt` | string     | Yes      | Text to submit—can be a natural language message or a slash command. |\n\n## Hook events\n\nThe table below lists every supported event. The **Cloud agent** column shows whether the event fires under cloud agent and notes any behavior differences.\n\n| Event                 | Fires when                                                                                                                                                                                                                                                                                | Output processed                                                                                 | Cloud agent                                                                                                                                                   |\n| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `agentStop`           | The main agent finishes a turn.                                                                                                                                                                                                                                                           | Yes — can block and force continuation.                                                          | Fires. `decision: \"block\"` forces another turn, which still counts against the job's timeout.                                                                 |\n| `errorOccurred`       | An error occurs during execution.                                                                                                                                                                                                                                                         | No                                                                                               | Fires.                                                                                                                                                        |\n| `notification`        | Fires asynchronously when the CLI emits a system notification (shell completion, agent completion or idle, permission prompts, elicitation dialogs). Fire-and-forget: never blocks the session. Supports `matcher` regex on `notification_type`.                                          | Optional — can inject `additionalContext` into the session.                                      | **Does not fire.** Cloud agent does not surface notifications to a user (see the **Interactivity** row in the Cloud agent execution environment table above). |\n| `permissionRequest`   | Fires before the permission service runs (rules engine, session approvals, auto-allow/auto-deny, and user prompting). If the merged hook output returns `behavior: \"allow\"` or `\"deny\"`, that decision short-circuits the normal permission flow. Supports `matcher` regex on `toolName`. | Yes — can allow or deny programmatically.                                                        | Tool calls are pre-approved, so this hook either does not fire or has no effect. Use `preToolUse` to make permission decisions instead.                       |\n| `postToolUse`         | After each tool completes successfully.                                                                                                                                                                                                                                                   | No                                                                                               | Fires.                                                                                                                                                        |\n| `postToolUseFailure`  | After a tool completes with a failure.                                                                                                                                                                                                                                                    | Yes — can provide recovery guidance via `additionalContext` (exit code `2` for command hooks).   | Fires.                                                                                                                                                        |\n| `preCompact`          | Context compaction is about to begin (manual or automatic). Supports `matcher` to filter by trigger (`\"manual\"` or `\"auto\"`).                                                                                                                                                             | No — notification only.                                                                          | Fires only with `trigger: \"auto\"`. There is no user to request manual compaction.                                                                             |\n| `preToolUse`          | Before each tool executes.                                                                                                                                                                                                                                                                | Yes — can allow, deny, or modify.                                                                | Fires. A decision of `\"ask\"` is treated as `\"deny\"` because no user is available to answer.                                                                   |\n| `sessionEnd`          | The session terminates.                                                                                                                                                                                                                                                                   | No                                                                                               | Fires once per job. `reason` is typically `\"complete\"`, `\"error\"`, or `\"timeout\"`; `\"abort\"` and `\"user_exit\"` are not expected because there is no user.     |\n| `sessionStart`        | A new or resumed session begins.                                                                                                                                                                                                                                                          | Optional — can inject `additionalContext` into the session.                                      | Fires once per job, as a new session (not a resume). See the Prompt hooks note above for the behavior of `prompt` entries under cloud agent.                  |\n| `subagentStart`       | A subagent is spawned (before it runs). Supports `matcher` to filter by agent name.                                                                                                                                                                                                       | Optional — cannot block creation, but `additionalContext` is prepended to the subagent's prompt. | Fires.                                                                                                                                                        |\n| `subagentStop`        | A subagent completes.                                                                                                                                                                                                                                                                     | Yes — can block and force continuation.                                                          | Fires.                                                                                                                                                        |\n| `userPromptSubmitted` | The user submits a prompt.                                                                                                                                                                                                                                                                | No                                                                                               | Fires at most once, for the prompt supplied to the job. There is no follow-up user input.                                                                     |\n\n## Hook event input payloads\n\nEach hook event delivers a JSON payload to the hook handler. Two payload formats are supported, selected by the event name used in the hook configuration:\n\n* **camelCase format** — Configure the event name in camelCase (for example, `sessionStart`). Fields use camelCase.\n* **VS Code compatible format** — Configure the event name in PascalCase (for example, `SessionStart`). Fields use snake\\_case to match the VS Code Copilot extension format.\n\n### `sessionStart` / `SessionStart`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;      // Unix timestamp in milliseconds\n    cwd: string;\n    source: \"startup\" | \"resume\" | \"new\";\n    initialPrompt?: string;\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"SessionStart\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    source: \"startup\" | \"resume\" | \"new\";\n    initial_prompt?: string;\n}\n```\n\n### `sessionEnd` / `SessionEnd`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    reason: \"complete\" | \"error\" | \"abort\" | \"timeout\" | \"user_exit\";\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"SessionEnd\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    reason: \"complete\" | \"error\" | \"abort\" | \"timeout\" | \"user_exit\";\n}\n```\n\n### `userPromptSubmitted` / `UserPromptSubmit`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    prompt: string;\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"UserPromptSubmit\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    prompt: string;\n}\n```\n\n### `preToolUse` / `PreToolUse`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    toolName: string;\n    toolArgs: unknown;\n}\n```\n\n**VS Code compatible input:**\n\nWhen configured with the PascalCase event name `PreToolUse`, the payload uses snake\\_case field names to match the VS Code Copilot extension format:\n\n```typescript\n{\n    hook_event_name: \"PreToolUse\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    tool_name: string;\n    tool_input: unknown;    // Tool arguments (parsed from JSON string when possible)\n}\n```\n\n### `postToolUse` / `PostToolUse`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    toolName: string;\n    toolArgs: unknown;\n    toolResult: {\n        resultType: \"success\";\n        textResultForLlm: string;\n    }\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"PostToolUse\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    tool_name: string;\n    tool_input: unknown;\n    tool_result: {\n        result_type: \"success\";\n        text_result_for_llm: string;\n    }\n}\n```\n\n### `postToolUseFailure` / `PostToolUseFailure`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    toolName: string;\n    toolArgs: unknown;\n    error: string;\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"PostToolUseFailure\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    tool_name: string;\n    tool_input: unknown;\n    error: string;\n}\n```\n\n### `agentStop` / `Stop`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    transcriptPath: string;\n    stopReason: \"end_turn\";\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"Stop\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    transcript_path: string;\n    stop_reason: \"end_turn\";\n}\n```\n\n### `subagentStart`\n\n**Input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    transcriptPath: string;\n    agentName: string;\n    agentDisplayName?: string;\n    agentDescription?: string;\n}\n```\n\n### `subagentStop` / `SubagentStop`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    transcriptPath: string;\n    agentName: string;\n    agentDisplayName?: string;\n    stopReason: \"end_turn\";\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"SubagentStop\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    transcript_path: string;\n    agent_name: string;\n    agent_display_name?: string;\n    stop_reason: \"end_turn\";\n}\n```\n\n### `errorOccurred` / `ErrorOccurred`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    error: {\n        message: string;\n        name: string;\n        stack?: string;\n    };\n    errorContext: \"model_call\" | \"tool_execution\" | \"system\" | \"user_input\";\n    recoverable: boolean;\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"ErrorOccurred\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    error: {\n        message: string;\n        name: string;\n        stack?: string;\n    };\n    error_context: \"model_call\" | \"tool_execution\" | \"system\" | \"user_input\";\n    recoverable: boolean;\n}\n```\n\n### `preCompact` / `PreCompact`\n\n**camelCase input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    transcriptPath: string;\n    trigger: \"manual\" | \"auto\";\n    customInstructions: string;\n}\n```\n\n**VS Code compatible input:**\n\n```typescript\n{\n    hook_event_name: \"PreCompact\";\n    session_id: string;\n    timestamp: string;      // ISO 8601 timestamp\n    cwd: string;\n    transcript_path: string;\n    trigger: \"manual\" | \"auto\";\n    custom_instructions: string;\n}\n```\n\n## `preToolUse` decision control\n\nThe `preToolUse` hook can control tool execution by writing a JSON object to stdout.\n\n| Field                      | Values                       | Description                                                                                                                                              |\n| -------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `permissionDecision`       | `\"allow\"`, `\"deny\"`, `\"ask\"` | Whether the tool executes. Empty output uses default behavior. Under cloud agent, `\"ask\"` is treated as `\"deny\"` because no user is available to answer. |\n| `permissionDecisionReason` | string                       | Reason shown to the agent. Required when decision is `\"deny\"`.                                                                                           |\n| `modifiedArgs`             | object                       | Substitute tool arguments to use instead of the originals.                                                                                               |\n\n## `agentStop` / `subagentStop` decision control\n\n| Field      | Values               | Description                                                       |\n| ---------- | -------------------- | ----------------------------------------------------------------- |\n| `decision` | `\"block\"`, `\"allow\"` | `\"block\"` forces another agent turn using `reason` as the prompt. |\n| `reason`   | string               | Prompt for the next turn when `decision` is `\"block\"`.            |\n\n## `permissionRequest` decision control\n\n> \\[!NOTE]\n> **Второй пилот CLI only.** The `permissionRequest` hook does not apply under Copilot облачный агент—tool calls there are pre-approved (see the **Interactivity** row in the Cloud agent execution environment table). Use `preToolUse` to make permission decisions in cloud agent.\n\nThe `permissionRequest` hook fires before the permission service runs—before rule checks, session approvals, auto-allow/auto-deny, and user prompting. If hooks return `behavior: \"allow\"` or `\"deny\"`, that decision short-circuits the normal permission flow. Returning nothing falls through to normal permission handling. Use it to approve or deny tool calls programmatically—especially useful in CLI pipe mode (`-p`) and other CLI CI usages where no interactive prompt is available. It does not apply to cloud agent.\n\nAll configured `permissionRequest` hooks run for each request (except `read` and `hook` permission kinds, which short-circuit before hooks). Hook outputs are merged with later hook outputs overriding earlier ones.\n\n**Matcher:** Optional regex tested against `toolName`. Anchored as `^(?:pattern)$`; must match the full tool name. When set, the hook fires only for matching tool names.\n\nOutput JSON to stdout to control the permission decision:\n\n| Field       | Values              | Description                                                   |\n| ----------- | ------------------- | ------------------------------------------------------------- |\n| `behavior`  | `\"allow\"`, `\"deny\"` | Whether to approve or deny the tool call.                     |\n| `message`   | string              | Reason fed back to the LLM when denying.                      |\n| `interrupt` | boolean             | When `true` combined with `\"deny\"`, stops the agent entirely. |\n\nReturn empty output or `{}` to fall through to the normal permission flow. For command hooks, exit code `2` is treated as a deny; stdout JSON (if any) is merged with `{\"behavior\":\"deny\"}`, and stderr is ignored.\n\n## `notification` hook\n\n> \\[!NOTE]\n> **Второй пилот CLI only.** The `notification` hook does not fire under Copilot облачный агент.\n\nThe `notification` hook fires asynchronously when the CLI emits a system notification. These hooks are fire-and-forget: they never block the session, and any errors are logged and skipped.\n\n**Input:**\n\n```typescript\n{\n    sessionId: string;\n    timestamp: number;\n    cwd: string;\n    hook_event_name: \"Notification\";\n    message: string;           // Human-readable notification text\n    title?: string;            // Short title (e.g., \"Permission needed\", \"Shell completed\")\n    notification_type: string; // One of the types listed below\n}\n```\n\n**Notification types:**\n\n| Type                       | When it fires                                                                        |\n| -------------------------- | ------------------------------------------------------------------------------------ |\n| `shell_completed`          | A background (async) shell command finishes                                          |\n| `shell_detached_completed` | A detached shell session completes                                                   |\n| `agent_completed`          | A background subagent finishes (completed or failed)                                 |\n| `agent_idle`               | A background agent finishes a turn and enters idle state (waiting for `write_agent`) |\n| `permission_prompt`        | The agent requests permission to execute a tool                                      |\n| `elicitation_dialog`       | The agent requests additional information from the user                              |\n\n**Output:**\n\n```typescript\n{\n    additionalContext?: string; // Injected into the session as a user message\n}\n```\n\nIf `additionalContext` is returned, the text is injected into the session as a prepended user message. This can trigger further agent processing if the session is idle. Return `{}` or empty output to take no action.\n\n**Matcher:** Optional regex on `notification_type`. The pattern is anchored as `^(?:pattern)$`. Omit `matcher` to receive all notification types.\n\n## Matcher filtering\n\nSeveral events accept an optional `matcher` regex on each hook entry that filters which invocations the hook fires for. The pattern is anchored as `^(?:matcher)$` and must match the full value. Invalid regexes cause the hook entry to be skipped.\n\n| Event               | `matcher` is matched against       |\n| ------------------- | ---------------------------------- |\n| `notification`      | `notification_type`                |\n| `permissionRequest` | `toolName`                         |\n| `preCompact`        | `trigger` (`\"manual\"` or `\"auto\"`) |\n| `preToolUse`        | `toolName`                         |\n| `subagentStart`     | `agentName`                        |\n\n## Tool names for hook matching\n\n| Tool name    | Description                                                                                                             |\n| ------------ | ----------------------------------------------------------------------------------------------------------------------- |\n| `ask_user`   | Ask the user a clarifying question. Under cloud agent there is no user, so `ask_user` does not produce a useful result. |\n| `bash`       | Execute shell commands (Unix).                                                                                          |\n| `create`     | Create new files.                                                                                                       |\n| `edit`       | Modify file contents.                                                                                                   |\n| `glob`       | Find files by pattern.                                                                                                  |\n| `grep`       | Search file contents.                                                                                                   |\n| `powershell` | Execute shell commands (Windows). Does not appear under cloud agent (Linux sandbox).                                    |\n| `task`       | Run subagent tasks.                                                                                                     |\n| `view`       | Read file contents.                                                                                                     |\n| `web_fetch`  | Fetch web pages.                                                                                                        |\n\nIf multiple hooks of the same type are configured, they execute in order. For `preToolUse`, if any hook returns `\"deny\"`, the tool is blocked. Hook failures (non-zero exit codes other than `2`, or timeouts) are logged and skipped—they never block agent execution.\n\n## Exit codes for command hooks\n\n| Exit code      | Meaning                                                                                                                                                                                                                                                                                                                             |\n| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `0`            | Success. `stdout` is parsed as the hook output JSON if present.                                                                                                                                                                                                                                                                     |\n| `2`            | Treated as a warning by default. `stderr` is surfaced to the user but the run continues. For `permissionRequest`, exit `2` is treated as `{\"behavior\":\"deny\"}` and any `stdout` JSON is merged in. For `postToolUseFailure`, exit `2` is treated as `additionalContext` and `stdout` is appended to the failure shown to the agent. |\n| Other non-zero | Logged as a hook failure. The run continues (fail-open).                                                                                                                                                                                                                                                                            |\n\n## Disable all hooks\n\nUse `disableAllHooks` when you want to keep your hook configuration on disk but stop it from running—for example:\n\n* Debugging an issue and you want to confirm a hook is the cause without deleting your config.\n* Pausing automation during a sensitive task (a code review, a release branch, working with secrets) without losing the setup. (**Второй пилот CLI only.**)\n* Shipping a hooks file in source control that contributors can opt out of locally by setting the option in their repository `settings.json`. (**Второй пилот CLI only.**)\n* Temporarily silencing slow or noisy hooks during an interactive session. (**Второй пилот CLI only.**)\n\nSet `disableAllHooks` to `true` at the top level to skip every hook in the file without deleting it.\n\n```json\n{\n  \"version\": 1,\n  \"disableAllHooks\": false,\n  \"hooks\": {\n    \"preToolUse\": [ /* hook entries */ ]\n  }\n}\n```\n\nBehavior depends on where you set the flag:\n\n* **Inside a single `.github/hooks/*.json` file** — only the hooks declared in that file are skipped. Honored by both Второй пилот CLI and Copilot облачный агент.\n* **At the top level of repository `settings.json`** — **Второй пилот CLI only.** Every hook from every source (repository files, user files, plugins, and inline hook blocks) is skipped for sessions in that repository. Cloud agent does not load `settings.json`.\n\n## Further reading\n\n* [Использование крючков с GitHub Copilot CLI](/ru/copilot/how-tos/copilot-cli/use-hooks)\n* [GitHub Copilot hooks reference](/ru/copilot/reference/hooks-configuration)\n* [Справочник команды GitHub Copilot CLI](/ru/copilot/reference/copilot-cli-reference/cli-command-reference)\n* [Концепции облачного агента GitHub Copilot](/ru/copilot/concepts/agents/cloud-agent)"}