devto 2026-07-20 원문 보기 ↗
Claude Code hooks and persistent session monitoring are often compared as if they were two implementations of the same feature.
They are not.
A hook answers: “Which lifecycle event just happened, and what should run because of it?”
A monitor answers: “Across the sessions that exist now, which one is running, waiting, blocked, completed, stalled, or inactive?”
The difference becomes obvious after a restart, a missed event, or a second simultaneous session.
Claude Code documents session-level, turn-level, tool-level, permission, notification, subagent, task, compaction, and elicitation events. That makes hooks a good fit for deterministic local automation:
The handler can act. It can call a command, HTTP endpoint, prompt, agent, or MCP tool. That power is also why hooks need clear failure behavior, bounded runtime, and idempotent writes.
A persistent monitor has a broader but less deterministic job. It combines session records, semantic timestamps, process signals, and expiry rules to reconstruct current state.
That lets it:
This coverage costs more inference. The monitor has to tolerate partial writes, deduplicate records, define freshness windows, and avoid treating file modification time as semantic truth.
A fresh Stop event is strong evidence that one response ended. It does not prove that the session still needs attention five minutes later.
The user may already have replied. Another turn may be running. A later permission request or provider error may have changed the operational state.
The inverse is also true. Recent file or process activity can support a running classification, but it cannot prove successful completion.
This is the central rule:
event = evidence at a lifecycle point
state = current conclusion after identity, freshness, and supersession
Use hooks when the event itself is the contract. Keep handlers small, include session and turn identity when available, and decide explicitly whether handler failure should block the coding flow.
Use monitoring when current context is the contract. Document supported providers, terminal markers, silence thresholds, supersession rules, and recovery behavior.
If you need both low latency and durable context, combine them:
lifecycle event -> compact local evidence record
durable session artifacts -> recovery and reconciliation
both sources -> per-session state engine
state transitions -> deduplicated notification
The hook makes event meaning explicit. The monitor provides restart recovery, multi-session comparison, expiry, and a place to process later activity. Neither source should bypass identity and freshness checks.
For a status companion, passive observation is usually the safer boundary. Agent Island reads local Claude Code and Codex session evidence, shows live and your-turn states, and does not control the agents or upload session data to an Agent Island service.
Read the full hooks-versus-monitoring comparison and implementation checklist