Claude Code vs OpenClaw hooks: events and CLI compared
Claude Code and OpenClaw both let you run your own code at lifecycle moments, but the two hook models are shaped by different architectures. Claude Code hooks live inside a single agent session: thirty-one PascalCase events cover the loop from SessionStart through PreToolUse, PostToolUse and Stop to SessionEnd, with a matcher field narrowing when each fires. OpenClaw hooks live in a long-running gateway that serves chat channels: sixteen colon-namespaced keys (command:new, message:received, gateway:startup) group into five families, and subscribing to a bare family name catches everything in it. The table pairs the moments that correspond; the fourth column is our note on how exact each pairing is.
| Lifecycle moment | Claude Code | OpenClaw | How close is the match |
|---|---|---|---|
| A new conversation or session is created | SessionStart | command:new | Claude Code fires SessionStart for startup, resume, clear, compact, and fork (matcher-selectable). OpenClaw's event is tied to the /new command itself. |
| A session is reset | SessionStart | command:reset | Claude Code treats clear as one more way a session starts; OpenClaw emits a dedicated command:reset. |
| Before context compaction | PreCompact | session:compact:before | Near-identical concept; Claude Code's matcher distinguishes manual from auto. |
| After compaction completes | PostCompact | session:compact:after | Both fire after the summary replaces history. |
| Work is stopped | Stop | command:stop | Different meanings: Claude Code's Stop fires whenever Claude finishes responding; OpenClaw's fires when the /stop command is issued. |
| A scheduled or idle reset | SessionStart | session:auto-reset | OpenClaw's daily/idle reset is its own event; in Claude Code a resumed or restarted session comes back through SessionStart. |
| Session properties change | ConfigChange | session:patch | Loose equivalence: ConfigChange watches configuration files, session:patch fires on session property modification. |
| Inbound user input | UserPromptSubmit | message:received | Claude Code hooks the prompt before processing; OpenClaw hooks the inbound channel message, including transcription and preprocessing stages after it. |
| Audio input transcribed | - | message:transcribed | No Claude Code equivalent - transcription is an OpenClaw gateway concern. |
| Media/link preprocessing done | - | message:preprocessed | Fires whether preprocessing ran or was skipped. |
| Outbound message / display | MessageDisplay | message:sent | MessageDisplay is display-only while text streams; message:sent reports the send attempt with context.success. |
| Workspace context injection | InstructionsLoaded | agent:bootstrap | Claude Code fires per loaded CLAUDE.md or rules file; OpenClaw fires once before bootstrap files are injected. |
| Process startup / shutdown | SessionEnd | gateway:startup | Closest pairing across different architectures: Claude Code sessions end (SessionEnd); OpenClaw's long-running gateway starts, stops (gateway:shutdown) and restarts (gateway:pre-restart). |
| Subscribe to a whole family | - | command | OpenClaw accepts bare family names (command, session, agent, gateway, message) as catch-alls; Claude Code hooks subscribe per event, with matchers narrowing within an event. |
| List configured hooks | /hooks | openclaw hooks list | Claude Code's /hooks is an in-session command; OpenClaw manages hooks from the shell. |
| Inspect / toggle a hook | - | openclaw hooks info <hook-name> | OpenClaw adds info, check, enable and disable subcommands; in Claude Code, hooks live in settings files and /hooks is the in-session view. |
The structural difference is where filtering happens. Claude Code has many events and a matcher within each: PreToolUse alone can be narrowed by tool name, SessionStart by how the session began, StopFailure by error type. OpenClaw has fewer, more specific keys and no matcher; its docs instead warn that subscribing to an unlisted name leaves a hook silently dead, and openclaw hooks info flags such typos. Tool-call interception is the biggest one-sided gap: Claude Code's PreToolUse, PermissionRequest, PostToolUse and PostToolUseFailure have no OpenClaw counterpart, because OpenClaw hooks watch commands and messages rather than an agentic tool loop.
Management is the mirror image. OpenClaw ships a full shell CLI - openclaw hooks list, info, check, enable, disable - with an eligibility system that verifies binaries, environment variables and config before a hook can run. Claude Code keeps configuration in settings files, surfaces the current state through the in-session /hooks command, and decides at fire time via matchers. Full event tables with per-event notes are on the two reference pages below.
Full references: Claude Code (142) · OpenClaw (99) · all comparisons