开发与测试
powershell-new-module
Create a new PowerShell module with a manifest, a root module, Public and Private folders, a first function, and Pester tests, following this repository's PowerShell standards. Use when asked to create, scaffold, or start a PowerShell module.
fadwen · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add fadwen/ai-powershell-standards --skill powershell-new-module技能说明
name: powershell-new-module description: Create a new PowerShell module with a manifest, a root module, Public and Private folders, a first function, and Pester tests, following this repository's PowerShell standards. Use when asked to create, scaffold, or start a PowerShell module.
Create a new PowerShell module
Read these before writing files, unless they are already loaded:
.github/copilot-instructions.md, orAGENTS.mdif the repository has no such file (the core rules and the function template).github/instructions/powershell-modules.instructions.md.github/instructions/powershell-version.instructions.md
Steps
- Ask for, or confirm, the module name, what it is for, and whether it must run on Windows PowerShell 5.1. Without a 5.1 requirement, target PowerShell 7.6.
- Create the layout from the module rules:
ModuleName.psd1,ModuleName.psm1,Public/,Private/, andTests/, with the unit tests underTests/Unit/(MOD-01). AddTests/Integration/andTests/Performance/when the module has such tests, andClasses/only if the module defines a class. Do not create empty folders for things the module does not have. - Write the manifest with literal values only. Generate the GUID once with
New-Guidand paste the result. SetPowerShellVersionandCompatiblePSEditionsfor the target. List exported functions by name. TakeAuthor,CompanyName, and the copyright holder from.github/powershell-attribution.mdwhen the project has one (DOC-18), and the project links from the user or the repository; leave out what you do not know. - Write the root module exactly as the module rules show it: a
#Requires -Versionline that matches the manifest'sPowerShellVersion(MOD-08), strict mode, thenClasses,Private, andPublicdot-sourced in that order, failing the import if a file fails to load. - Add the first function with the
powershell-new-functionskill, or follow its steps. - Import the module in a new session with
Import-Module ./ModuleName.psd1 -Force, confirm thatGet-Command -Module ModuleNamelists exactly the exported functions, and run the tests. - Add a
README.mdthat follows.github/instructions/powershell-readme.instructions.md.
Report
List the files you created, the target version, and the results of the import check and the tests. Do
not add dependencies or CI workflows unless the user asked for them; mention them as possible next
steps instead. Every module generates its command help with PlatyPS (PLT-10): do that with the
powershell-module-help skill, or say that it is still to do.