writing-powershelllisted
Install: claude install-skill woznet/wozdev
# Writing PowerShell
Author PowerShell that is idiomatic, safe, and consistent with an approved style, then prove it with the bundled checker.
**Core rule:** `[CmdletBinding()]` functions, single-quoted `-f` strings, OTBS braces, `try/catch`, structured object output. Never `Write-Host`, `Out-Null`, backtick continuation, `New-Object`, aliases, doubled single quotes, or raw-string returns.
## Choosing a Template
Two scaffolds cover the common cases. Default to **quick**; promote to **full** only when a real need appears.
| Use **full** when… | Use **quick/helper** when… |
|---|---|
| Takes pipeline input | Small, single-purpose helper |
| Destructive/stateful action needing `-WhatIf`/`-Confirm` | No destructive side effects |
| Needs `begin`/`end` for shared setup or teardown | Thin wrapper over one or two calls |
| Public/exported module command | Internal helper |
A standalone `.ps1` script follows the same rules at file level: help block, `[CmdletBinding()]` and `param()` at the top, `#Requires` for modules it needs. See `references/patterns.md`.
## Quick Reference
| Topic | Do | Don't |
|-------|----|-------|
| Strings | `('{0} -> {1}' -f $a, $b)`, single quotes | `"$a -> $b"`, double-quote interpolation |
| Quotes inside strings | embed double quotes: `('name "{0}"' -f $A)` | doubled single quotes: `('name ''{0}''' -f $A)` |
| Discarding output | `$null = $List.Add($x)` or `[void]$List.Add($x)` | `$List.Add($x) \| Out-Null` |
| Functions | `[CmdletBinding()]` + t