@@ -13,7 +13,7 @@ This document provides guidance for AI coding agents (like GitHub Copilot, Curso
1313
1414## Project Structure
1515
16- ```
16+ ``` plaintext
1717PSScriptModule.Template/
1818├── src/ # Source code
1919│ ├── PSScriptModule.psd1 # Module manifest
@@ -31,26 +31,30 @@ PSScriptModule.Template/
3131## Key Conventions
3232
3333### File Naming
34+
3435- Public functions: ` Verb-Noun.ps1 ` in ` src/Public/ `
3536- Private functions: ` VerbNoun.ps1 ` in ` src/Private/ `
3637- Test files: ` *.Tests.ps1 ` alongside source files
3738- Help files: ` Verb-Noun.md ` in ` docs/help/ `
3839
3940### Function Structure
41+
4042- Use approved PowerShell verbs (Get, Set, New, Remove, etc.)
4143- Include ` [CmdletBinding()] ` attribute
4244- Add comprehensive comment-based help
4345- Use parameter validation attributes
4446- Follow begin/process/end blocks when appropriate
4547
4648### Testing Requirements
49+
4750- Every function must have corresponding ` .Tests.ps1 ` file
4851- Use Pester framework (v5+)
4952- Organize tests with Describe/Context/It blocks
5053- Test both success and failure scenarios
5154- Mock external dependencies
5255
5356### Code Quality
57+
5458- Must pass PSScriptAnalyzer with default rules
5559- Follow PSScriptAnalyzerSettings.psd1 configuration
5660- Check for security issues (injection attacks, etc.)
@@ -77,7 +81,8 @@ Invoke-Build Invoke-Pester # Run Pester tests
7781 - Public functions → ` src/Public/Verb-Noun.ps1 `
7882 - Private functions → ` src/Private/VerbNoun.ps1 `
7983
80- 2 . ** Function Template** :
84+ 1 . ** Function Template** :
85+
8186 ``` powershell
8287 function Verb-Noun {
8388 <#
@@ -128,7 +133,8 @@ Invoke-Build Invoke-Pester # Run Pester tests
128133 }
129134 ```
130135
131- 3 . ** Create Test File** :
136+ 1 . ** Create Test File** :
137+
132138 ``` powershell
133139 BeforeAll {
134140 # Import the function
@@ -154,10 +160,10 @@ Invoke-Build Invoke-Pester # Run Pester tests
154160### When Modifying Existing Code
155161
1561621 . ** Verify Tests** : Ensure existing tests still pass
157- 2 . ** Update Tests** : Add new tests for new functionality
158- 3 . ** Update Help** : Regenerate markdown help if function signature changes
159- 4 . ** Check Analysis** : Run PSScriptAnalyzer to verify compliance
160- 5 . ** Semantic Versioning** : Include appropriate ` +semver: ` keyword in commits
163+ 1 . ** Update Tests** : Add new tests for new functionality
164+ 1 . ** Update Help** : Regenerate markdown help if function signature changes
165+ 1 . ** Check Analysis** : Run PSScriptAnalyzer to verify compliance
166+ 1 . ** Semantic Versioning** : Include appropriate ` +semver: ` keyword in commits
161167
162168### Code Quality Checklist
163169
@@ -177,6 +183,7 @@ Before completing any code changes, verify:
177183### Common Patterns
178184
179185** Error Handling** :
186+
180187``` powershell
181188try {
182189 # Operation
@@ -188,11 +195,13 @@ catch {
188195```
189196
190197** Verbose Output** :
198+
191199``` powershell
192200Write-Verbose "Performing action on $Target"
193201```
194202
195203** Parameter Validation** :
204+
196205``` powershell
197206[Parameter(Mandatory)]
198207[ValidateNotNullOrEmpty()]
@@ -202,6 +211,7 @@ $Path
202211```
203212
204213** Should Process (for destructive operations)** :
214+
205215``` powershell
206216[CmdletBinding(SupportsShouldProcess)]
207217param()
@@ -214,11 +224,13 @@ if ($PSCmdlet.ShouldProcess($Target, "Operation")) {
214224### Dependencies
215225
216226Install required modules via PSDepend:
227+
217228``` powershell
218229Invoke-PSDepend -Path ./requirements.psd1 -Install -Import -Force
219230```
220231
221232Key dependencies:
233+
222234- ** InvokeBuild** : Build orchestration
223235- ** Pester** : Testing framework
224236- ** PSScriptAnalyzer** : Static code analysis
@@ -229,10 +241,10 @@ Key dependencies:
229241- Uses GitVersion with GitHub Flow
230242- Every PR merge to ` main ` creates a new release
231243- Control version bumps with commit message keywords:
232- - ` +semver: major ` - Breaking changes (1.0.0 → 2.0.0)
233- - ` +semver: minor ` - New features (1.0.0 → 1.1.0)
234- - ` +semver: patch ` - Bug fixes (1.0.0 → 1.0.1)
235- - ` +semver: none ` - No version change
244+ - ` +semver: major ` - Breaking changes (1.0.0 → 2.0.0)
245+ - ` +semver: minor ` - New features (1.0.0 → 1.1.0)
246+ - ` +semver: patch ` - Bug fixes (1.0.0 → 1.0.1)
247+ - ` +semver: none ` - No version change
236248
237249### Testing Commands
238250
@@ -258,15 +270,15 @@ Invoke-ScriptAnalyzer -Path ./src -Recurse
258270## Best Practices for AI Agents
259271
2602721 . ** Always run tests** after making changes
261- 2 . ** Follow existing patterns** in the codebase
262- 3 . ** Don't remove or modify** PSScriptAnalyzer suppressions without understanding them
263- 4 . ** Update documentation** when changing function signatures
264- 5 . ** Use approved verbs** from ` Get-Verb ` output
265- 6 . ** Avoid aliases** in production code (use full cmdlet names)
266- 7 . ** Include examples** in help documentation
267- 8 . ** Handle errors explicitly** with try/catch blocks
268- 9 . ** Add verbose output** for debugging
269- 10 . ** Test edge cases** including null/empty inputs
273+ 1 . ** Follow existing patterns** in the codebase
274+ 1 . ** Don't remove or modify** PSScriptAnalyzer suppressions without understanding them
275+ 1 . ** Update documentation** when changing function signatures
276+ 1 . ** Use approved verbs** from ` Get-Verb ` output
277+ 1 . ** Avoid aliases** in production code (use full cmdlet names)
278+ 1 . ** Include examples** in help documentation
279+ 1 . ** Handle errors explicitly** with try/catch blocks
280+ 1 . ** Add verbose output** for debugging
281+ 1 . ** Test edge cases** including null/empty inputs
270282
271283## Resources
272284
@@ -279,6 +291,7 @@ Invoke-ScriptAnalyzer -Path ./src -Recurse
279291## Quick Reference
280292
281293### File Operations
294+
282295``` powershell
283296# Create new public function
284297New-Item -Path ./src/Public/Get-Something.ps1 -ItemType File
@@ -288,6 +301,7 @@ New-Item -Path ./src/Public/Get-Something.Tests.ps1 -ItemType File
288301```
289302
290303### Build Operations
304+
291305``` powershell
292306# Clean build
293307Invoke-Build Clean
@@ -303,6 +317,7 @@ Invoke-Build -ReleaseType Release
303317```
304318
305319### Module Operations
320+
306321``` powershell
307322# Import module for testing
308323Import-Module ./src/PSScriptModule.psd1 -Force
0 commit comments