MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Powershell

Powershell是一款code方向的AI技能,核心价值是PowerShell cmdlet and scripting best practices based on Microsoft guidelines,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

PowerShell cmdlet and scripting best practices based on Microsoft guidelines

Last verified on: 2026-05-30
mkdir -p ./skills/powershell && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/powershell/SKILL.md -o ./skills/powershell/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# PowerShell Cmdlet Development Guidelines


This guide provides PowerShell-specific instructions to help GitHub Copilot generate idiomatic,

safe, and maintainable scripts. It aligns with Microsoft’s PowerShell cmdlet development guidelines.


Naming Conventions


- **Verb-Noun Format:**

- Use approved PowerShell verbs (Get-Verb)

- Use singular nouns

- PascalCase for both verb and noun

- Avoid special characters and spaces


- **Parameter Names:**

- Use PascalCase

- Choose clear, descriptive names

- Use singular form unless always multiple

- Follow PowerShell standard names


- **Variable Names:**

- Use PascalCase for public variables

- Use camelCase for private variables

- Avoid abbreviations

- Use meaningful names


- **Alias Avoidance:**

- Use full cmdlet names

- Avoid using aliases in scripts (e.g., use `Get-ChildItem` instead of `gci`)

- Document any custom aliases

- Use full parameter names


Example - Naming Conventions


powershell
function Get-UserProfile {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$Username,

        [Parameter()]
        [ValidateSet('Basic', 'Detailed')]
        [string]$ProfileType = 'Basic'
    )

    process {
        $outputString = "Searching for: '$($Username)'"
        Write-Verbose -Message $outputString
        Write-Verbose -Message "Profile type: $ProfileType"
        # Logic here
    }
}

Parameter Design


- **Standard Parameters:**

- Use common parameter names (`Path`, `Name`, `Force`)

- Follow built-in cmdlet conventions

- Use aliases for specialized terms

- Document parameter purpose


- **Parameter Names:**

- Use singular form unless always multiple

- Choose clear, descriptive names

- Follow PowerShell conventions

- Use PascalCase formatting


- **Type Selection:**

- Use common .NET types

- Implement proper validation

- Consider ValidateSet for limited options

- Enable tab completion where possible


- **Switch Parameters:**

- **ALWAYS** use `[switch]` for boolean flags, never `[bool]`

- **NEVER** use `[bool]$Parameter` or assign default values

- Switch parameters default to `$false` when omitted

- Use clear, action-oriented names

- Test presence with `.IsPresent`

- Using `$true`/`$false` in parameter attributes (e.g., `Mandatory = $true`) is acceptable


Example - Parameter Design


powershell
function Set-ResourceConfiguration {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$Name,

        [Parameter()]
        [ValidateSet('Dev', 'Test', 'Prod')]
        [string]$Environment = 'Dev',

        # ✔️ CORRECT: Use `[switch]` with no default value
        [Parameter()]
        [switch]$Force,

         # ❌ WRONG: Shows incorrect default assignment, however this is correct syntax (requires `[switch]` cast).
        [Parameter()]
        [switch]$Quiet = [switch]$true,

        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string[]]$Tags
    )

    process {
        # Use .IsPresent to check switch state
        if ($Quiet.IsPresent) {
            Write-Verbose "Quiet mode enabled"
        }
    }
}

Pipeline and Output


- **Pipeline Input:**

- Use `ValueFromPipeline` for direct object input

- Use `ValueFromPipelineByPropertyName` for property mapping

- Implement Begin/Process/End blocks for pipeline handling

- Document pipeline input requirements


- **Output Objects:**

- Return rich objects, not formatted text

- Use PSCustomObject for structured data

- Avoid Write-Host for data output

- Enable downstream cmdlet processing


- **Pipeline Streaming:**

- Output one object at a time

- Use process block for streaming

- Avoid collecting large arrays

- Enable immediate processing


- **PassThru Pattern:**

- Default to no output for action cmdlets

- Implement `-PassThru` switch for object return

- Return modified/created object with `-PassThru`

- Use verbose/warning for status updates


Example

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Powershell to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

Is Powershell compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Powershell?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Powershell?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/powershell/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping usability testing

AI-generated designs should be validated with real users before development.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills