| name | powershell-module-scaffolder |
| description | Scaffold PowerShell modules with Pester tests. Use when the user requests a new PowerShell module or sample functions; keywords: powershell, psm1, psd1, pester, PSScriptAnalyzer, scaffold |
PowerShell Module Scaffolder Skill
Summary: Create a skeleton PowerShell module (.psm1/.psd1), sample function, and Pester test harness.
Usage:
- Inputs: module name, functions list
- Outputs: module folder,
README.md, tests/ with Pester examples
Requirements:
- PowerShell 7.x available for local development and CI
- Pester 5.x for unit tests (
Invoke-Pester)
PSScriptAnalyzer configured with a repository baseline (recommended)
Steps:
- Enforce approved verb-noun names and module layout (see verb-validation micro-procedure below).
- Add
PSScriptAnalyzer settings and sample Pester tests.
Example scaffold (expected output):
MyModule/
├── MyModule.psd1
├── MyModule.psm1
├── Public
│ └── Get-MyThing.ps1
├── README.md
├── tests
│ └── Get-MyThing.Tests.ps1
└── .vscode/ (optional dev settings)
Example function (Public/Get-MyThing.ps1):
function Get-MyThing {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$Name
)
process {
return @{ Name = $Name; Created = (Get-Date) }
}
}
Export-ModuleMember -Function Get-MyThing
Example Pester test (tests/Get-MyThing.Tests.ps1):
Describe 'Get-MyThing' {
It 'returns an object with Name and Created' {
$result = Get-MyThing -Name 'Test'
$result | Should -Not -BeNullOrEmpty
$result.Name | Should -Be 'Test'
}
}