What
Hooks are your own scripts that Claude Code runs at set points. A hook that asks the model a question through $.model.complete can now pass promptBlocks and systemBlocks instead of a single plain text prompt and system message. Each block is { text } and can also include cache: true.
- Blocks marked
cache: trueare sent as cacheable blocks. Caching lets a repeated part of a prompt be reused instead of processed again. - If caching is disabled, Claude Code drops those cache markers.
- Badly shaped input is rejected with specific error messages.
Why
Hook authors who send the same long text again and again can use prompt caching.
Names in the bundlepromptBlockssystemBlocks
Documented inclaude-code/plugins/mods/api
The entry above is what we published on the day. These lines were added later, as Anthropic's own pages caught up, and they sit beside the original rather than replacing it.
Confirmed since
Anthropic's documentation has since written up systemBlocks, on Use the mods API.
* **`e.promptBlocks` and `e.systemBlocks`**: the caller's arrays, each present when the caller passed an array for that fieldplugins/mods/api see the edit
Confirmed since
Anthropic's documentation has since written up promptBlocks, on Use the mods API.
* **`e.promptBlocks` and `e.systemBlocks`**: the caller's arrays, each present when the caller passed an array for that fieldplugins/mods/api see the edit
Two sources agreeTwo things we can check say the same as this entry.
Anthropic's documentation agrees
Anthropic's documentation has since written up promptBlocks, on Use the mods API.
Anthropic's release notes agree
Added prompt caching to $.model.complete for mods: prompt and system take blocks of text, and cache: true on a block caches the request up…