powershell-guidelines
Skill3 starsChanged 8 days agoMITView on GitHub
Apply PowerShell 7 policy as a conditional overlay when writing or reviewing PowerShell scripts, modules, and manifests: pwsh, PSScriptAnalyzer, strict mode, approved verbs, and cross-platform scripting. Code that must stay compatible with Windows PowerShell 5.1 gets no overlay from this policy, which also does not authorize upgrading it.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- analyze-projectSkill
- api-contract-strategySkill
- architecture-patternsSkill
- close-changeSkill
- design-changeSkill
- development-standardsSkill
- docker-multiarch-buildSkill
- error-patternsSkill
- go-guidelinesSkill
- herdr-implementSkill
- implement-changeSkill
- logging-standardsSkill
- lua-guidelinesSkill
- organize-docsSkill
- output-stylesSkill
- plan-changeSkill
- python-guidelinesSkill
- review-changeSkill
- review-designSkill
- review-implementationSkill
- review-planSkill
- routeros-scripting-guidelinesSkill
- runtime-diagnosisSkill
- security-guardrailsSkill
- shell-guidelinesSkill
- skill-authoringSkill
- skill-minerSkill
- skills-routingSkill
- smart-commitSkill
- sops-age-guardrailsSkill
- sync-truthSkill
- testing-strategySkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 0 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Read-only review checks: references/review-checklist.md
- Very specific: line 21
Start every script with #Requires -Version 7.0, adding #Requires -Modules for external module dependencies.
- Very specific: line 22
Follow it with Set-StrictMode -Version Latest and $ErrorActionPreference = 'Stop'.
- Very specific: line 27
Use PascalCase for functions, parameters and script-scoped variables, and $camelCase for locals.
- Very specific: line 29
Write full cmdlet names in scripts (Get-ChildItem, not ls).
- Very specific: line 39
Use [CmdletBinding()] for advanced functions and [Parameter(Mandatory)] for required inputs.
- Very specific: line 46
Use $PSCmdlet.ThrowTerminatingError() in advanced functions.
- Very specific: line 47
Check $LASTEXITCODE after every native command.
- Very specific: line 52
Run the parser check and Invoke-ScriptAnalyzer (Warning and Error severity) from references/operational-checks.md.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PowerShell Guidelines
Apply PowerShell 7 standards for safe, portable, auditable automation to .ps1, .psm1 and .psd1 files, including scripts authored on macOS for Windows execution, and to their review and syntax audit. Language selection reads references/language-selection.md in skills-routing; ad hoc tool choice reads references/tool-selection.md there.
Progressive Disclosure
- Parser, analyzer and approved-verb commands:
references/operational-checks.md - Authoring on macOS for Windows execution, or a case-sensitivity, line-ending or native-command portability question:
references/macos-notes.md - Writing an advanced function with error records, or checking a native command's exit code:
references/error-handling-examples.md - Read-only review checks:
references/review-checklist.md
Rules
Script Header
- Start every script with
#Requires -Version 7.0, adding#Requires -Modulesfor external module dependencies. - Follow it with
Set-StrictMode -Version Latestand$ErrorActionPreference = 'Stop'. Use'SilentlyContinue'only inside a documented exception-handling block.
Naming
- Name functions
Verb-Nounwith an approved verb (Get-Verblists them). - Use PascalCase for functions, parameters and script-scoped variables, and
$camelCasefor locals. - Name script files in PascalCase:
Get-UserReport.ps1. - Write full cmdlet names in scripts (
Get-ChildItem, notls). - Pass data through parameters and return values.
Paths
- Build every path with
Join-Pathand$PSScriptRoot, and guard any platform-specific literal (such asC:\...) with a platform check. - A single
[System.IO.Path]::Combine()call may join three or more trusted literal segments in one expression, when no later segment is rooted (a rooted segment discards the earlier path).
Inputs And Security
- Use
[CmdletBinding()]for advanced functions and[Parameter(Mandatory)]for required inputs. Choose parameter types and validation attributes ([ValidateSet()],[ValidatePattern()],[ValidateRange()]) for the actual input constraints, and reject unexpected values early. - Pass untrusted input as parameters or typed values.
- Supply secrets, credentials and API keys through the environment or a secret mechanism, and accept passwords as
[SecureString]or credential objects.
Errors
- Let failures propagate to the owning boundary. Add
try/catchwhere recovery or context is needed, andfinallywhere cleanup must run on success and failure. Include the operation attempted and relevant values in error messages. - Use
$PSCmdlet.ThrowTerminatingError()in advanced functions. - Check
$LASTEXITCODEafter every native command. - For generic error-handling patterns, see
error-patterns.
Checks
Run the parser check and Invoke-ScriptAnalyzer (Warning and Error severity) from references/operational-checks.md; the parser check exits non-zero when Parser::ParseFile reports diagnostics. Test scripts with pwsh on macOS before deploying to Windows.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

