Powershell maintainer
Skill dfinke/powershell-ai-skills/skills/powershell-maintainer
Help write, review, refactor, and maintain PowerShell scripts, functions, and modules with practical PowerShell 7+ and Windows PowerShell 5.1 awareness. Use for idiomatic cmdlet design, advanced functions, pipeline/object output, parameter validation, error handling, paths and encoding, secure credential handling, native command interop, PSScriptAnalyzer/Pester validation, and cross-platform maintainability.From its SKILL.md
npx -y skills add dfinke/powershell-ai-skills --skill powershell-maintainerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.1 KB, 865 tokens by cl100k_base, as published. Nobody here has run it
PowerShell Maintainer
Use this skill for general PowerShell coding and maintenance. Prefer the target repository's conventions when they are clear.
Workflow
-
Orient to the project.
- Check target PowerShell versions, supported operating systems, CI matrix, module manifest, dependencies, and existing style.
- Prefer
pwshfor PowerShell 7+ work; use Windows PowerShell 5.1 only when legacy modules or host constraints require it. - Inspect existing functions before introducing new naming, layout, or helper patterns.
-
Write maintainable functions and scripts.
- Use approved
Verb-Nounnames for public functions. - Use
[CmdletBinding()]for reusable functions and advanced scripts. - Add
SupportsShouldProcessfor state-changing operations and honor$PSCmdlet.ShouldProcess(). - Use parameter validation attributes for important inputs.
- Emit objects for data; reserve
Write-Hostfor user-facing console decoration. - Use full cmdlet names in committed code, not aliases.
- Use approved
-
Handle errors deliberately.
- Use
-ErrorAction Stopor a scoped$ErrorActionPreference = 'Stop'whentry/catchmust handle cmdlet failures. - Never leave
catchblocks empty. - Capture
$_early in acatchblock if the error will be reused. - Check
$LASTEXITCODEafter native executables when the exit code matters.
- Use
-
Keep code portable unless the task is Windows-only.
- Use
Join-Path,$PSScriptRoot, and platform checks such as$IsWindows,$IsLinux, and$IsMacOS. - Specify encoding when writing files that will be read across platforms; prefer UTF-8 without BOM in PowerShell 7+, and account for Windows PowerShell 5.1's different encoding behavior.
- Avoid hard-coded drive letters, path separators, and interactive assumptions.
- Mark Windows-only code clearly instead of pretending it is cross-platform.
- Use
-
Protect users and systems.
- Do not hard-code secrets or write credentials to logs.
- Prefer
PSCredential, SecretManagement, managed identity, environment-specific auth, or an existing repo pattern. - Avoid
Invoke-Expressionfor constructed or untrusted input. - Use
-WhatIf,-Confirm, dry-run modes, or explicit guards for destructive operations.
-
Validate before finishing.
- Run the repository's existing checks first.
- Use
Invoke-ScriptAnalyzerwhen available. - Use
Invoke-Pesterfor tests that exist or that you add. - For changes touching external systems, verify with mocks, dry runs, or a documented manual step.
Common Checks
Discover the runtime:
$PSVersionTable
Get-Module -ListAvailable
Find commands and help:
Get-Command -Name Get-ChildItem
Get-Help Get-ChildItem -Full
Get-Verb
Inspect objects:
$result | Get-Member
$result | Select-Object -First 1 *
Run validation:
Invoke-ScriptAnalyzer -Path ./src -Recurse
Invoke-Pester
Gotchas
- Parenthesize command calls inside logical expressions:
if ((Test-Path $a) -or (Test-Path $b)). - Use
ConvertTo-Json -Depthfor nested objects. - Avoid
Format-*in the middle of pipelines; format at the display boundary. - Avoid
+=in large loops; collect pipeline orforeachoutput directly. - Treat
Write-Output,Write-Verbose,Write-Warning,Write-Error, andWrite-Informationas different streams with different purposes. - Account for Constrained Language Mode or locked-down hosts when the target environment may enforce AppLocker or WDAC.
Examples
examples/advanced-function.ps1: an advanced function with validation, pipeline input, andShouldProcess.examples/script-skeleton.ps1: a script layout with help, parameters, strict mode, and error handling.
What ships with it: 2 files
1.2 KB alongside SKILL.md, 2 of them executable
examples/
- advanced-function.ps1runs461 B
- script-skeleton.ps1runs791 B