windows shell safety - tfsugjp/skills GitHub Wiki
Add a standalone windows-shell-safety plugin that keeps agents from losing time on Windows when Azure CLI, JSON payloads, and pipelines pass through cmd.exe. The skill prescribes safe execution patterns, and a bundled pre-execution lint flags dangerous command shapes before they run.
| Type | Issue |
|---|---|
| Parent | Issue #84 |
| Sub-issue | Issue #85 |
| Sub-issue | Issue #86 |
| Sub-issue | Issue #87 |
| Sub-issue | Issue #88 |
-
azon Windows is the batch fileaz.cmd. Even when called from PowerShell 7,cmd.exere-parses its arguments and consumes|,&,<,>,^, and%VAR%, so JMESPath such as--query "[?x=='a'] | [0]"breaks. - PowerShell 7.3+ defaults to
$PSNativeCommandArgumentPassing = 'Windows', which keeps legacy argument passing for.cmd/.battargets, so double quotes inside inline JSON are dropped. - Nested invocations such as
powershell -Command "... | ..."from Git Bash orcmdlet the outer shell consume pipes and quotes first. - Mismatched
$OutputEncodingand[Console]::OutputEncodingturn non-ASCII pipeline data into?. - The existing Azure DevOps guidance covers only REST writes; this plan generalizes it.
- Prevention level: skill plus pre-execution lint. No PreToolUse hook, so false positives never block work.
- Placement: new plugin
plugins/windows-shell-safety/usable foraz,gh,dotnet, and other native tools. Azure DevOps skills link to it instead of duplicating guidance. - Skill rules: use
pwshonly; never embed JSON in arguments (UTF-8 file and@file); keepcmdmetacharacters and quotes out ofaz --queryand filter withConvertFrom-Json; set UTF-8 encodings before pipes; run scripts withpwsh -Fileinstead of-Commandstrings; lint before running; inspect received argv before retrying. -
Test-NativeCommand.ps1: AST-based lint with rules WSS001-WSS008 (cmd /c,-Commandstrings,cmdmetacharacters for.cmdtargets, inline JSON, escaped quotes, Windows PowerShell 5.1, missing UTF-8 setup, shell workarounds). Exit code 1 on findings,-AsJsonoutput. -
Invoke-NativeJson.ps1:Invoke-AzJsonsends bodies through a UTF-8 temporary file and returns parsed objects;-EchoArgsshows the argv a.cmdchild actually received.
- Lint script and unittest fixtures (#85).
- Safe execution helper (#86).
- Skill documentation, references, manifests, and repository docs (#87).
-
windows-latestCI job reproducing the argument loss and proving the safe patterns (#88).
-
python3 scripts/validate_marketplaces.pysucceeds. - The lint unittest passes locally with
pwshand in the existing Ubuntu CI job. - The
windows-latestCI job shows the broken forms fail and the recommended forms succeed withaz version, which needs no sign-in.