Claude Code release notes: 2.1.248–2.1.251 add restricted mode and model-switch hooks

Claude Code release notes: 2.1.248–2.1.251 add restricted mode and model-switch hooks

Claude Code 2.1.248 adds a restricted mode for evaluation harnesses on shared machines. Version 2.1.251 adds hooks that can block, confirm, or annotate a model switch. The npm registry lists 2.1.251 as the current version.

Sources: Claude Code 2.1.248. Claude Code 2.1.251.

Claude Code 2.1.248 starts in restricted mode

Restricted mode is a startup mode for evaluation environments where Claude Code must not run commands or read the machine's normal user and project settings.

With --restricted, Claude Code removes its built-in command and code execution tools plus WebFetch. A tool can still be allowed explicitly through --tools. File tools stay inside the working directories, bypassPermissions is refused, and cloud sessions cannot be created. The mode reads managed settings and an explicit --settings file, but not normal user, project, or local settings.

Human step: Update to 2.1.248 or later and start the controlled run with claude --restricted. For print mode, Anthropic documents claude --restricted -p "query".

Sources: Anthropic's CLI reference for --restricted. Claude Code 2.1.248 release notes.

Claude Code 2.1.251 can control model switches

A hook is a command or tool that Claude Code runs at a defined point in the session. PreModelSwitch runs before a model switch and can block it, ask for confirmation, or add a message. PostModelSwitch runs after the change and can add context for Claude's next request.

Hooks can distinguish a switch requested by the user, an automatic change, and a model restored when a session resumes. SessionStart now also receives the resumed session's staleness and the estimated prompt re-cache cost.

The same release shows prompt-cache hit ratio, misses, and re-cached tokens in /cost. Developers behind a Claude apps gateway with spend limits also get a spend bar in /usage.

Human step: Add PreModelSwitch or PostModelSwitch at the settings level that governs your Claude Code environment. Make an intentional model switch, then verify that the block, confirmation, or added context behaves as expected.

Sources: Anthropic's model-switch hook documentation. Claude Code 2.1.251 release notes.

Availability

--restricted requires Claude Code 2.1.248 or later. Model-switch hooks and the new cost fields require 2.1.251. npm and GitHub list 2.1.251 as the current release, published on August 28, 2026.

Sources: Current Claude Code version in the npm registry. Claude Code changelog.

FAQ

What does --restricted remove in Claude Code?

It removes the built-in command and code execution tools plus WebFetch unless they are explicitly allowed. File tools stay inside the working directories, and bypassPermissions is refused.

What do PreModelSwitch and PostModelSwitch do?

PreModelSwitch runs before a model change and can block it or require confirmation. PostModelSwitch runs after the change and can add context for the next request.

The Forge newsletter

Get new articles in your inbox

Pick the topics you care about. No noise, at most one email a week.

Get new articles in your inbox

We follow GDPR. Unsubscribe anytime.