{"version":1,"type":"story","url":"https://digestai.news/story/claude-code-v2-1-332-adds-hook-to-block-skill-shell-commands","json":"https://digestai.news/story/claude-code-v2-1-332-adds-hook-to-block-skill-shell-commands.json","markdown":"https://digestai.news/story/claude-code-v2-1-332-adds-hook-to-block-skill-shell-commands.md","slug":"claude-code-v2-1-332-adds-hook-to-block-skill-shell-commands","headline":"Claude Code v2.1.332 adds hook to block skill shell commands","summary":"Anthropic released Claude Code v2.1.332 on November 25, introducing a new `PreSkillShellCommand` hook to address security concerns in skill execution. The update allows developers to block shell commands prefixed with \"!\" that run automatically when a skill is loaded, a process that previously bypassed standard `PreToolUse` hooks. This change is significant because malicious or unintended commands in third-party skills could execute without user awareness if the skill author pre-approves them in the frontmatter.\n\nA technical blog team from Claude Code Laboratory conducted 47 local tests on macOS to verify the new hook's behavior. Their findings show that the new hook successfully blocked unauthorized commands in 7 out of 7 tests, whereas the older `PreToolUse` hook failed to stop them in all 5 tests where it was applied. The tests also revealed that if the new hook script crashes or times out, the command executes by default unless the configuration explicitly sets `onFailure: \"block\"`. Additionally, the new hook does not apply to commands executed later in \"auto mode,\" which still rely on `PreToolUse`.\n\nThe article advises users to update their configuration files to include the new hook and set the failure mode to block for maximum security. It also notes that hooks written within the skill's own frontmatter are not invoked, meaning the installing party must define the restrictions. For those who do not want any load-time command execution, the article suggests disabling the feature entirely via `disableSkillShellExecution`.","keyPoints":["Claude Code v2.1.332 introduces PreSkillShellCommand hook to block load-time shell commands.","Tests show PreToolUse hooks fail to stop skill loading commands, while the new hook succeeds.","Users must set onFailure to block to prevent command execution if the hook script crashes."],"whyItMatters":"This update closes a security gap where third-party skills could execute arbitrary shell commands upon loading, bypassing standard tool-use permissions. It provides a specific mechanism for developers to secure their AI coding environments against malicious or buggy skill definitions.","category":{"slug":"agents","name":"Agents & Tools","url":"https://digestai.news/category/agents"},"entities":{"companies":["Anthropic","Claude Code Laboratory"],"models":["Claude Code"],"people":[]},"firstPublishedAt":"2026-11-26T19:10:00Z","updatedAt":"2026-11-26T19:10:00Z","sourceCount":1,"hasPrimarySource":false,"sources":[{"outlet":"note.com","title":"Do Claude Code Skills Run Commands Just by Being Read? 47 Real Measurements of the New Hook","url":"https://note.com/claudecode_lab/n/nf71e3e78383d?hl=en","publishedAt":"2026-11-26T19:10:00Z","type":"press","primary":false,"lead":true}],"sourceNotes":null,"discussions":[],"thread":null,"cite":{"text":"Digest AI, \"Claude Code v2.1.332 adds hook to block skill shell commands\", 26 November 2026, https://digestai.news/story/claude-code-v2-1-332-adds-hook-to-block-skill-shell-commands","publisher":"Digest AI","title":"Claude Code v2.1.332 adds hook to block skill shell commands","datePublished":"2026-11-26T19:10:00Z","url":"https://digestai.news/story/claude-code-v2-1-332-adds-hook-to-block-skill-shell-commands"},"generatedBy":"Written by Digest AI's editorial model from the linked sources; the sources are the record.","license":"Headlines, digests and key points are written by Digest AI and may be quoted with a link to the story page. Linked articles belong to their publishers. Terms: https://digestai.news/terms#reuse"}