Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

Claude Code Hooks and Telemetry: A Lifecycle-First Guide

A lifecycle-first guide to Claude Code hooks, event matching, configuration scope, operational telemetry, and organization-managed OpenTelemetry export.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Claude Code hooks automate work at specific points in a session; OpenTelemetry is a separate way for organizations to export monitoring data. This guide moves from lifecycle events to matching and handler choices, then to telemetry controls. “Progressive disclosure” is an editorial description of that sequence, not a named Claude Code feature.

What are Claude Code hooks?

A hook is a configured handler that runs when a particular lifecycle event occurs. Depending on the event, a handler can be a shell command, HTTP endpoint, MCP tool call, prompt, or agent. Claude Code provides JSON context to the handler: command handlers receive it on standard input, while HTTP handlers receive it in the request body. The available inputs and decisions differ by event, so check the current hooks reference before implementing one.

As an Amazon Associate I earn from qualifying purchases.

Think of a hook configuration as three parts: the lifecycle event that can trigger it, an optional matcher group that filters when it runs, and one or more handlers. A hook may observe an event, provide context, or affect a decision. Its output and exit behavior matter; silence does not automatically approve an action.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which Claude Code hook events are available?

The events are easier to reason about by the point in the session they represent. This grouping is an explanatory aid, not a separate product taxonomy; the event reference defines each event’s precise firing condition, schema, matcher field, supported handlers, and decisions.

Session boundaries and setup

  • Setup, SessionStart, and SessionEnd cover setup and session boundaries.

Prompt and response flow

  • UserPromptSubmit and UserPromptExpansion relate to prompt handling.
  • MessageDisplay, Stop, and StopFailure relate to message display and stopping behavior.

Tools and permissions

  • PreToolUse runs before a tool is used; PostToolUse runs after successful use.
  • PostToolUseFailure and PostToolBatch cover failure and batch cases.
  • PermissionRequest and PermissionDenied relate to permission decisions.

Agents and tasks

  • SubagentStart and SubagentStop mark subagent activity.
  • TaskCreated, TaskCompleted, and TeammateIdle relate to task and teammate activity.

Workspace and configuration

  • InstructionsLoaded, ConfigChange, CwdChanged, and DirectoryAdded cover instructions, configuration, and workspace changes.
  • FileChanged, WorktreeCreate, and WorktreeRemove cover file and worktree changes.

Context, model, and MCP input

  • PreCompact and PostCompact relate to context compaction; PreModelSwitch and PostModelSwitch relate to model changes.
  • Elicitation and ElicitationResult cover MCP elicitation.

Notifications

  • Notification is the notification event.

How do you run a hook only before a particular tool?

Use PreToolUse for a handler that should run before tool execution, then add a matcher group for the relevant tool. For example, the hooks reference demonstrates matching Bash and narrowing further to relevant Bash commands. That lets a guard run for selected commands instead of every tool action. The exact matcher fields and syntax are event-specific; use the reference’s current example rather than assuming all events accept the same filters.

In the documented guard example, a handler can return a structured deny decision for destructive commands. A successful exit without output leaves the normal permission flow in place. This distinction is important: a hook can be designed to intervene, but merely running a hook or producing no output does not itself grant permission.

Where do hook settings apply?

Choose a configuration location based on who should receive and control the automation. The settings documentation describes settings behavior and precedence; the hooks reference covers hook-specific sources and scope.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • User settings: apply across that user’s projects.
  • Project settings: can be committed and shared with a project.
  • Local project settings: are project-specific and are not shared.
  • Managed settings: are controlled by an organization.
  • Other contexts: plugins, skills, and subagent frontmatter can define hooks within their respective contexts.

Do not assume that a hook configured for a local session behaves identically in a cloud or self-hosted context; configuration availability can differ.

How is OpenTelemetry different from hooks?

Hooks automate or influence behavior at lifecycle events. OpenTelemetry export is for organization-managed monitoring, not another hook type. Claude Code can export metrics as time-series data, events through the logs/events protocol, and optional traces to configured exporters. The organization chooses the exporter and, where applicable, the OTLP endpoint and monitoring backend. See the OpenTelemetry monitoring guide for the current configuration options.

The documented setup uses environment variables, including CLAUDE_CODE_ENABLE_TELEMETRY, exporter selection, and an OTLP endpoint where applicable. Administrators can also provide these values through a managed settings file. Repository .claude/settings.json and .claude/settings.local.json are ignored for OpenTelemetry exporter variables, and Claude Code does not pass OTEL_* variables to spawned subprocesses such as hooks and MCP servers.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What telemetry does Claude Code send?

“Telemetry” can mean different data flows, so identify the one you intend to control. Anthropic’s data usage documentation describes operational usage metrics and error reports, while OpenTelemetry export is configured for organization-managed monitoring. Feedback-related commands are another distinct path: depending on user selection and configuration, they can send conversation history, including code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The data usage documentation describes operational metrics as excluding code, prompts, and file paths. Error reports have their own documented contents and redaction behavior; do not assume the metrics description also describes error reports or feedback submissions. Defaults and controls can vary with API provider, subscription, Claude Code version, and applicable organization agreements. Consult the current data usage page for the conditions that apply to your account.

Best Value
Sale
Game Programming Patterns
  • Brand New in box. The product ships with all relevant accessories

How do you disable or manage telemetry?

First decide which data flow you mean. For Anthropic operational metrics and error reporting, use the separate controls described in the data usage documentation; do not treat a hook setting as a telemetry opt-out. For organization-exported OpenTelemetry, administrators configure export through the documented environment variables or managed settings. The monitoring guide covers exporter configuration and signal selection. If feedback submission is the concern, treat it separately from both operational reporting and configured OpenTelemetry export.

Before deploying organization-wide settings, verify the current behavior for your provider and account conditions. The Claude Code documentation is living documentation and does not state a publication date; these pages were checked on October 7, 2026.

Which mechanism should you use?

  • Choose a hook when a command or other handler should run at a session, prompt, tool, permission, task, workspace, or context event.
  • Use the data usage controls when the question is Anthropic’s operational metrics or error reporting.
  • Configure OpenTelemetry when your organization needs to export selected metrics, events/logs, or optional traces to its monitoring stack.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.