Skip to main content

Toolkit

Capability 02 · reviewed 2026-08-01

On this page3 sections

Lifecycle Hooks

Hooks attach deterministic programs or product-defined handlers to moments in an AgentA worker you delegate to: brief it, and it takes steps on its own. A chatbot answers; an agent acts.An LLM that runs tools in a loop toward a goal — it acts, checks the result, decides the next step, and repeats until done.Full definition run: before a tool executes, after it completes, when a session changes state, or when work is declared complete.

The strongest use of hooks is not “make the model behave.” It is to move repeatable checks out of probabilistic instructions and into an inspectable execution path.

What Hooks Are Good For

  • Rejecting or rewriting a proposed tool action when the product exposes a blocking event.
  • Running fast validation after edits.
  • Recording an audit event with the action, result, and causal run identifier.
  • Loading narrowly scoped context at a defined lifecycle point.
  • Triggering a review or completion check before work leaves the agent loop.

The Enforcement Boundary

Hook existence does not imply hard enforcement. Products differ in event coverage, timeout behavior, exit-code semantics, configuration scope, and whether cloud execution uses the same hook runtime as local execution.

OpenAI describes Codex hooks as guardrails rather than complete enforcement. GitHub documents fail-open timeout behavior for Copilot hooks. Claude Code exposes a broad event and handler model, but its hooks still run inside the product's configured execution boundary. For a release-critical invariant, verify the actual event path and keep the final gate outside the model-controlled workflow.

A Defensible Design

  1. Identify the exact lifecycle event and surface.
  2. Define the input contract and the action that a handler may take.
  3. Make failure behavior explicit: block, warn, retry, or record.
  4. Bound runtime and output size.
  5. Test bypasses, timeouts, malformed output, and nested-agent behavior.
  6. Keep the authoritative release decision in CI or another independently controlled gate.

The deeper lenses retain Claude Code configuration examples. Translate the mechanism, not the JSON shape, when applying them to Codex or Copilot.

Documented coverage · 2026-08-01

Lifecycle Hooks by product

These classifications are documentation findings, not empirical runtime tests. Surface names are explicit because product-family claims are too coarse.

Claude Code

Anthropic

NativeCLI · IDE

Claude Code documents command, prompt, agent, HTTP, and MCP-tool hooks across lifecycle events and settings scopes.

Basis: documentedSources: 1

UnknownCloud

The reviewed hook reference is insufficient to assert the same lifecycle contract on Claude Code's hosted surface.

Basis: documentedSources: 1

OpenAI Codex

OpenAI

NativeCLI · IDE

Codex exposes first-party local lifecycle hooks. OpenAI explicitly describes hooks as guardrails, not complete policy enforcement.

Basis: documentedSources: 2

No documented equivalentCloud

The reviewed official hooks reference documents the local Codex hook boundary, not an equivalent cloud hook runtime.

Basis: documentedSources: 2

UnknownWeb

The reviewed hook reference does not establish a browser-hosted hook runtime.

Basis: documentedSources: 2

GitHub Copilot

GitHub

PartialCLI · Cloud

Copilot documents lifecycle hooks and decision control, but hook timeouts fail open; use them as automation and guardrails, not a universal hard-policy boundary.

Basis: documentedSources: 3

UnknownIDE · Web

The reviewed hooks source does not establish the same event and decision contract for general IDE and web interactions.

Basis: documentedSources: 3

Source register

Lifecycle Hooks sources

Primary vendor documentation reviewed on the date shown. Links may change after publication.

  1. Hooks reference (opens in a new tab)

    Anthropic · official docs · accessed 2026-08-01

  2. Hooks (opens in a new tab)

    OpenAI · official docs · accessed 2026-08-01

  3. GitHub Copilot hooks reference (opens in a new tab)

    GitHub · official docs · accessed 2026-08-01

Comparative implementation depth

Four implementation lenses