SdnDiagnostics
Copilot instructions35 starsChanged 5 years agoMITView on GitHub
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
26 rules. About 0 are common, 12 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Follow PowerShell best practices and the PowerShell Practice and Style Guide
- Distinctive: line 10
Use approved verbs for function names (Get-, Set-, New-, Remove-, etc.)
- Distinctive: line 11
Use PascalCase for function names and parameters
- Distinctive: line 12
Use camelCase for local variables
- Very specific: line 16
Always include [CmdletBinding()] attribute for advanced functions
- Distinctive: line 17
Use parameter sets when functions have mutually exclusive parameters
- Very specific: line 19
Use ShouldProcess pattern for functions that make changes (with -Confirm and -WhatIf support)
- Distinctive: line 20
Always include proper error handling with try/catch blocks
- Very specific: line 23
Use Trace-Output for logging instead of Write-Host or Write-Verbose
- Very specific: line 25
Always include both Trace-Exception and Write-Error in catch blocks
- Distinctive: line 40
Use Trace-Output function for all logging with appropriate -Level parameter
- Distinctive: line 49
Place role-specific functions in appropriate module files:
- Very specific: line 58
Use New-PSRemotingSession for creating remote sessions
- Very specific: line 59
Use Invoke-PSRemoteCommand for executing commands remotely.
- Very specific: line 60
Always pass $Credential parameter for remote operations
- Very specific: line 63
Use Invoke-RestMethodWithRetry or Invoke-WebRequestWithRetry for Network Controller REST API calls
- Very specific: line 65
Always include parameter sets for RestCertificate and RestCredential
- Very specific: line 66
Use @ncRestParams splatting pattern for REST parameters
- Very specific: line 69
Use Initialize-DataCollection to prepare output directories and validate disk space
- Very specific: line 70
Use Export-ObjectToFile to save results with consistent formatting
- Distinctive: line 89
Use proper markdown formatting in comment-based help
- Distinctive: line 90
Document any prerequisites or dependencies
- Very specific: line 111
All tests are offline (mock-based) in tests/offline/.
- Distinctive: line 125
Never log credentials or secrets
- Distinctive: line 126
Use SecureString for password parameters
- Very specific: line 128
Check for admin privileges when required using Confirm-IsAdmin
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
GitHub Copilot Instructions for SdnDiagnostics
Project Overview
SdnDiagnostics is a PowerShell module for diagnosing and troubleshooting Software Defined Networking (SDN) infrastructure in Microsoft environments, including Azure Stack HCI and Windows Server deployments.
Code Style and Conventions
PowerShell Standards
- Follow PowerShell best practices and the PowerShell Practice and Style Guide
- Use approved verbs for function names (Get-, Set-, New-, Remove-, etc.)
- Use PascalCase for function names and parameters
- Use camelCase for local variables
- Include comprehensive comment-based help for all exported functions
Function Structure
- Always include
[CmdletBinding()]attribute for advanced functions - Use parameter sets when functions have mutually exclusive parameters
- Include proper parameter validation attributes (
Mandatory,ValidateSet,ValidateScript, etc.) - Use
ShouldProcesspattern for functions that make changes (with-Confirmand-WhatIfsupport) - Always include proper error handling with try/catch blocks
Error Handling
- Use
Trace-Outputfor logging instead ofWrite-HostorWrite-Verbose - Pipe exceptions to
Trace-Exceptionin catch blocks - Always include both
Trace-ExceptionandWrite-Errorin catch blocks - Return meaningful error messages to users
Example:
try {
# Function logic
}
catch {
$_ | Trace-Exception
$_ | Write-Error
}Logging and Tracing
- Use Trace-Output function for all logging with appropriate -Level parameter
- Level:Verbose for detailed debug information
- Level:Information for general information (default)
- Level:Warning for warnings
- Level:Error for errors
- Level:Exception for exceptions (handled by Trace-Exception)
- Level:Success for successful operations
Module Organization
Place role-specific functions in appropriate module files:
SdnDiag.Common.psm1- Functions common to all rolesSdnDiag.Gateway.psm1- Gateway-specific functionsSdnDiag.LoadBalancerMux.psm1- Load balancer MUX functionsSdnDiag.NetworkController.psm1- Network Controller functionsSdnDiag.Server.psm1- Server/host-specific functionsSdnDiag.Utilities.psm1- Utility helper functions
Remote Execution
- Use
New-PSRemotingSessionfor creating remote sessions - Use
Invoke-PSRemoteCommandfor executing commands remotely. This function should handle session management and error handling. - Always pass
$Credentialparameter for remote operations
REST API Interactions
- Use
Invoke-RestMethodWithRetryorInvoke-WebRequestWithRetryfor Network Controller REST API calls - Support both certificate and credential-based authentication
- Always include parameter sets for
RestCertificateandRestCredential - Use
@ncRestParamssplatting pattern for REST parameters
Data Collection
- Use
Initialize-DataCollectionto prepare output directories and validate disk space - Use
Export-ObjectToFileto save results with consistent formatting - Support
-OutputDirectoryparameter for all data collection functions - Include time range parameters (
-FromDate,-ToDate) where applicable
Credential Handling
- Use
[System.Management.Automation.PSCredential]type - Default to
[System.Management.Automation.PSCredential]::Empty - Include
[System.Management.Automation.Credential()]attribute
Example:
[Parameter(Mandatory = $false)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::EmptyDocumentation
- Include synopsis, description, parameter descriptions, and examples
- Use proper markdown formatting in comment-based help
- Document any prerequisites or dependencies
- Include related links where applicable
Common Patterns
Network Controller REST Parameter Pattern
$ncRestParams = @{
NcUri = $NcUri
ErrorAction = 'Stop'
}
switch ($PSCmdlet.ParameterSetName) {
'RestCertificate' { $ncRestParams.Add('NcRestCertificate', $NcRestCertificate) }
'RestCredential' { $ncRestParams.Add('NcRestCredential', $NcRestCredential) }
}
$result = Get-SdnResource @ncRestParams -ResourceRef $resourceRefPester Testing
All tests are offline (mock-based) in tests/offline/. See .github/instructions/pester-tests.instructions.md for the full authoring guide.
When adding a new function, always add corresponding Pester tests:
- Pure utility functions (Format-, Confirm-, Convert-*) → Pattern A (InModuleScope, no mocking)
- Functions calling NC REST API → Pattern B (mock
Invoke-RestMethodWithRetryinsideInModuleScope SdnDiag.NetworkController) - Functions calling remote commands → Pattern C (mock
Invoke-PSRemoteCommandinside the nested module scope)
Test file convention: Named after the source module (e.g., SdnDiag.Utilities.psm1 → Utilities.Tests.ps1)
Mock data: Uses DVLAB prefix naming. JSON files in tests/offline/data/SdnApiResources/ auto-load into $Global:PesterOfflineTests.SdnApiResources.
Running: Build the module first (.\build.ps1), then .\tests\offline\RunTests.ps1
Security Best Practices
- Never log credentials or secrets
- Use SecureString for password parameters
- Validate user input with appropriate attributes
- Check for admin privileges when required using
Confirm-IsAdmin
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.

