powershell-expert

📁 oimiragieo/agent-studio 📅 10 days ago
21
总安装量
21
周安装量
#17729
全站排名
安装命令
npx skills add https://github.com/oimiragieo/agent-studio --skill powershell-expert

Agent 安装分布

github-copilot 21
gemini-cli 21
cursor 21
amp 20
codex 20
kimi-cli 20

Skill 文档

PowerShell Expert Skill

1. Robust Execution

The Iron Law: Never allow silent failures.

  • Action: Always set $ErrorActionPreference = 'Stop' at the top of your scripts.
  • Block: Use Try/Catch for any operation that interacts with the filesystem or network.

2. Object-Oriented Piping

Do not parse text with regex if an object exists.

  • Action: Convert raw output to [PSCustomObject] or use -Output JSON flags in CLIs.
  • Benefit: Maintains data integrity and allows for native filtering/sorting.

3. Cross-Platform Core

  • Standard: Code for PowerShell Core (7+). Avoid Windows-only modules (e.g., ActiveDirectory) unless explicitly required.
  • Paths: Always use Join-Path or [IO.Path]::Combine to ensure compatibility with both / and \.

4. Security & Secrets

  • Rule: Never hardcode credentials.
  • Standard: Use the Microsoft.PowerShell.SecretManagement module to pull secrets from local or cloud stores.
  • Policy: Block usage of Invoke-Expression (IEX) on untrusted inputs.

5. Module & Pester Testing

  • Structure: Organize large scripts into .psm1 modules with explicit exports.
  • Testing: Every production script MUST have a corresponding .Tests.ps1 file using Pester 6.

Example 1: Robust File Processing

$ErrorActionPreference = 'Stop'
try {
    $files = Get-ChildItem -Path $target -Filter *.json
    foreach ($file in $files) {
        $data = Get-Content -Path $file.FullName | ConvertFrom-Json
        # Process $data object
    }
} catch {
    Write-Error "Failed to process files: $($_.Exception.Message)"
}

Example 2: Secure Secret Retrieval

Request: “Automate the API backup.” Action: 1. Use Get-Secret to retrieve the key. 2. Invoke the backup CLI with the key injected via environment variable. 3. Log completion without exposing the secret.

Memory Protocol (MANDATORY)

Before starting:

cat .claude/context/memory/learnings.md

After completing: Record new PowerShell modules, Pester testing patterns, or OS-specific workarounds to memory.

ASSUME INTERRUPTION: Your context may reset. If it’s not in memory, it didn’t happen.