Dokumentationerreichbar
Anthropic, Hooks reference
code.claude.com (externe Seite)
Die Herstellerdokumentation zu den Ereignissen, an denen sich eigene Programme einhängen lassen. Für das Gedächtnis sind drei Stellen entscheidend. Pre
geprüft 10.11.2026
Worauf sich diese Seite beruft, wörtlich, abgerufen am 04.08.2026:
Because the if filter is best-effort, use the permission system rather than a hook to enforce a hard allow or deny.
bestätigt 10.11.2026When Claude Code can't determine which commands the Bash input runs, it runs your hook regardless of the pattern.
bestätigt 10.11.2026No decision control. Used for side effects like logging or cleanup
bestätigt 10.11.2026Exit with code 2 to block the action.
bestätigt 10.11.2026The message that comes with the block is your hook's stderr. If your hook also printed JSON that makes a blocking decision, Claude Code uses that decision's reason instead.
bestätigt 10.11.2026Blocking error. Claude Code still reads the fields, but they can't override the block
bestätigt 10.11.2026Prevents Claude from stopping, continues the conversation
bestätigt 10.11.2026Claude Code applies an 8-consecutive-continuation cap: after stop hooks have continued the turn eight times in a row, Claude Code overrides the next block and ends the turn.
bestätigt 10.11.2026For most events, Claude Code writes stdout to the debug log and doesn't show it in the transcript.
bestätigt 10.11.2026Exit with code 2 to block compaction.
bestätigt 10.11.2026send a prompt to a Claude model for single-turn evaluation
bestätigt 10.11.2026Exit code 1 without valid JSON output is a non-blocking error unless the hook is one whose failure blocks the action, even though 1 is the conventional Unix failure code.
bestätigt 10.11.2026don't count on a stalled hook to act as a gate
bestätigt 10.11.2026On most events, when a hook fails or times out, Claude Code still carries out the action. A policy hook with a wrong path or a crashing script then lets everything through.
bestätigt 10.11.2026The note never establishes user intent, and if it claims you approved or requested something, the classifier checks that claim against your own messages in the conversation
bestätigt 10.11.2026the task is not marked as completed and the stderr message is fed back to the model as feedback
bestätigt 10.11.2026Cloud sessions don’t read your local ~/.claude/settings.json
bestätigt 10.11.2026The hook can deny the call, but staying silent doesn’t approve it.
bestätigt 10.11.2026Type /
bestätigt 10.11.2026hooks in Claude Code to open a read-only browser for your configured hooks. There is no way to disable an individual hook while keeping it in the configuration.
bestätigt 10.11.2026holds back hooks from every settings file, including your own
bestätigt 10.11.2026Hook entries merge across settings levels rather than replacing each other
bestätigt 10.11.2026when it judges the condition can never be satisfied
bestätigt 10.11.2026Claude Code runs an HTTP hook handler only if its URL matches the merged allowlist
bestätigt 10.11.2026The hook never starts an OAuth flow
bestätigt 10.11.2026Claude Code skips their mcp_tool hooks without calling the tool
bestätigt 10.11.2026Async hooks can’t block or control Claude’s behavior
bestätigt 10.11.2026where it denies the request
bestätigt 10.11.2026set once: true on it.
bestätigt 10.11.2026A -p session doesn’t count as accepting it.
bestätigt 10.11.2026Your user, project, local, and plugin hooks are blocked.
bestätigt 10.11.2026There is no timeout or retry limit.
bestätigt 10.11.2026only in non-interactive mode with the -p flag
bestätigt 10.11.2026only when Claude makes a single tool call in the turn
bestätigt 10.11.2026Command hooks execute shell commands with your full user permissions.
bestätigt 10.11.2026run in a folder you’ve never trusted
bestätigt 10.11.2026Claude writes the plan to a file on disk before calling the tool
bestätigt 10.11.2026Ask
bestätigt 10.11.2026User Question and Exit Plan Mode require user interaction. Claude Code injects the plan content and file path before passing the input to hooks.
bestätigt 10.11.2026This fires in two situations: when any agent explicitly marks a task as completed through the Task
bestätigt 10.11.2026Update tool, or when an agent team teammate finishes its turn with in-progress tasks. Frontmatter hooks in a project skill follow the same workspace trust rule as hooks in settings files
bestätigt 10.11.2026If the session is idle, the response waits until the next user interaction.
bestätigt 10.11.2026an async
bestätigt 10.11.2026Rewake hook that exits with code 2 wakes Claude immediately even when the session is idle To surface a warning to Claude from a Post
bestätigt 10.11.2026Tool Use or Post Tool Use Failure hook, exit 2 instead so Claude sees the stderr even though the tool already ran. 12 of those run at once and the rest start as running ones finish.
bestätigt 10.11.2026Each waiting hook’s timeout starts counting when that hook starts.
bestätigt 10.11.2026commands inside $() and backticks are checked
bestätigt 10.11.2026patterns that specify more than the command name run the hook anyway on $(), backticks, or $VAR
bestätigt 10.11.2026Any non-zero exit code causes worktree creation to fail
bestätigt 10.11.2026Skill discovery normally runs before Session
bestätigt 10.11.2026Start hooks finish, so without it, files a hook writes into ~/.claude/ skills/ or .claude/ skills/ can be missing when the first prompt runs. suppressOriginalPrompt changes only the block message.
bestätigt 10.11.2026The submitted text can still appear in local files such as the session transcript and your prompt history, so a blocking hook isn’t a way to keep a secret off disk.
bestätigt 10.11.2026An Agent SDK callback hook that exceeds its timeout blocks the tool call.
bestätigt 10.11.2026Non-blocking error: your hook exits with any other code, or fails in some other way, such as not starting or printing invalid JSON.
bestätigt 10.11.2026exit code 2 on these events sends Claude back to keep working, and Claude can’t repair a hook that won’t run
bestätigt 10.11.2026your stdout becomes instructions for the compaction summary
bestätigt 10.11.2026Keep that stdout under 10,000 characters per hook.
bestätigt 10.11.2026The compact_summary field contains the conversation summary generated by the compact operation.
bestätigt 10.11.2026Post
bestätigt 10.11.2026Compact hooks have no decision control. Claude Code ignores retry when the classifier produced no verdict
bestätigt 10.11.2026normally sends the tool call to the permission prompt, and the classifier doesn’t decide it
bestätigt 10.11.2026only when it has a permission host, such as an MCP tool you pass with --permission-prompt-tool
bestätigt 10.11.2026until the cleanupPeriodDays retention sweep deletes it, after 30 days by default
bestätigt 10.11.2026
Erst der rote TestHook im Glossar05 Das Gedächtnis07 Prüfen statt glauben08 Berechtigungen und Rechtemodi11 Codequalität und Refactoring12 Hooks und Skills18 Hooks und Mods23 Plan vor Code24 Test und Spezifikation zuerst