The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Claude Code hooks run configured handlers at specific lifecycle events; OpenTelemetry exports monitoring data to systems your organization configures. They solve different problems. “Progressive disclosure” is a useful way to understand them: start with the lifecycle, then narrow when a handler runs and what it does, and finally decide whether to export telemetry. It is an editorial framing, not a named Claude Code feature.
What are Claude Code hooks?
A hook is a configured handler that runs when a particular event occurs in a Claude Code session. Anthropic describes hooks as “user-defined shell commands, HTTP endpoints, MCP tool calls, LLM prompts, or subagents that execute automatically at specific points in Claude Code’s lifecycle.” The supported handler types depend on the event. See the Claude Code hooks reference for the current event-specific details.
Think of a hook configuration as three separate choices:
- Event: the lifecycle moment that can trigger the hook.
- Matcher: a filter that narrows which events or tools activate a handler.
- Handler: the command, endpoint, MCP tool, prompt, or agent that runs, where that type is supported.
Claude Code supplies JSON context to the handler. Command handlers receive it on standard input; HTTP handlers receive it in the request body. Payloads, match fields, and available decisions vary by event, so do not assume every hook receives the same fields or can control the same behavior.
#1 Best Overall
Which Claude Code hook events are available?
The events cover more than tool execution. This grouping is a way to find the relevant point in the lifecycle; it is not an official product taxonomy.
| Lifecycle area | Events | Typical question |
|---|---|---|
| Session boundaries and setup | Setup, SessionStart, SessionEnd |
Should something run as a session is prepared, starts, or ends? |
| Prompt and response flow | UserPromptSubmit, UserPromptExpansion, MessageDisplay, Stop, StopFailure |
Should a handler react to submitted or expanded prompts, displayed messages, or a stopping outcome? |
| Tool and permission flow | PreToolUse, PermissionRequest, PermissionDenied, PostToolUse, PostToolUseFailure, PostToolBatch |
Should it run before a tool, around a permission decision, after a tool result, or after a batch? |
| Agents and tasks | SubagentStart, SubagentStop, TaskCreated, TaskCompleted, TeammateIdle |
Should it react to an agent or task lifecycle change? |
| Workspace and configuration | InstructionsLoaded, ConfigChange, CwdChanged, DirectoryAdded, FileChanged, WorktreeCreate, WorktreeRemove |
Should it respond to loaded instructions or a workspace/configuration change? |
| Context and model changes | PreCompact, PostCompact, PreModelSwitch, PostModelSwitch |
Should it run around context compaction or a model switch? |
| MCP input | Elicitation, ElicitationResult |
Should it handle an MCP elicitation or its result? |
| Notifications | Notification |
Should it react to a notification? |
For an implementation, check the event reference for the exact firing condition, input schema, matcher field, supported handler types, and decision controls for the event you choose.
Rank #2
How do I run a hook only before a particular tool?
- Choose the pre-execution event. Use
PreToolUsewhen the handler needs to run before a tool executes.PostToolUseis for after a successful tool use, not a substitute for a pre-execution check. - Add a matcher for the tool. For example, a
PreToolUsematcher can target Bash rather than every tool. - Narrow the match further if needed. A Bash matcher can be paired with a more specific Bash command condition so a guard script runs only for relevant commands.
- Choose the handler and its effect. A handler can observe or provide context, or return an event-supported decision. In the documented destructive-command example, the handler returns a structured deny decision. A successful exit with no output leaves the normal permission flow in place; silence does not itself approve the tool action.
- Verify the event’s schema and decision rules. Check the current hooks reference rather than assuming the same return behavior applies to other events.
The reference describes the configuration pattern but event-specific syntax and fields should be taken from its current examples. Avoid copying a matcher or decision payload from a different event without checking that event’s documented schema.
Where should hook configuration live?
Choose a location based on who should receive the hook and who controls it. Claude Code also supports hooks in plugins, skills, and subagent frontmatter for those contexts.
Rank #3
| Configuration location | Scope | Sharing or governance |
|---|---|---|
| User settings | Across that user’s projects | Personal user-level configuration |
| Project settings | The project | Can be committed and shared with the project |
| Local project settings | The project on that local setup | Not shared with the project |
| Managed settings | Organization-controlled | Administrator-managed configuration |
| Plugin, skill, or subagent frontmatter | The corresponding plugin, skill, or subagent context | Defined in that context |
For the settings-file behavior and precedence, see Claude Code settings. Configuration availability can differ between local sessions and cloud or self-hosted contexts, so verify the context in which the hook will run rather than assuming a local setup carries over.
What telemetry does Claude Code send?
“Telemetry” can mean separate data flows. A hook is an automation mechanism; it is not the same thing as Anthropic’s operational telemetry or organization-configured OpenTelemetry export.
Rank #4
| Mechanism | Purpose and data | Control or destination |
|---|---|---|
| Hooks | Run a configured handler at a lifecycle event; the event supplies context to that handler. | Configured in the applicable hook location; not a general monitoring export. |
| Anthropic operational telemetry | Usage metrics and error reports. The data-usage documentation says metrics exclude code, prompts, and file paths; error reports have separate documented contents and redaction behavior. | Separate data-usage controls; behavior depends on provider and account conditions. |
| OpenTelemetry export | Organization-managed monitoring: metrics as time-series data, events through the logs/events protocol, and optional traces. | Configured exporters and, where applicable, an OTLP endpoint; organizations can set managed configuration. |
| Feedback submissions | Feedback-related commands can send conversation history, including code, depending on the user’s selection and configuration. | A distinct user-feedback path, not the same as operational metrics. |
Do not infer one universal default across all Claude Code users. Provider, subscription, version, and applicable organization agreements can affect data-use behavior. Consult the current data usage documentation for the applicable controls and provider-specific details.
How do I monitor Claude Code usage with OpenTelemetry?
OpenTelemetry is the documented route for organization-managed monitoring. Configure the signals and destination your team intends to use, then validate the export in the receiving collector or backend. The current monitoring guide lists the environment variables and exporter options.
Best Value
- Decide which signals you need. Metrics, events/logs, and traces are distinct; traces are optional. Select only the signals relevant to your monitoring and data-handling requirements.
- Set the telemetry enablement and exporter configuration. The documented configuration includes
CLAUDE_CODE_ENABLE_TELEMETRY, exporter selection, and an OTLP endpoint where applicable. Use the monitoring guide for the current variable values, protocol requirements, and endpoint details. - Use managed settings when the organization must control configuration. Administrator-managed settings provide an organization-level path for these values rather than relying only on each user’s shell environment.
- Check where the configuration is read. Repository-level
.claude/settings.jsonand.claude/settings.local.jsonare ignored for OpenTelemetry exporter variables. Do not depend on those files to configure an exporter. - Account for subprocess boundaries. Claude Code does not pass
OTEL_*variables into spawned subprocesses such as hooks and MCP servers. Configure those processes separately if they need their own telemetry settings. - Confirm data arrives at the intended destination. Check the chosen collector or backend for the signals you enabled and verify that its retention and access controls match your organization’s policy.
How do I disable Claude Code telemetry?
First identify which data flow you mean. To change Anthropic operational metrics or error-report behavior, use the applicable controls in the data usage documentation; provider and account conditions matter, so do not assume a single setting or default applies to every installation. To stop organization-managed OpenTelemetry export, change the relevant telemetry/exporter configuration described in the monitoring guide. Feedback submissions are a separate path governed by the feedback action and its selection/configuration. Disabling one mechanism should not be treated as disabling the others.
Which mechanism should you use?
- Automate or guard a lifecycle action: use a hook, then select the event, matcher, handler, and scope appropriate to the task.
- Review Anthropic’s operational data handling: consult the data-usage controls for the relevant provider and account.
- Send monitoring signals to systems your organization manages: configure OpenTelemetry and govern the exporter destination and signal set.
These are complementary mechanisms, not one combined “hooks telemetry” feature. Anthropic’s documentation pages are living references; the versions reviewed for this guide were checked on October 7, 2026, and did not state publication dates. Recheck the current event names, configuration options, data handling, and provider behavior when implementing them.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitches

