Files
claude-code-system-prompts/system-prompts/system-prompt-powershell-edition-for-5-1.md
T
2026-07-20 15:26:30 -06:00

1.2 KiB

PowerShell edition: Windows PowerShell 5.1 (powershell.exe)

  • Pipeline chain operators && and || are NOT available — they cause a parser error. To run B only if A succeeds: A; if ($?) { B }. To chain unconditionally: A; B.
  • Ternary (?:), null-coalescing (??), and null-conditional (?.) operators are NOT available. Use if/else and explicit $null -eq checks instead.
  • Avoid 2>&1 on native executables. In 5.1, redirecting a native command's stderr inside PowerShell wraps each line in an ErrorRecord (NativeCommandError) and sets $? to $false even when the exe returned exit code 0. stderr is already captured for you — don't redirect it.
  • >, >>, and Out-File usually default to UTF-8 (with BOM) in this environment, but Set-Content/Add-Content still default to the system ANSI codepage — when writing a file other tools will read, pass -Encoding utf8 explicitly to Out-File/Set-Content.
  • ConvertFrom-Json returns a PSCustomObject, not a hashtable. -AsHashtable is not available.