PSRule
Copilot instructions474 starsChanged 15 months agoMITView on GitHub
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. PSRule is a cross-platform PowerShell module for validating infrastructure as code (IaC) and objects using PowerShell rules. The project includes .NET libraries, a PowerShell module, CLI tools, VS Code extension, and comprehensive documentation. Always test functionality after making changes: Expected: Should return 11 commands without errors. Expected: Should display help text starting with "PSRule CLI…
- Deletes or force-pushes
- Installs packages
The file
We split this copilot-instructions.md into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
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
- Distinctive: line 3
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does …
- Distinctive: line 63
Always test functionality after making changes:
- Very specific: line 149
Use Invoke-Build with these common targets:
- Very specific: line 158
When implementing logging use ILogger from src/PSRule.Types/Runtime/ILogger.cs.
- Distinctive: line 159
When creating new files, always add a trailing newline before the end of the file.
- Very specific: line 165
PowerShell execution policy errors: Use pwsh instead of powershell for cross-platform compatibility.
≈ “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
PSRule Development Instructions
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
Working Effectively
PSRule is a cross-platform PowerShell module for validating infrastructure as code (IaC) and objects using PowerShell rules. The project includes .NET libraries, a PowerShell module, CLI tools, VS Code extension, and comprehensive documentation.
Bootstrap and Build Process
- Install PowerShell dependencies (3 seconds, NEVER CANCEL):
pwsh ./scripts/pipeline-deps.ps1 - Restore .NET dependencies (2 seconds, NEVER CANCEL):
dotnet restore - Build PowerShell module (35 seconds, NEVER CANCEL, set timeout to 60+ minutes):
pwsh -c "Invoke-Build BuildModule -Configuration Release" - Build CLI tool (25 seconds, NEVER CANCEL, set timeout to 60+ minutes):
pwsh -c "Invoke-Build BuildCLI -Configuration Release" - Build VS Code extension (15 seconds, NEVER CANCEL, set timeout to 30+ minutes):
npm install npm run build - Build documentation (13 seconds Python deps + 5 seconds build, NEVER CANCEL, set timeout to 30+ minutes):
python3 -m pip install -r requirements-docs.txt mkdocs build
Testing
NEVER CANCEL test runs. Some tests require network access and may fail in restricted environments.
- Unit tests for Types (5 seconds, NEVER CANCEL, set timeout to 30+ minutes):
dotnet test tests/PSRule.Types.Tests/ - All .NET tests (may fail due to network restrictions, 60+ seconds, NEVER CANCEL, set timeout to 60+ minutes):
dotnet test - Format validation (50 seconds, NEVER CANCEL, set timeout to 60+ minutes):
dotnet format --verify-no-changes
Validation Scenarios
Always test functionality after making changes:
- Verify PowerShell module loads correctly:
Expected: Should return 11 commands without errors.pwsh -c "Import-Module ./out/modules/PSRule/PSRule.psd1 -Force; Get-Command -Module PSRule | Measure-Object | Select Count" - Test CLI tool functionality:
Expected: Should display help text starting with "PSRule CLI v0.0.1"../out/cli/build/Microsoft.PSRule.Tool --help - Verify VS Code extension builds:
Expected: Createsnpm run packageout/package/vscode-ps-rule-0.0.1.vsix(~29MB).
Project Structure
Key Directories
src/- Source code for all componentsPSRule/- Core PowerShell modulePSRule.Tool/- CLI applicationPSRule.Types/- Type definitionsPSRule.CommandLine/- Command line interfacePSRule.EditorServices/- VS Code language server
tests/- Unit tests for all componentsdocs/- Documentation source (MkDocs)out/- Build output directoryscripts/- Build and utility scripts
Key Files
pipeline.build.ps1- Main build script using InvokeBuildbuild.ps1- Simple wrapper for pipeline.build.ps1global.json- .NET SDK version specificationpackage.json- VS Code extension configurationrequirements-docs.txt- Python documentation dependenciesmkdocs.yml- Documentation site configuration
Common Tasks
Working with PowerShell Module
- Module manifest:
src/PSRule/PSRule.psd1 - Main module file:
src/PSRule/PSRule.psm1 - Built module location:
out/modules/PSRule/
Working with CLI Tool
- Source:
src/PSRule.Tool/ - Built executable:
out/cli/build/Microsoft.PSRule.Tool - Test with:
./out/cli/build/Microsoft.PSRule.Tool --help
Working with VS Code Extension
- Source:
src/vscode-ps-rule/ - Build with:
npm run buildornpm run package - Package output:
out/package/vscode-ps-rule-*.vsix
Linting and Code Quality
- ALWAYS run these before committing or CI will fail:
dotnet format --verify-no-changes
Documentation
- Source files in
docs/directory - Build with
mkdocs build - Serve locally with
mkdocs serve - May show API rate limit warnings (normal in CI environments)
Quick Reference
| Task | Command |
| Install PS deps | pwsh ./scripts/pipeline-deps.ps1 |
| Restore .NET deps | dotnet restore |
| Build Module | pwsh -c "Invoke-Build BuildModule -Configuration Release" |
| Build CLI | pwsh -c "Invoke-Build BuildCLI -Configuration Release" |
| Build VSCode Ext | npm install && npm run build |
| Build Docs | python3 -m pip install -r requirements-docs.txt && mkdocs build |
| Run All Tests | dotnet test |
| Format Validation | dotnet format --verify-no-changes |
Build Targets
Use Invoke-Build with these common targets:
BuildModule- Build PowerShell module onlyBuildCLI- Build CLI toolTest- Run all tests (may fail due to network restrictions)TestDotNet- Run .NET unit tests onlyBuildHelp- Generate help documentation
Development Context
- When implementing logging use
ILoggerfromsrc/PSRule.Types/Runtime/ILogger.cs. - When creating new files, always add a trailing newline before the end of the file.
Troubleshooting
Common Issues
- Tests fail with network errors: Normal in restricted environments. Focus on core functionality tests.
- PowerShell execution policy errors: Use
pwshinstead ofpowershellfor cross-platform compatibility. - Documentation build API errors: Normal without GitHub token. Use
mkdocs buildwithout--strict. - Long build times: Builds can take 60+ seconds total. NEVER cancel early.
Common Commands
- Clean build output:
rm -rf out/* - Reset PowerShell dependencies:
pwsh ./scripts/pipeline-deps.ps1 -Reset - Update .NET SDK:
dotnet sdk check - Rebuild everything:
pwsh -c "Invoke-Build -Clean; Invoke-Build -All"
Performance Expectations
- Complete build cycle: ~80 seconds
- Incremental module build: ~25 seconds
- Unit tests: ~5 seconds (Types), ~60+ seconds (full suite)
- Documentation build: ~5 seconds
- VS Code extension: ~15 seconds
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.

