{"version":"2.1.315","anchor":"powershell-hook-no-extra-exit-code-guard-for-bare-block-key","canonical_anchor":"powershell-hook-no-extra-exit-code-guard-for-bare-block-key","heading":"PowerShell hooks using script blocks get different exit code handling","tier":"notice","area":"Elsewhere","scope":"individual","heads_up":true,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.315\/e\/powershell-hook-no-extra-exit-code-guard-for-bare-block-key","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.315","markdown":"### PowerShell hooks using script blocks get different exit code handling\n\nWhether Claude Code adds its exit code 2 check to a PowerShell hook now depends on whether the script uses begin, process, end, clean or dynamicparam blocks\n\n**Unclear.** Whether scripts with these blocks now get the added exit code check or now skip it is not clear.\n\n**What**\n\nHooks are commands you set up for Claude Code to run at certain moments. A hook reports back through its exit code, the number a program returns when it finishes, and exit code 2 has a special meaning. For hooks written in PowerShell, Claude Code can add a short line to the end of the script so that, when the last command failed with code 2, the hook also exits with code 2.\n\nThe rule for when that line is added has changed. It now depends on whether the script contains begin, process, end, clean or dynamicparam blocks. The rule for `PermissionRequest` hooks is unchanged.\n\n**Why**\n\nPowerShell scripts that use these block keywords now have their exit codes handled differently. If you have such a hook, check that it still reports exit code 2 the way you expect.\n\n- Area: Elsewhere\n- Tier: You'll notice\n- Useful: 2\/5\n- Signal: 1\/5\n- Scope: individual\n- Heads-up: yes"}