OMC
Oh My ClaudeCodev4.12.0

Lifecycle Events

Explains Claude Code's 11 lifecycle events and the hooks connected to each event.

What are Lifecycle Events?

Claude Code emits multiple events during a session. OMC connects hooks to these events to extend behavior.

Below are the 11 lifecycle events supported by Claude Code and the OMC hooks executed at each event.

UserPromptSubmit

Fires when a user submits a prompt.

ScriptRoletimeout
keyword-detector.mjsDetects magic keywords and invokes the corresponding skill5s
skill-injector.mjsInjects skill prompts3s

This event runs on all user input (matcher: "*"). When the keyword detector finds keywords like "ultrawork", "ralph", or "autopilot", it injects a skill invocation instruction via additionalContext.

SessionStart

Fires when a new session starts.

ScriptmatcherRoletimeout
session-start.mjs*Session initialization, state restoration5s
project-memory-session.mjs*Loads project memory5s
setup-init.mjsinitInitial setup wizard30s
setup-maintenance.mjsmaintenanceMaintenance tasks60s

The init and maintenance matchers only run in special cases. For a normal session start, only the 2 scripts with * matcher run.

PreToolUse

Fires just before Claude uses a tool.

ScriptRoletimeout
pre-tool-enforcer.mjsValidates rules before tool use3s

Runs on all tool calls (matcher: "*") and enforces agent permission restrictions (e.g., blocking Write/Edit for read-only agents).

PermissionRequest

Fires when a permission request occurs during Bash tool execution.

ScriptmatcherRoletimeout
permission-handler.mjsBashHandles Bash command permission5s

Only handles permission requests for the Bash tool.

PostToolUse

Fires after a tool use completes.

ScriptRoletimeout
post-tool-verifier.mjsVerifies tool use results and injects additional context3s
project-memory-posttool.mjsUpdates project memory3s

Injects additional guidance based on tool results for Read, Write, Edit, Bash, etc. For example, after reading a file it might hint "consider using parallel reads".

PostToolUseFailure

Fires when a tool use fails.

ScriptRoletimeout
post-tool-use-failure.mjsProvides recovery guidance for failed tool use3s

SubagentStart

Fires when a subagent is spawned.

ScriptRoletimeout
subagent-tracker.mjs startTracks subagent start, injects prompts3s

Records the subagent's name, start time, and session information.

SubagentStop

Fires when a subagent completes.

ScriptRoletimeout
subagent-tracker.mjs stopTracks subagent completion5s
verify-deliverables.mjsVerifies subagent deliverables5s

PreCompact

Fires just before context compaction.

ScriptRoletimeout
pre-compact.mjsPreserves state before compaction10s
project-memory-precompact.mjsPreserves project memory5s

Preserves important state and memory before compaction runs when the context window is full.

Stop

Fires when Claude's response ends.

ScriptRoletimeout
context-guard-stop.mjsMonitors context usage5s
persistent-mode.cjsMaintains active mode state (ralph, ultrawork, etc.)10s
code-simplifier.mjsAuto-simplifies modified files (opt-in)5s

persistent-mode injects reinforcement messages like "The boulder never stops" when there is an active execution mode to encourage continued work.

SessionEnd

Fires when a session ends.

ScriptRoletimeout
session-end.mjsSaves session summary, sends callback notifications10s

Saves agent activity, token usage, etc. during the session to .omc/sessions/, and sends completion notifications to Discord/Telegram/Slack if configured.

On this page