Skip to content

Add .github/copilot-instructions.md for AI agent guidance#58

Open
cocallaw wants to merge 3 commits into
mainfrom
cocallaw/add-copilot-instructions
Open

Add .github/copilot-instructions.md for AI agent guidance#58
cocallaw wants to merge 3 commits into
mainfrom
cocallaw/add-copilot-instructions

Conversation

@cocallaw

Copy link
Copy Markdown
Owner

Description

Adds a .github/copilot-instructions.md file so that GitHub Copilot (and other AI coding agents) understand the project's conventions, compatibility constraints, and architecture when assisting with this repo.

Without project-specific instructions, AI agents default to generic PowerShell patterns that may introduce 7+-only syntax, miss the Public/Private module structure, or overlook security practices like CSV formula injection prevention.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test updates

Changes Made

  • Added .github/copilot-instructions.md covering:
    • Module layout (Public/Private/Tests structure and export rules)
    • PowerShell 5.1 compatibility requirements with banned 7+-only syntax
    • Coding conventions (approved verbs, CmdletBinding, parameter validation, error handling)
    • Security practices (CSV injection, XSS prevention, URL validation, token isolation)
    • Testing guidance (Pester v5, mocking, InModuleScope usage)
    • CI/CD expectations (PSScriptAnalyzer + cross-platform test matrix)
    • Step-by-step checklist for adding new functions

Testing

  • All existing tests pass

N/A -- documentation-only change that does not affect runtime behavior.

Test Environment

  • PowerShell Version: N/A
  • Operating System: macOS
  • Authentication Method: N/A

Test Commands

# No runtime testing needed for documentation file

Test Results

N/A - documentation only

Checklist

  • My code follows the existing code style
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • I have updated the documentation (README, function help, etc.)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally
  • I have checked for any breaking changes

Additional Notes

This file is automatically loaded by VS Code Copilot for all workspace interactions. It helps AI agents produce code that is compatible with both PowerShell Desktop 5.1 and Core 7+, follows the module's established patterns, and respects the security constraints documented in the codebase.

Provide project-specific instructions covering module layout, PowerShell 5.1/7+
compatibility requirements, coding conventions, security practices, testing with
Pester v5, CI/CD expectations, and guidance for adding new functions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 23, 2026 23:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repository-level Copilot instruction file to steer AI agents toward AzRetirementMonitor’s established module structure, PowerShell 5.1 compatibility constraints, security expectations, and CI/testing workflow.

Changes:

  • Introduces .github/copilot-instructions.md documenting module layout (Public/Private/Tests) and export rules.
  • Documents PowerShell 5.1 + 7+ compatibility guidance (including 7+-only syntax to avoid).
  • Captures repo-specific guidance for error handling, security (CSV injection/XSS/nextLink validation), testing (Pester v5), and CI expectations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/copilot-instructions.md Outdated
Comment on lines +58 to +59
- Validate URLs with scheme checks (`https://` only) before rendering links.
- Validate pagination `nextLink` URIs against an allowlist of trusted hosts.
Clarify that HTML link rendering accepts both http:// and https:// (to block
protocol injection like javascript:), while pagination nextLink validation is
strictly https-only against a trusted host allowlist.

Addresses PR review feedback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread .github/copilot-instructions.md Outdated
- Tests use **Pester v5** with `BeforeAll` module imports.
- Test file: `Tests/AzRetirementMonitor.Tests.ps1`
- Mock all Azure API/module calls — tests must work without a live Azure connection.
- Use `InModuleScope AzRetirementMonitor { }` when testing private/internal functions.
Comment thread .github/copilot-instructions.md Outdated
- **Dual retrieval modes**: Default uses Az.Advisor module; `-UseAPI` switch enables direct REST calls. Both return identical `[PSCustomObject]` output shapes.
- **`SupportsShouldProcess`**: Used on destructive or file-writing operations (e.g., `Export-AzRetirementReport`).
- **Pipeline support**: `Get-AzRetirementRecommendation` output pipes directly into `Export-AzRetirementReport`.
- **No external dependencies at runtime** beyond Az.Advisor/Az.Accounts (for default mode) or Azure CLI (for API mode).
- Replace InModuleScope guidance with the actual pattern used in the repo:
  & (Get-Module AzRetirementMonitor) { ... }
- Clarify that API mode supports both Azure CLI and Az.Accounts for auth

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants