agentleFS
nainishshafinainishshafi/developer-productivity-skills/.github/skills/powershell-writer/SKILL.md

powershell-writer

Skill1 starsChanged 4 days agoMITView on GitHub

Writes idiomatic, high-performance, and secure PowerShell scripts, modules, and automation workflows (PowerShell 7.4+ LTS & Windows PowerShell 5.1). Covers advanced functions ([CmdletBinding]), approved verbs, object pipeline streaming, error handling with Set-StrictMode, Pester v5 testing, PSScriptAnalyzer rules, and parallel concurrency. Use when asked to "write powershell", "powershell script", "create powershell module", "powershell-writer", "ps1 script", "pester test", or "powershell automation".

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 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.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prefer simple .ps1 scripts for linear orchestration (< 150 lines).

    line 27
  2. Very specific:

    Never use Invoke-Expression (iex).

    line 29
  3. Very specific:

    Always validate manifests using Test-ModuleManifest before shipping.

    line 30

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PowerShell Writer

Staff-level guidance for authoring production-grade PowerShell scripts, advanced functions, and enterprise modules across cross-platform environments (Windows, Linux, macOS).


When to Use This Skill

  • Writing standalone automation scripts (.ps1) or reusable modules (.psm1 / .psd1).
  • Implementing advanced cmdlets with [CmdletBinding()], parameter validation, and pipeline streaming (begin/process/end).
  • Enforcing defensive error handling with $ErrorActionPreference = 'Stop', try/catch, and Set-StrictMode.
  • Eliminating performance bottlenecks like the $O(N^2)$ array append antipattern ($arr += $item).
  • Multi-threading and background tasks using ForEach-Object -Parallel, Start-ThreadJob, or Runspaces.
  • Authoring unit tests with Pester v5 and linting with PSScriptAnalyzer.

Architectural Philosophy: Guidance Over Dogmatism

PowerShell is an object-oriented shell and automation engine. Heuristics guide design:

  • Prefer simple .ps1 scripts for linear orchestration (< 150 lines); use Modules (.psm1) when distributing 5+ reusable cmdlets.
  • Emit structured [PSCustomObject] rather than raw strings or bloated custom C# class hierarchies.
  • Never use Invoke-Expression (iex); pass arrays or use the call operator (&).
  • Always validate manifests using Test-ModuleManifest before shipping.

Core Knowledge Modules

Load the relevant module based on your task:

DomainDescriptionModule File
Core & Cmdlet Design[CmdletBinding()], approved verbs, pipeline binding, parameter validationCmdlet Design
Error Handling$ErrorActionPreference = 'Stop', Set-StrictMode, try/catch, $LASTEXITCODEError Handling
Anti-Bloat & PragmatismDecision matrix, over-engineering self-checks, avoiding $O(N^2)$ array trapsAnti-Bloat Guidelines
Pipeline & SplattingStreaming, [PSCustomObject], calculated properties, hashtable splatting (@params)Pipeline & Objects
Data & REST APIsInvoke-RestMethod, JSON depth limits, CSV/XML, native CLI argument quotingData & REST APIs
Concurrency & JobsForEach-Object -Parallel, thread-safe collections, Start-ThreadJob, RunspacesConcurrency & Parallelism
Module ArchitectureProfessional directory layout, .psm1, .psd1 manifests, Export-ModuleMemberModule Architecture
Security & Hardeningiex ban, SecureString, SecretManagement, ExecutionPolicy, CLMSecurity & Hardening
Testing & QualityPester v5 test patterns (Discovery vs Run), mocks, PSScriptAnalyzer rulesTesting with Pester v5

References

  • PowerShell Writer Reference Guide — Comprehensive architectural and operational reference.
  • Code Reviewer — Multi-language senior code review skill.
  • API Security — Universal API security and authentication audit.
  • Detect Overengineering — Anti-bloat heuristics and YAGNI auditing.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.