waseemnasir2k26

Claude Code Pwsh Guard — Development skill for Claude Code

Development community

Claude Code hook pack that stops the agent firing Bash-only syntax at a Windows PowerShell session.

How to install Claude Code Pwsh Guard

This entry records only its repository, not the path inside it, so there is no exact command to give. Open waseemnasir2k26/claude-code-pwsh-guard and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Code Pwsh Guard does

Claude Code hook pack that stops the agent firing Bash-only syntax at a Windows PowerShell session. Detects extglob, POSIX env refs, /dev/null, heredocs and more; auto-rewrites the safe ones and blocks the rest with the correct pwsh command so the agent self-corrects. Not affiliated with Anthropic.

Alternatives in Development

  • Check 1: Cache Exists? — CLAUDE_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}" CACHE_EXISTS=$(ls -d "$CLAUDE_DIR/plugins/cache/claude-hud" 2 10.9k ★
  • CORS — Scan an endpoint for CORS misconfiguration — arbitrary-origin reflection, null-origin trust, credential exposu 4.5k ★
  • n8n Expression Syntax — n8n expression syntax with {{}} and $json/$node variables 3.6k ★

README

claude-code-pwsh-guard

A Claude Code hook pack that catches bash-only shell syntax before it reaches a Windows PowerShell session, and either rewrites it to the PowerShell equivalent or blocks it with the correct command in the error message.

Claude                                                    pwsh-guard                          Result
──────────────────────────────────────────────────────────────────────────────────────────────────
Bash("shopt -s extglob;                       ─▶  PreToolUse: deny                   ✗ never runs
      rm -f !(keep.txt|keep2.txt)")               [ERROR] shopt / extglob is a bash builtin
                                                   PowerShell: Get-ChildItem -Exclude ... |
                                                               Remove-Item
                                                  [ERROR] extglob pattern !(...)

Bash("Get-ChildItem -Exclude                  ─▶  (silent)                            ✓ runs
      keep.txt,keep2.txt | Remove-Item")

Bash("export NODE_ENV=production;             ─▶  PreToolUse: allow + updatedInput    ✓ runs, fixed
      echo $PATH > /dev/null")                    $env:NODE_ENV = "production";
                                                  echo $env:PATH > $null

Without the guard, that first command produces `The term 'shopt' is not recognized`, Claude tries a variation of the same bash syntax, and the loop repeats. That loop is [issue #28670](https://github.com/anthropics/claude-code/issues/28670).

![hook events](https://img.shields.io/badge/hooks-PreToolUse%20%2B%20SessionStart-blue) ![rules](https://img.shields.io/badge/rules-19-blue) ![tests](https://img.shields.io/badge/tests-204%20passing-brightgreen) ![license](https://img.shields.io/badge/license-MIT-blue)

Quick start

  1. Clone this repo anywhere: git clone https://github.com//claude-code-pwsh-guard
  2. cd claude-code-pwsh-guard
  3. powershell -ExecutionPolicy Bypass -File .\install.ps1