← Back to Explorer

Lifecycle Hooks

/hooks
Event-driven callbacks that fire automatically at defined points in an agent runtime — before or after a tool call, turn, file edit, or session boundary. The runtime runs them; the model does not choose to call them.
Strata: L3, L4 Axes: Execution, Orchestration Status: seed

Explainer

Hooks are deterministic extension points in an agent runtime. Code runs before or after a lifecycle event — a turn, tool call, file edit, session stop, or context compaction boundary — without any model decision required. That makes them different from MCP tools (which the model chooses to call) and from skills or workflows (which a human or agent invokes on demand).

Think of hooks like React lifecycle methods or Express middleware: they fire because of where you are in the lifecycle, not because anyone asked for them. That guarantee is exactly what makes them useful for ambient behavior — memory capture, auditing, heartbeat checks — that must happen reliably, not best-effort.

Mechanism vs Pattern — the key distinction

Hook, cron, and VS Code task are mechanisms (how something fires). Heartbeat is a pattern (what something does — quiet recurring check, clips findings). A heartbeat can be implemented via any of the three mechanisms.

ConceptTypeTriggerWho runs itTypical use
Hook Mechanism Lifecycle event (Stop, PostToolUse, SessionStart…) Agent runtime (Claude Code harness) Memory capture, audit, sentinel check on session end
Cron job Mechanism Fixed time interval (independent of sessions) OS scheduler / task runner Daily brief at 07:00, weekly repo health scan
VS Code Task Mechanism IDE events (folder open, build trigger, Ctrl+Shift+B) VS Code task runner Pre-build linting, launch scripts, rename queues
Skill Capability unit Manual (/sentinel) or agentic (model decides) Human or model On-demand audit, pipeline step, named tool
Workflow Orchestration Manual or agentic, multi-step sequence Human or model LinkedIn crucible, acquire-skill, post-ship checklist
Heartbeat Pattern Any recurring mechanism above Whichever mechanism implements it Sentinel clips violations every session end; brief every morning
Rule of thumb: If you need it to happen without anyone asking, use a hook (session-scoped) or cron (time-scoped). If you need it on demand, build a skill. If you need it to chain multiple skills, build a workflow.

Hook events (Claude Code)

Anti-Patterns

Mitigations

Top Products

Related Concepts