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 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.2026
  • When Claude Code can't determine which commands the Bash input runs, it runs your hook regardless of the pattern.bestätigt 10.11.2026
  • No decision control. Used for side effects like logging or cleanupbestätigt 10.11.2026
  • Exit with code 2 to block the action.bestätigt 10.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 10.11.2026
  • Blocking error. Claude Code still reads the fields, but they can't override the blockbestätigt 10.11.2026
  • Prevents Claude from stopping, continues the conversationbestätigt 10.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 10.11.2026
  • For most events, Claude Code writes stdout to the debug log and doesn't show it in the transcript.bestätigt 10.11.2026
  • Exit with code 2 to block compaction.bestätigt 10.11.2026
  • send a prompt to a Claude model for single-turn evaluationbestätigt 10.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 10.11.2026
  • don't count on a stalled hook to act as a gatebestätigt 10.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 10.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 10.11.2026
  • the task is not marked as completed and the stderr message is fed back to the model as feedbackbestätigt 10.11.2026
  • Cloud sessions don’t read your local ~/.claude/settings.jsonbestätigt 10.11.2026
  • The hook can deny the call, but staying silent doesn’t approve it.bestätigt 10.11.2026
  • Type /hooks in Claude Code to open a read-only browser for your configured hooks.bestätigt 10.11.2026
  • There is no way to disable an individual hook while keeping it in the configuration.bestätigt 10.11.2026
  • holds back hooks from every settings file, including your ownbestätigt 10.11.2026
  • Hook entries merge across settings levels rather than replacing each otherbestätigt 10.11.2026
  • when it judges the condition can never be satisfiedbestätigt 10.11.2026
  • Claude Code runs an HTTP hook handler only if its URL matches the merged allowlistbestätigt 10.11.2026
  • The hook never starts an OAuth flowbestätigt 10.11.2026
  • Claude Code skips their mcp_tool hooks without calling the toolbestätigt 10.11.2026
  • Async hooks can’t block or control Claude’s behaviorbestätigt 10.11.2026
  • where it denies the requestbestätigt 10.11.2026
  • set once: true on it.bestätigt 10.11.2026
  • A -p session doesn’t count as accepting it.bestätigt 10.11.2026
  • Your user, project, local, and plugin hooks are blocked.bestätigt 10.11.2026
  • There is no timeout or retry limit.bestätigt 10.11.2026
  • only in non-interactive mode with the -p flagbestätigt 10.11.2026
  • only when Claude makes a single tool call in the turnbestätigt 10.11.2026
  • Command hooks execute shell commands with your full user permissions.bestätigt 10.11.2026
  • run in a folder you’ve never trustedbestätigt 10.11.2026
  • Claude writes the plan to a file on disk before calling the toolbestätigt 10.11.2026
  • AskUserQuestion and ExitPlanMode require user interaction.bestätigt 10.11.2026
  • Claude Code injects the plan content and file path before passing the input to hooks.bestätigt 10.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 10.11.2026
  • Frontmatter hooks in a project skill follow the same workspace trust rule as hooks in settings filesbestätigt 10.11.2026
  • If the session is idle, the response waits until the next user interaction.bestätigt 10.11.2026
  • an asyncRewake hook that exits with code 2 wakes Claude immediately even when the session is idlebestätigt 10.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 10.11.2026
  • 12 of those run at once and the rest start as running ones finish.bestätigt 10.11.2026
  • Each waiting hook’s timeout starts counting when that hook starts.bestätigt 10.11.2026
  • commands inside $() and backticks are checkedbestätigt 10.11.2026
  • patterns that specify more than the command name run the hook anyway on $(), backticks, or $VARbestätigt 10.11.2026
  • Any non-zero exit code causes worktree creation to failbestätigt 10.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 10.11.2026
  • suppressOriginalPrompt changes only the block message.bestätigt 10.11.2026
  • 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.bestätigt 10.11.2026
  • An Agent SDK callback hook that exceeds its timeout blocks the tool call.bestätigt 10.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 10.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 10.11.2026
  • your stdout becomes instructions for the compaction summarybestätigt 10.11.2026
  • Keep that stdout under 10,000 characters per hook.bestätigt 10.11.2026
  • The compact_summary field contains the conversation summary generated by the compact operation.bestätigt 10.11.2026
  • PostCompact hooks have no decision control.bestätigt 10.11.2026
  • Claude Code ignores retry when the classifier produced no verdictbestätigt 10.11.2026
  • normally sends the tool call to the permission prompt, and the classifier doesn’t decide itbestätigt 10.11.2026
  • only when it has a permission host, such as an MCP tool you pass with --permission-prompt-toolbestätigt 10.11.2026
  • until the cleanupPeriodDays retention sweep deletes it, after 30 days by defaultbestä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

Alle Quellen

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