NachschlagenQuellenregister

Dokumentationerreichbar

Anthropic, Hooks reference

code.claude.com (externe Seite)

Die Her­stel­ler­do­ku­men­ta­tion zu den Ereignissen, an denen sich eigene Programme einhängen lassen. Für das Gedächtnis sind drei Stellen entscheidend. PreCompact kann das Verdichten anhalten, mit Exit-Code 2 oder "decision": "block". Läuft es durch, wird seine Standardausgabe zur Vorgabe für die Zusammenfassung. PostCompact hat laut Tabelle keine Ent­schei­dungs­ge­walt und dient nur Nebenwirkungen wie Protokoll oder Aufräumen; es bekommt die fertige Zusammenfassung als compact_summary. Einspeisen kann SessionStart, dort fügt das Feld hookSpecificOutput.additionalContext dem Kontext etwas hinzu, und dieses Ereignis kennt fünf Auslöser, darunter ausdrücklich "compact". Der Rückweg im Wortlaut führt damit über den Sitzungsstart. Für den Auto-Modus kann ein PostToolUse-Hook dem Ergebnis eines Aufrufs im Feld classifierContext eine Notiz für den Klassifikator anhängen. Kommt der Hook aus den Einstellungen, gilt sie als ungeprüfter Hinweis der Anwendung und nie als Wille des Menschen. Seit Version 2.1.295 kann ein Befehls- oder HTTP-Hook mit onFailure: "block" festlegen, dass sein Scheitern die Handlung abweist: ein Rückgabewert außer 0 und 2, ein Skript, das nicht startet, eine Zeit­über­schrei­tung. Am Ende einer Antwort und bei Hooks im Hintergrund wirkt die Einstellung nicht. Abgerufen am 09.10.2026.

geprüft 22.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 22.11.2026
  • When Claude Code can’t split the Bash input into subcommands, it runs your hook regardless of the pattern.bestätigt 22.11.2026
  • No decision control. Used for side effects like logging or cleanupbestätigt 22.11.2026
  • Exit with code 2 to block the action.bestätigt 22.11.2026
  • The 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 22.11.2026
  • Exit code 2 still blocks with most JSON your hook printsbestätigt 22.11.2026
  • Prevents Claude from stopping, continues the conversationbestätigt 22.11.2026
  • Claude 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 22.11.2026
  • On these events, your plain-text stdout reaches Claude or the compaction summarybestätigt 22.11.2026
  • Exit with code 2 to block compaction.bestätigt 22.11.2026
  • send a prompt to a Claude model for single-turn evaluationbestätigt 22.11.2026
  • Exit 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 22.11.2026
  • don't count on a stalled hook to act as a gatebestätigt 22.11.2026
  • On 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 22.11.2026
  • The 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 conversationbestätigt 22.11.2026
  • the task is not marked as completed and the stderr message is fed back to the model as feedbackbestätigt 22.11.2026
  • Cloud sessions don’t read your local ~/.claude/settings.jsonbestätigt 22.11.2026
  • The hook can deny the call, but staying silent doesn’t approve it.bestätigt 22.11.2026
  • Type /hooks in Claude Code to open a read-only browser for your configured hooks.bestätigt 22.11.2026
  • There is no way to disable an individual hook while keeping it in the configuration.bestätigt 22.11.2026
  • holds back hooks from every settings file, including your ownbestätigt 22.11.2026
  • Hook entries merge across settings levels rather than replacing each otherbestätigt 22.11.2026
  • when it judges the condition can never be satisfiedbestätigt 22.11.2026
  • Claude Code runs an HTTP hook handler only if its URL matches the merged allowlistbestätigt 22.11.2026
  • The hook never starts an OAuth flowsteht dort nicht mehr
  • Claude Code skips their mcp_tool hooks without calling the toolbestätigt 22.11.2026
  • Async hooks can’t block or control Claude’s behaviorbestätigt 22.11.2026
  • where it denies the requestbestätigt 22.11.2026
  • set once: true on it.steht dort nicht mehr
  • A -p session doesn’t count as accepting it.bestätigt 22.11.2026
  • Your user, project, local, and plugin hooks are blocked.bestätigt 22.11.2026
  • There is no timeout or retry limit.bestätigt 22.11.2026
  • only in non-interactive mode with the -p flagbestätigt 22.11.2026
  • only when Claude makes a single tool call in the turnbestätigt 22.11.2026
  • Command hooks execute shell commands with your full user permissions.bestätigt 22.11.2026
  • run in a folder you’ve never trustedbestätigt 22.11.2026
  • Claude writes the plan to a file on disk before calling the toolbestätigt 22.11.2026
  • AskUserQuestion and ExitPlanMode require user interaction.bestätigt 22.11.2026
  • Claude Code injects the plan content and file path before passing the input to hooks.bestätigt 22.11.2026
  • This fires in two situations: when any agent explicitly marks a task as completed through the TaskUpdate tool, or when an agent team teammate finishes its turn with in-progress tasks.bestätigt 22.11.2026
  • Frontmatter hooks in a project skill follow the same workspace trust rule as hooks in settings filesbestätigt 22.11.2026
  • If the session is idle, the response waits until the next user interaction.bestätigt 22.11.2026
  • an asyncRewake hook that exits with code 2 wakes Claude immediately even when the session is idlebestätigt 22.11.2026
  • To surface a warning to Claude from a PostToolUse or PostToolUseFailure hook, exit 2 instead so Claude sees the stderr even though the tool already ran.bestätigt 22.11.2026
  • 12 of those run at once and the rest start as running ones finish.bestätigt 22.11.2026
  • Each waiting hook’s timeout starts counting when that hook starts.bestätigt 22.11.2026
  • commands inside $() and backticks are checkedbestätigt 22.11.2026
  • patterns that specify more than the command name run the hook anyway on $(), backticks, or $VARbestätigt 22.11.2026
  • Any non-zero exit code causes worktree creation to failbestätigt 22.11.2026
  • Skill discovery normally runs before SessionStart hooks finish, so without it, files a hook writes into ~/.claude/skills/ or .claude/skills/ can be missing when the first prompt runs.bestätigt 22.11.2026
  • suppressOriginalPrompt changes only the block message.steht dort nicht mehr
  • The 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.steht dort nicht mehr
  • An Agent SDK callback hook that exceeds its timeout blocks the tool call.bestätigt 22.11.2026
  • Non-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 22.11.2026
  • exit code 2 on these events sends Claude back to keep working, and Claude can’t repair a hook that won’t runbestätigt 22.11.2026
  • your stdout becomes instructions for the compaction summarybestätigt 22.11.2026
  • Keep that stdout under 10,000 characters per hook.bestätigt 22.11.2026
  • The compact_summary field contains the conversation summary generated by the compact operation.bestätigt 22.11.2026
  • PostCompact hooks have no decision control.bestätigt 22.11.2026
  • Claude Code ignores retry when the classifier produced no verdictbestätigt 22.11.2026
  • normally sends the tool call to the permission prompt, and the classifier doesn’t decide itbestätigt 22.11.2026
  • only when it has a permission host, such as an MCP tool you pass with --permission-prompt-toolbestätigt 22.11.2026
  • until the cleanupPeriodDays retention sweep deletes it, after 30 days by defaultbestätigt 22.11.2026
  • A hook that runs for a Monitor command can deny it or have Claude Code ask you about it.bestätigt 22.11.2026
  • To allow or rewrite the command, switch from a Bash matcher to one that includes Monitorbestätigt 22.11.2026
  • a PostToolUse hook with one doesn't run for Monitor.bestätigt 22.11.2026
  • The server reviewed the input Claude wrote, not the input your hook returned.bestätigt 22.11.2026
  • Any updatedInput it returns is dropped, so what runs is what the server reviewedbestätigt 22.11.2026
  • your PostToolUse hooks run on its result and have 10 seconds to finishbestätigt 22.11.2026
  • Claude Code kills a command hook that is still running, whatever its timeoutbestätigt 22.11.2026
  • a message you queue with Enter doesn't interrupt the turn, so the hooks keep their usual timeoutbestätigt 22.11.2026
  • In interactive terminal sessions and VS Code sessions on a direct connection to the Anthropic APIbestätigt 22.11.2026
  • a command hook in settings or a plugin’s hooks file can change Bash, PowerShell, Monitor, Edit, Write, and NotebookEdit calls without this denialbestätigt 22.11.2026
  • The denial can still appear, such as when any hook changed an earlier call in the same Claude response or a Bash command asks to run outside the sandbox.bestätigt 22.11.2026
  • If Claude repeats the changed input exactly in its next response, your hook still runsbestätigt 22.11.2026
  • The key acts as Esc if you queued a ! command ahead of your messages or background tasks are disabledbestätigt 22.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

Alle Quellen

↑↓ auswählenEnter öffnenDie Suche läuft im Browser. Nichts wird übertragen.