Claude Code Hooks

Claude Code Hooks, Visualized.

Claude Code hooks let you run deterministic shell commands on every key event in the Claude Code lifecycle: before a tool is used, after a tool is used, when a prompt is submitted, when an agent stops, or when a notification is sent. AgentsRoom is the visual command center that lets you watch every hook fire in real time, across dozens of Claude Code agents, in dozens of projects.

Hooks are Anthropic's official way to add deterministic automation, guardrails, audit trails and custom side effects to Claude Code. AgentsRoom doesn't replace your hooks. It runs the real Claude Code CLI, so every hook you configure in .claude/settings.json keeps working exactly as intended. What AgentsRoom adds is visibility: a live dashboard where you can see every hook trigger, per agent, per project, per run.

What are Claude Code hooks?

Claude Code hooks are user-defined shell commands that Claude Code automatically executes at specific points during an agent session. They are configured in .claude/settings.json (shared, committed to git) or .claude/settings.local.json (personal, gitignored), and they give you deterministic control over the behavior of your Claude Code agents. Where a prompt is probabilistic, a hook is 100% deterministic: it runs every time the matching event fires, no exceptions.

Hooks are Anthropic's answer to the need for guardrails, automation, telemetry, audit logging and custom integrations. You can use Claude Code hooks to format code automatically after every edit, block dangerous commands before they run, log every tool call to a file, send a desktop notification when the agent is waiting for input, trigger a CI job when a session ends, or stream every prompt to an observability backend. Any shell command you can write, you can wire to a Claude Code hook.

Because hooks live in the project itself (.claude/settings.json is git-committed), they travel with your codebase. Every developer on the team, and every AI agent spawned from that project, inherits the same safety net. AgentsRoom respects this model end to end: the desktop app doesn't rewrite your hooks, it runs the real Claude Code CLI as a child process, which picks up your hook configuration automatically, just like running claude code from a terminal would.

The 6 Claude Code Hook Events

Every Claude Code agent session fires hook events at well-defined points. Here's what each event means and what you can do with it.

PreToolUse

The PreToolUse hook fires before Claude Code runs any tool (Bash, Edit, Write, Read, Grep, etc.). It's the perfect place for guardrails: block dangerous commands, require confirmation for destructive operations, enforce project-specific rules, or rewrite tool arguments before execution. Return a non-zero exit code from the hook to block the tool call entirely. PreToolUse is the #1 Claude Code hook for safety-conscious teams.

PostToolUse

The PostToolUse hook fires immediately after any Claude Code tool completes. This is where you wire up automatic post-processing: run a formatter (Prettier, Black, rustfmt) after every Edit, trigger a linter after every Write, update a changelog when a file is modified, or push telemetry events. PostToolUse is the bread-and-butter hook for turning Claude Code into a disciplined team member that leaves the codebase cleaner than it found it.

UserPromptSubmit

The UserPromptSubmit hook fires whenever a new prompt is sent to a Claude Code agent. Use it to log every prompt for audit and compliance, rewrite prompts on the fly (inject context, redact secrets), route requests to different models, or enforce naming conventions. Combined with AgentsRoom's multi-agent dashboard, UserPromptSubmit gives you a full audit trail of every instruction sent to every Claude Code agent.

Stop

The Stop hook fires when a Claude Code agent session ends, either because the work is done or because it was cancelled. It's the right place to run cleanup jobs, push a final summary to a tracking system, commit artifacts, or notify a human that the session is over. AgentsRoom complements the Stop hook with its own notification system, so you get notified both by your custom hook and by AgentsRoom's desktop + mobile push notifications.

Notification

The Notification hook fires when Claude Code sends a system notification โ€” typically when the agent is waiting for user input or has finished a long-running task. Use it to route notifications to Slack, Discord, Telegram, email, or any webhook you like. AgentsRoom already surfaces Claude Code notifications natively in its multi-agent dashboard and as push notifications on your phone, so the Notification hook is a perfect place to add custom integrations on top.

SubagentStop

The SubagentStop hook fires when a Claude Code subagent finishes its work and returns control to the parent. If you use Claude Code subagents defined in .claude/agents/*.md to delegate specialized tasks, SubagentStop lets you log what each subagent did, aggregate their outputs, or trigger a follow-up step. Inside AgentsRoom, SubagentStop events appear in the live agent timeline so you can see exactly which subagents ran inside each Claude Code session.

Why Claude Code Hooks Matter

Hooks turn Claude Code from an impressive AI into a production-grade coding agent your whole team can rely on.

Deterministic Safety Guardrails

Prompts are probabilistic and can be bypassed. Claude Code hooks are deterministic shell commands that always run. A PreToolUse hook can block any rm -rf, any push --force, any destructive migration โ€” no matter how the agent phrases its reasoning. This is the gold standard for safety-critical Claude Code deployments.

Zero-Effort Automation

Wire Claude Code hooks to your formatters, linters, test runners, type checkers, and build scripts. Every edit the agent makes triggers the same checks your CI pipeline runs โ€” locally, instantly, automatically. Your Claude Code agents become self-disciplined contributors that never forget to run the formatter.

Complete Audit Trail

Every prompt, every tool call, every session start and stop can be logged by Claude Code hooks. Combine that with AgentsRoom's visual timeline and you get a full audit trail of every AI coding agent action โ€” essential for compliance-heavy teams, security-conscious companies, and anyone serious about observable AI development.

Team-Wide Conventions

Because .claude/settings.json is committed to git, a single set of Claude Code hooks enforces the same conventions for every developer on the team and every AI agent spawned from the project. New team members inherit the guardrails the moment they clone the repo. Upgrade your entire AI coding team's behavior with one pull request.

Live Hook Observability

Claude Code hooks produce events. AgentsRoom turns those events into a visual feed: every hook trigger, every tool call, every status change, streamed live per agent and per project. You don't have to tail logs any more โ€” you watch your Claude Code fleet work in real time.

Shift From Watching to Supervising

Without hooks, running Claude Code means watching every tool call. With hooks, you delegate the watching to deterministic code and supervise at the exception level. AgentsRoom amplifies this: you see all your hook-protected Claude Code agents at once, and you only step in when something demands your attention.

Claude Code Hooks + AgentsRoom

AgentsRoom is the visual command center for Claude Code and other AI coding CLIs. It doesn't fork Claude Code, it doesn't re-implement hooks, it doesn't intercept tool calls. It runs the real Claude Code CLI as a child process inside a full xterm.js terminal, which means every hook you defined in .claude/settings.json or .claude/settings.local.json runs exactly as Anthropic designed it โ€” no compromises, no surprises, no invisible middleware.

What AgentsRoom adds is scale and visibility. You can run dozens of Claude Code agents in parallel, across dozens of projects, each with its own hook configuration, and see every hook trigger on one dashboard. Combined with AgentsRoom's per-agent notifications, mobile companion app, and real-time status tracking, Claude Code hooks become a first-class observability layer for your entire AI coding operation.

Runs the Real Claude Code CLI

AgentsRoom spawns real claude CLI processes inside full xterm.js terminals. Any hook configured in .claude/settings.json, .claude/settings.local.json or user-level settings fires automatically, exactly as if you ran Claude Code from your terminal. No patching, no rewriting, no loss of fidelity.

Hook Events Across a Multi-Agent Fleet

Run 10, 20, 50 Claude Code agents in parallel with hooks enabled. AgentsRoom's multi-agent dashboard surfaces hook-triggered notifications and status changes for every agent simultaneously. Your PreToolUse guardrails, PostToolUse formatters and Stop handlers all operate at fleet scale.

Cross-Project Hook Visibility

Every project in AgentsRoom has its own .claude/settings.json and therefore its own Claude Code hook configuration. The sidebar aggregates live status across projects so you can spot which hooks are firing where, which agents are blocked on user input, and which Stop hooks just completed a run.

Desktop + Mobile Notifications

AgentsRoom ships with native macOS notifications and end-to-end encrypted mobile push notifications. Claude Code's Notification hook, Stop hook and SubagentStop hook all produce signals that AgentsRoom surfaces directly on your desktop and phone. You can step away from the computer and still know when a hook tells you to come back.

Claude Code Hooks FAQ

What are Claude Code hooks, in one sentence?+
Claude Code hooks are user-defined shell commands that Claude Code runs automatically on specific lifecycle events (PreToolUse, PostToolUse, UserPromptSubmit, Stop, Notification, SubagentStop), giving you deterministic control over the behavior of your AI coding agents.
Where are Claude Code hooks configured?+
Claude Code hooks live in .claude/settings.json (committed to git, shared with the team) or .claude/settings.local.json (gitignored, personal). Both files are picked up automatically by the Claude Code CLI. AgentsRoom runs the real Claude Code CLI, so it respects both files without any additional configuration.
Does AgentsRoom replace Claude Code hooks?+
No. AgentsRoom does not replace, rewrite, or intercept Claude Code hooks. It runs the real Claude Code CLI as a child process, which means your hooks keep running exactly as Anthropic designed them. AgentsRoom's role is to give you a visual command center and multi-agent dashboard on top of hook-powered Claude Code sessions.
Can I monitor Claude Code hook events in AgentsRoom?+
Yes. AgentsRoom streams the output of every Claude Code session live, including hook-triggered events (formatter output, guardrail rejections, notification messages, subagent stops). The multi-agent dashboard aggregates status across every running agent, so you can spot at a glance which hooks fired where.
What's the most useful Claude Code hook to start with?+
For most teams, PostToolUse is the highest-value first hook: wire it to your formatter and linter so every Edit is instantly cleaned up. For safety-critical projects, PreToolUse is indispensable: block destructive Bash commands before the agent runs them. Once those are in place, add UserPromptSubmit for audit logging and Stop for completion telemetry.
Is AgentsRoom free to use with Claude Code hooks?+
Yes. AgentsRoom is free to download and use with up to 3 projects. Bring your own Anthropic subscription or API key. Every hook, every PreToolUse guardrail, every PostToolUse formatter you've configured in .claude/settings.json will work immediately โ€” no extra setup, no extra fees.

See Your Claude Code Hooks Fire Live

Download AgentsRoom, open a project with .claude/settings.json hooks, spawn a Claude Code agent, and watch every hook event stream into the dashboard in real time.

FreeDownload AgentsRoom

Companion app: monitor your agents on the go

Works with Claude, Codex, OpenCode, Gemini CLI, and Aider

Multiple projects
Multi-provider
Multiple agents
Live status
File diff & commit
Mobile companion
Live preview