Powershell-Copilot-Standards: Command for GitHub Copilot

.github/prompts/code-analysis.prompt.md

code-analysis is a command for GitHub Copilot from fadwen/Powershell-Copilot-Standards. It costs 9 tokens per session (453 once invoked), scanned A, original, MIT.

A code-quality checklist for PowerShell code. It covers error handling, parameter help, string and collection handling, performance, and the types returned by functions.

In plain words
What is it for?
Use it to inspect selected PowerShell code for safer error handling, clearer help, suitable data structures, and appropriate performance choices.
Why use it?
It provides a consistent review of common PowerShell maintenance and quality problems instead of relying on a quick visual inspection.

Command for GitHub Copilot

Written for GitHub Copilot: a Copilot chat mode or prompt.

This is fadwen/Powershell-Copilot-Standards's own configuration. It tells GitHub Copilot how to work on Powershell-Copilot-Standards itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything Powershell-Copilot-Standards configures →

Reuse

Borrowing it

Nothing to install: this file belongs to fadwen/Powershell-Copilot-Standards. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/fadwen/Powershell-Copilot-Standards/main/.github/prompts/code-analysis.prompt.md
Clone the repo
git clone --depth 1 https://github.com/fadwen/Powershell-Copilot-Standards

Made for: GitHub Copilot.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-analysis

README.md
[![agentmods](https://agentmods.dev/badge/commands/fadwen/powershell-copilot-standards/code-analysis/github.svg)](https://agentmods.dev/commands/fadwen/powershell-copilot-standards/code-analysis)
Your own site
<a href="https://agentmods.dev/commands/fadwen/powershell-copilot-standards/code-analysis"><img src="https://agentmods.dev/badge/commands/fadwen/powershell-copilot-standards/code-analysis/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for code-analysis

Your own site · 80×15
<a href="https://agentmods.dev/commands/fadwen/powershell-copilot-standards/code-analysis"><img src="https://agentmods.dev/badge/commands/fadwen/powershell-copilot-standards/code-analysis.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 453 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00009 $0.00453
Opus 5.5 $0.00004 $0.00181
Sonnet 5.5 $0.00002 $0.00091
Haiku 4.5 $0.00001 $0.00045

Measured 1mo ago against content hash 5a3cfd94cc88, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-analysis scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/prompts/code-analysis.prompt.md · 78 lines

What it actually says

Perform thorough analysis of this PowerShell code against modern best practices:

Selected Code:

${selection}

Analysis Framework:

1. Modern PowerShell Patterns ✅

  • Error handling: Verify $_ usage in catch blocks (not $Error[0])
  • Credential creation: Check for [PSCredential]::new() vs New-Object
  • Parameter validation: Ensure appropriate validation without redundancy
  • String operations: Context-appropriate concatenation vs StringBuilder

2. Comment-Based Help Quality ✅

  • Proper block comment syntax with opening markers
  • Complete parameter documentation
  • Meaningful examples with descriptions
  • Appropriate .INPUTS and .OUTPUTS sections
  • Avoid maintenance-heavy versioning in .NOTES

3. Performance Patterns ✅

  • Context-aware string operations (simple vs complex)
  • Collection handling: flag += only where the declared target is below 7.5, in which it is still O(n²), or where the loop is unbounded. PowerShell 7.5 optimised it. Never suggest ArrayList
  • Appropriate use of pipeline vs loops
  • Memory-conscious patterns for large datasets

4. Output Type Design ✅

  • Descriptive type names instead of misleading [PSCustomObject]
  • Custom classes for complex objects
  • Meaningful IntelliSense support
  • Proper type declarations

5. Enterprise Standards ✅

  • Correlation ID implementation
  • Structured logging patterns
  • Configuration-driven behavior
  • Environment-appropriate error handling

6. Security & Compliance ✅

  • Modern security patterns
  • Input validation best practices
  • Audit trail requirements
  • Compliance framework alignment

7. Code Quality Metrics ✅

  • Approved PowerShell verb usage
  • Consistent style and formatting
  • Appropriate function complexity
  • Clear separation of concerns

Analysis Output: Provide prioritized recommendations with:

  • ❌ Issues found with severity rating
  • ✅ Best practices already implemented
  • 🔧 Specific code corrections
  • 💡 Optimization opportunities
  • 📋 Compliance gaps

Include corrected code examples demonstrating proper modern PowerShell patterns.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 78 lines · 9 tokens per session scan A 5a3cfd94cc88

Subscribe to this mod's changes

code-analysis is a command published in the GitHub repository fadwen/Powershell-Copilot-Standards (19 stars, last pushed 1mo ago), licensed MIT. It adds 9 tokens to every session and 453 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-16.