The whole hunk
from line 934, old and new numbered
/
lines
This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.
from line 934
934934
935935Your hook's stdout must contain only the JSON object. If your shell profile prints text on startup, it can interfere with JSON parsing. See [Hook JSON has no effect](/docs/en/hooks-guide#hook-json-has-no-effect) in the troubleshooting guide.
936936
937Hook output strings, including `additionalContext`, `systemMessage`, and plain stdout, are capped at 10,000 characters. Output that exceeds this limit is saved to a file and replaced with a preview and file path, the same way a large valid Bash result is handled under [Output limits](/docs/en/tools-reference#output-limits).
937A hook's `additionalContext`, `systemMessage`, and `initialUserMessage` strings, and its plain stdout, are capped at 10,000 characters:
938938
939* **Scope**: Claude Code measures each string on its own, even when several hooks run for the same event. For JSON output, each field is measured separately; plain stdout is measured whole.
940* **Over the limit**: Claude Code saves the output to a file in the session directory and replaces it with the file path and a preview of up to the first 2,000 characters. A large valid Bash result is handled the same way, described under [Output limits](/docs/en/tools-reference#output-limits). Unlike that Bash ceiling, this cap has no setting or environment variable to raise it.
941* **Reading the file**: Claude Code doesn't ask Claude to read the file, so keep anything Claude must always see within the cap.
942
939943The JSON object supports three kinds of fields:
940944
941945* **Universal fields** like `continue` are listed in the table below. Every event accepts them, but some events discard them or deliver `systemMessage` somewhere other than the transcript. Each event's section says so. `terminalSequence` works on those events too, with the exceptions listed under [Emit terminal notifications](#emit-terminal-notifications).
from line 1020
10161020
10171021When several hooks return `additionalContext` for the same event, Claude receives all of the values.
10181022
1019If a value exceeds 10,000 characters, Claude Code writes the text to a file in the session directory and passes Claude the file path with a short preview instead.
1023If a value exceeds 10,000 characters, Claude Code writes the text to a file in the session directory and passes Claude the file path with a preview of up to the first 2,000 characters instead. Claude can read the file, but Claude Code doesn't ask it to.
10201024
10211025Use `additionalContext` for information Claude should know about the current state of your environment or the operation that just ran:
10221026
from line 2691
26872691TeammateIdle hooks support two ways to control teammate behavior:
26882692
26892693* **Exit code 2**: the teammate receives the stderr message as feedback and continues working instead of going idle.
2690* **JSON `{"continue": false, "stopReason": "..."}`**: stops the teammate entirely, matching `Stop` hook behavior. The `stopReason` is shown to the user.
2691
2692This example checks that a build artifact exists before allowing a teammate to go idle:
2693
2694```bash theme={null}
2695#!/bin/bash
2696
2697if [ ! -f "./dist/output.js" ]; then
2698 echo "Build artifact missing. Run the build before stopping." >&2
2699 exit 2
2700fi
2701
2702exit 0
2703```
2704
2705### ConfigChange
2706
2707Runs when a configuration file changes during a session. Use this to audit settings changes, enforce security policies, or block unauthorized modifications to configuration files.
2708
2709Claude Code runs ConfigChange hooks when a settings file, a managed policy file, or a skill file changes.
2694* **JSON `{"continue": false, "stopReason": "..."}`**: stops the teammate entirely, matching `Stop` hook beh