← Back to news
Claude Code 2.1.332: Control Shell Execution Before Skills Load

Photo: Sebastiaan ter Burg / Wikimedia Commons — CC BY 2.0 (https://creativecommons.org/licenses/by/2.0/); original: https://commons.wikimedia.org/wiki/File:Wikimedia_Hackathon_2013_-_Flickr_-_Sebastiaan_ter_Burg_(4).jpg; header may be cropped/resized / cadrage et redimensionnement possibles.

27/11/2026

Claude Code 2.1.332: Control Shell Execution Before Skills Load

Claude Code 2.1.332: review what runs before a skill even starts

The interesting change in the current Claude Code changelog is not another way to generate code. Version 2.1.332 introduces PreSkillShellCommand, a hook for shell commands executed while a skill or slash command loads. It also adds beta support for skills supplied by MCP servers. Together, these changes make an overlooked engineering question more urgent: what code executes before the model has even begun following a reusable procedure?

For a senior engineer, the opportunity is practical. Reusable skills can collect repository context, standardize investigations, and prepare reviews without repeated prompting. But context collection is still execution. A command that reads repository metadata and a command that sends credentials somewhere both look like convenient automation until you examine their effects. This release provides a control point, not a replacement for that examination.

This guide reflects official documentation checked on 27 November 2026. It proposes workflows and acceptance tests; it does not claim a measured productivity benchmark or a live Claude Code deployment in our environment.

What the tool actually does

Claude Code is a coding agent used from a terminal and other supported development surfaces. It can inspect a repository, propose edits, run commands subject to its configuration, and help investigate failures. A skill packages instructions in a SKILL.md file, optionally with supporting scripts and reference material. Instead of pasting the same review checklist every morning, an engineer can invoke a named procedure.

The distinction between instructions and execution matters. A skill can contain dynamic context injection: shell expressions run as the skill loads, with their output inserted into its instructions. The documented inline form is an exclamation mark followed by a command inside backticks. This is useful for a branch summary or a recent diff. It also means opening a procedure can have operational effects before the agent makes an ordinary tool call.

MCP adds another distribution surface. In this release, server-provided skills appear as server:skill in the slash menu. That naming helps identify origin, but a recognizable name is not evidence that a server or procedure deserves access.

Install, authenticate, then check the actual version

Start with the official setup page linked in the sources. On macOS, Linux, and WSL, the documented native installer is curl -fsSL https://claude.ai/install.sh | bash. In a controlled engineering environment, download and inspect that installer before executing it, or use your organization’s approved distribution route. On Windows, the documentation provides PowerShell, CMD, and WinGet options. Homebrew is also supported.

After installation, open a new terminal and run claude --version, followed by claude doctor. The latter performs read-only installation and configuration diagnostics; it is not the same as asking an interactive diagnostic skill to fix your setup. Authenticate using an eligible Claude account or your organization’s supported API-provider configuration. The free claude.ai plan does not include Claude Code access.

For this feature, verify version 2.1.332 or later on every relevant surface, including desktop and editor integrations. A binary on your terminal PATH does not establish the version used by another client. Release channels and package-manager update behavior differ; follow the setup documentation rather than assuming installation implies current feature support.

The boundary that ordinary tool hooks do not cover

The official hook documentation is explicit: PreToolUse does not fire for injected commands. If your security policy only monitors ordinary Bash tool calls, do not infer that the same policy has inspected a shell expression embedded in a skill. PreSkillShellCommand exists to cover that separate execution point.

The new hook runs after the permission check for injected commands, so it sees commands that passed that check. It also runs in bypassPermissions mode. That does not make bypassing permissions a recommended operating mode; it explains where this hook remains applicable. In auto mode, a command requiring approval may instead be attempted later as a normal tool call. Keep the relevant policy on both events.

A useful mental model is two doors into execution. One opens when a skill gathers context; the other opens when the agent uses a shell tool. Securing one door does not secure the other, and neither control replaces operating-system permissions, network restrictions, or careful credential scoping.

Configure enforcement where it actually applies

Use a settings file or a plugin to define the new hook. For organizational enforcement, prefer centrally managed settings and protect the hook implementation from modification by the same agent it supervises. A project-level example is useful for a pilot, but editable repository policy is not a strong administrative boundary.

The documented matcher is Bash|PowerShell, covering both tools used for injected commands. Choose a synchronous command, HTTP, or MCP-tool hook when blocking is required. An asynchronous hook cannot block. Configure onFailure: "block" so an exception or timeout does not silently turn your intended gate into best-effort logging.

Do not put the only protection inside the skill’s own frontmatter. The documentation describes first-load, subagent, and forked-skill cases where those local hooks do not cover its injected commands. Upgrade clients before distributing the new event: version 2.1.331 and older do not enforce it and may show an unknown-event warning. Use the documented requiredMinimumVersion setting if your deployment needs a minimum-version requirement.

Design a narrow policy, not a shell-security illusion

The hook receives the command, tool name, skill name, source, and invocation origin. Those fields are useful for decisions and audit records. For example, a team can distinguish a developer-invoked project procedure from an automatically invoked server-provided procedure, then apply different review requirements. Treat names and source labels as context, not cryptographic proof of trustworthy behavior.

For a pilot, start with a small set of reviewed context collectors and deny unexpected execution. Keep those collectors simple: bounded output, explicit working directories, no credential reads, no network calls unless separately approved. A regular expression searching for a dangerous word is a demonstration, not a complete shell parser or a security sandbox. Quoting, interpreters, command substitution, wrappers, and indirect execution defeat simplistic assumptions.

Protect the approved scripts themselves. A policy that permits a familiar script path while an agent can rewrite that file only relocates the risk. Read-only policy storage and least-privilege execution matter more than a reassuring allowlist label.

Acceptance tests before a shared rollout

The official documentation offers a harmless test: create a test skill containing an injected echo command whose argument includes the literal text rm -rf. A demonstration blocking hook can refuse that text without deleting anything. The important outcome is that the command is not executed and the blocked-command notice appears. Do not present the documentation’s expected notice as your own observed test result.

  • Test one allowed collector and one denied collector on both execution events.
  • Test a missing policy script, a nonzero unexpected exit, and a timeout with failure blocking enabled.
  • Test user invocation, automatic invocation, and a subagent path where supported.
  • Verify behavior after restarting each supported client and after a version change.

Blocking an injected command normally still allows the skill to load, with a marker instead of that command’s output. Your procedure must explicitly stop or report missing prerequisites rather than inventing the missing context. If policy must stop the entire invocation, study the documented continue:false behavior and test that separately.

Use case one: repository orientation without oversharing

A repository-orientation skill can gather the current branch, tracked changes, a bounded directory map, and the project’s documented test entry points. Ask the agent to identify the request path, relevant modules, and uncertainty before proposing edits. Each architecture claim should point to an actual file or symbol, not a plausible convention.

The productivity gain is reduced rediscovery: the same context pack supports onboarding, review preparation, and interrupted work. Keep the pack small enough to read. Exclude secrets, generated assets, dependency directories, and unrelated customer material. Read-only shell behavior is not equivalent to data safety; even a command that only reads can disclose sensitive output to the model.

Make the human checkpoint explicit: approve the proposed files and validation plan before implementation. If the collector cannot run, the agent should identify what it could not establish and ask for permitted evidence. It should not reconstruct a fictional repository map from project naming alone.

Use case two: pull-request preparation with a stable evidence pack

Build a review-preparation skill around a bounded diff, the intended behavior, relevant tests, and a list of touched interfaces. Ask it to separate confirmed defects, credible risks, and questions. A useful prompt is: identify behavior changes, cite the changed lines, propose the smallest discriminating test, and do not approve or merge the pull request.

Dynamic context can save repetitive copying, but fetching a remote pull request is still a network action. Keep credentials restricted to the repository and operation you need. A local diff collector and an authenticated remote collector deserve different policy decisions. Server-provided skills should undergo the same review as local scripts, especially when their content can change independently.

The engineer owns the judgment: which findings are real, which trade-offs are acceptable, and whether the evidence is enough. Track findings that survive human review rather than counting the length of generated commentary. More comments are not automatically better review.

Use case three: failure triage that preserves the original evidence

For a failing build, collect the exact command, exit status, relevant log excerpt, runtime versions, and commit identifier. Have the agent formulate competing hypotheses before editing. A debugging skill should preserve the original failure artifact and distinguish a reproduced failure from a suspected one. It should never rewrite the test merely to make the symptom disappear.

Use the hook to constrain collection, then let the ordinary tool policy control any reproducer or test execution. Running tests is not intrinsically harmless: fixtures, installation steps, and integration tests can start services or contact shared systems. Prefer a disposable workspace with explicitly scoped dependencies.

The handoff should be a short causal argument: what failed, what changed, which test distinguishes the diagnosis, and what remains unverified. This can reduce the cost of reconstructing an investigation after interruptions. The claim is an engineering mechanism, not a promise that every failure becomes faster or that the agent’s first explanation is correct.

Use case four: repeatable migrations, one slice at a time

A migration skill can inventory deprecated API calls, classify usage patterns, and propose the first low-risk slice. Keep inventory separate from modification. Start with representative cases, define compatibility expectations, then approve one implementation batch with its tests. Do not let a context-loading command perform the migration itself.

For example, ask for an inventory of callers, a proposed replacement contract, and a regression test for each distinct behavior. The human approves sequencing and public-interface changes. The agent handles repetitive edits only after that decision. A small batch makes an incorrect assumption cheaper to detect and undo than a repository-wide transformation.

Productivity comes from reusing the inventory and checklist while preserving reviewability. Require a complete diff review, a known base commit, and fresh validation against the integrated result. A successful test run from another branch or an earlier state is not evidence for the final merge candidate. Release approval remains outside the skill’s authority.

MCP skills: useful distribution, additional review responsibility

The new server:skill menu convention makes discovery easier, but beta availability is not an enterprise readiness guarantee. Inventory which servers can supply procedures, who administers them, and how updates are reviewed. Check what runs locally, what executes remotely, and what information crosses that boundary. A local shell hook is not a universal monitor for a remote server’s implementation.

Start with one trusted server and a non-sensitive repository. Record the server configuration, client version, and the reviewed procedure or an available version identifier. Recheck behavior when the server or client changes. If the beta is unavailable in your environment, retain reviewed local skills instead of making your workflow depend on an assumed menu entry.

Keep the policy independent of convenience. A skill being discoverable, automatically relevant, or apparently read-only should not grant new access. The developer should be able to explain why each connection and command is necessary before turning it into a shared default.

Reliability fixes matter to daily engineering

The same release lists fixes for hangs involving hook output, local MCP standard output, permission matching, and interrupted SSE MCP connections. It also corrects a login path that could report success when credentials were not saved. These are not glamorous features, but blocked terminals and misleading success messages consume real engineering attention.

Read those entries as vendor-reported fixes, not proof that every related failure has disappeared. During a pilot, include your actual proxy, shell, MCP servers, and editor integration. A workflow that works on a clean laptop may fail behind a corporate gateway or with large logs. Bound output and preserve useful diagnostics without recording secrets.

Also inspect the release’s model-routing and default changes before upgrading a team. Model aliases, cloud deployments, and regional settings can affect reproducibility, availability, and cost. Approving one hook feature is not approval of every unrelated behavior change bundled in the release.

Measure saved work, not generated activity

Choose comparable tasks before introducing the skill, then record context-preparation time, time to a verified result, human review effort, reruns, and accepted defects found. Include the maintenance cost of the policy and collectors. A procedure that saves typing but creates repeated false blocks may be a net loss.

Keep the experiment modest: one team, a small procedure set, and an agreed rollback point. Compare against the team’s own baseline rather than a vendor headline. Record model and client versions so a later upgrade does not silently change the experiment. Do not infer a universal percentage gain from a few favorable examples.

The strongest result is not an agent that asks fewer questions at any cost. It is a team that spends less time assembling evidence and more time making good technical decisions, with no increase in escaped defects, credential exposure, or ambiguous release authority.

A practical adoption checklist

  • Verify version 2.1.332 or later on every client that must enforce the new event.
  • Review each skill’s injected commands and any externally supplied procedure.
  • Apply synchronous blocking policy to PreSkillShellCommand and ordinary shell tool use.
  • Use Bash|PowerShell, protect policy files, and configure failure blocking.
  • Test denial, timeout, missing context, and client-version mismatch before sharing.
  • Keep secrets, production credentials, merge authority, and deployment approval outside the skill’s reach.
  • Measure verified engineering outcomes and retain an easy rollback.

The lesson is straightforward: reusable AI workflows are executable engineering assets. Review them like code, constrain them like tools, and validate their results like any other change. Claude Code’s new hook is valuable because it makes one more execution boundary visible. The productivity win comes from combining that visibility with deliberate human control, not from treating a newly named control as permission to delegate everything.

The illustration shows a Wikimedia development gathering in 2013. It is contextual, not a screenshot of Claude Code or evidence of product use by the people pictured. Attribution, the original file page, and the image license are supplied with the article.