Source Intelligence

DisclaimerUnofficial, and not affiliated with Anthropic. Nearly all of this is read straight out of what ships: npm bundles, captured prompts, published docs. Anthropic's own notes go in verbatim, marked as theirs. The rest is my reading, and every entry carries the strings behind it. If one looks wrong, vote it down and say why.

All of v2.1.251 Home All releases olderv2.1.250
Claude Code v2.1.251

New PreModelSwitch and PostModelSwitch hooks

Use it now
Useful5 Signal4
Hooks Notable

New PreModelSwitch and PostModelSwitch hooks let you gate or annotate every model change.

PreModelSwitchPostModelSwitchpermissionDecisionadditionalContext
What

Two hook events now fire around model changes. PreModelSwitch runs before a switch from /model, the model picker, the SDK or a resume, and can allow, deny or ask via permissionDecision (or block with exit code 2); deny cancels the switch and ask prompts for confirmation, except in headless sessions where it refuses. PostModelSwitch runs after the model changes and can inject additionalContext that reaches the model on the next request.

Details
  • Registered in the hook schema, the /hooks help text and the plugin hook-name validator, with their own dispatch and timeout handling.
  • Switch telemetry reports from_model, to_model, requested_model, whether the prompt cache is still warm, cache_ttl, an estimated_cache_write_usd re-caching estimate, and a source field distinguishing command, picker, sdk, auto and resume switches.
Evidence

hookEventName: N("PreModelSwitch"), PreModelSwitch, `PreModelSwitch: [],

PostModelSwitch: [],, PreModelSwitch: fdt`

Strings lifted out of the shipped bundle, so the claim above can be checked against them.

See this entry in the whole of v2.1.251 →