Skip to main content

Toolkit

Lifecycle Hooks · Playbook

On this page6 sections

Playbook

1. State the Control Objective

Name the unwanted outcome, not the desired script. “Prevent writes outside the assigned module” is testable. “Add a safety hook” is not.

2. Select the Exact Event and Surface

Use the current official event reference for the target product. Record whether the handler observes, blocks, or transforms. Do not assume a CLI event also exists in IDE or cloud execution.

3. Keep the Handler Deterministic

Parse structured input, validate only what the event can prove, bound execution time, and emit a documented result. Send expensive analysis to a later asynchronous path rather than delaying every tool call.

4. Define Failure Policy

Choose explicitly:

  • Fail closed for a narrow, high-confidence local control.
  • Fail open with an auditable warning when availability matters more.
  • Escalate to an independent gate for release-critical policy.

If the product fixes timeout behavior, design around that behavior rather than the policy you wish it had.

5. Test Adversarial Cases

Exercise allowed input, denied input, malformed payload, handler crash, timeout, nested agents, alternate tools, disabled configuration, and cloud/local divergence.

6. Duplicate the Load-Bearing Check

Run the authoritative check in CI or a policy service using independently controlled configuration. The hook shortens the correction loop; it should not become the only source of release truth.

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