PowerShell格式强化

SKILL开发
开发 未标注权限 许可证不明确
安装这个技能

用于强化Llm对PowerShell的编写规范,避免误用错误的格式导致PowerShell运行报错。

一句话选型结论

按资料字段整理

PowerShell格式强化是开发类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_57ad3ca3/powershell-authoring-rules
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_57ad3ca3仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 1791709696
正文体量12.3 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写代码与改 bug

按需求补代码、定位并修掉报错。

读仓库与生成改动

让模型读懂项目结构,再给出可落地的改动。

跑测试与排查故障

按现象排查问题,补测试用例并复跑。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
PowerShell格式强化当前 未标注权限 未标注 未标注 未标注 有
技能审查员 浏览器控制 ClawHub 市场 877.9 万 OpenClaw 有
Vercel React 最佳实践 浏览器控制 GitHub 仓库 849.1 万 Codex、Claude、Cursor 有
GitHub 代码协作 联网访问 ClawHub 市场 763.3 万 OpenClaw 有
网页设计指南 联网访问 GitHub 仓库 668.6 万 Codex、Claude、Cursor 有
本体论 只读 ClawHub 市场 663.7 万 OpenClaw 有

SKILL.md 全文

12.3 KB
模型实际读到的说明书原文,来自技能仓库

PowerShell Authoring Rules

Overview

This skill is the mandatory rulebook for authoring PowerShell on Windows. Whenever a task
requires writing or running a PowerShell command, one-liner, or script, consult this skill
first and follow its rules exactly. It encodes the syntax rules, hard constraints, and
verification checklist that prevent the most common PowerShell authoring failures: Bash-isms
leaking into PowerShell, silent backtick breakage, --% parser shutdown, mangled quoting,
lost exit codes, and 5.1-incompatible syntax.

The content of this skill is self-contained — everything needed to write correct PowerShell
is in this file and the referenced references/ file. Do not fall back on Bash habits.

When To Use

Apply this skill whenever any of the following is true:

  • A PowerShell command, one-liner, pipeline, or .ps1 / .psm1 script is being authored.
  • PowerShell code is being reviewed, debugged, or corrected.
  • A Windows shell operation is requested: 批处理文件、批量重命名、读取/写入文件、改环境变量、
    启动原生程序、管道过滤、生成 JSON/CSV。
  • A decision must be made between PowerShell and another runtime (Python, Node) for a task.
  • Any question arises about PowerShell quoting, escaping, operators, or version compatibility.

Mandatory Workflow

Follow these steps in order for every PowerShell authoring request. Do not skip Step 1.

  1. Consult the rules. Re-read the rule sections below (and references/extended-examples.md
    when the snippet is non-trivial) before emitting code.
  2. Choose the execution mode. Select a simple one-liner, a persistent session, or a
    different runtime per "Choosing the Execution Mode".
  3. Draft the code. Apply every rule and honor every hard constraint in this file.
  4. Self-check. Run the "Pre-Output Self-Check Checklist" against the draft. If the draft is
    substantial, additionally run scripts/check_ps_syntax.py on it and fix every reported
    violation before output. Never emit code that fails the checklist.

Choosing the Execution Mode

  • Run a simple PowerShell command directly as a one-liner.
  • Consider Python for complex or stateful tasks. Do not force a long stateful workflow into a
    single PowerShell one-liner.
  • For multi-step interactive work, start a persistent session with interactive=True, then
    reuse the same tool with task_id=<id> to send input and read output in one step.
  • Use wait_for_pattern to wait for a prompt in a persistent session.
  • TaskOutput remains available as a fallback for listing and monitoring tasks.
  • Send exit to close a persistent session.

1. Cmdlets and Naming

  • Cmdlets use Verb-Noun names. Core vocabulary:
    Get-ChildItem (list files), Get-Content (read file), Set-Location (cd),
    Copy-Item, Move-Item, Remove-Item, New-Item, Select-String (grep),
    Get-Command, Get-Help.
  • Alias names (ls, cat, cd, rm, cp, mv) resolve to cmdlets but differ from their
    Bash namesakes. Prefer the full Verb-Noun form in scripts for clarity; aliases are
    acceptable in throwaway one-liners only when the mapping is exact.

2. Splatting and Exit Codes

  • Splat cmdlet parameters with @{}:

powershell $p = @{ LiteralPath = $f; Destination = $d } Copy-Item @p

  • $LASTEXITCODE is for native commands only — it does not report cmdlet success.
    Use $? or the cmdlet's own error stream for cmdlets.

3. Pipelines and Objects

  • The pipeline | passes .NET objects, not plain text. Shape the stream with
    Where-Object, Select-Object, ForEach-Object, Sort-Object, Measure-Object.
  • foreach (...) { } is a statement, not an expression — it cannot be piped directly.
    Either assign the result first, or use ForEach-Object:

```powershell
# Wrong — a foreach statement cannot be piped
foreach ($x in $list) { $x.Name } | Sort-Object

# Right — assign first
$names = foreach ($x in $list) { $x.Name }
$names | Sort-Object

# Right — use the pipeline cmdlet
$list | ForEach-Object { $_.Name } | Sort-Object
```

4. Operators

  • Comparison: -eq -ne -gt -ge -lt -le, -like (wildcard), -match (regex),
    -contains (collection membership), -replace (regex replace).
  • Logical: -and -or -not (or !).
  • Comparison operators are case-insensitive by default; prefix with c/i (-ceq, -imatch)
    when case sensitivity matters.

5. Command Chaining and Continuation

  • Chain commands with ; (always run next) or && / || (PowerShell 7+: run next only on
    success / only on failure). On Windows PowerShell 5.1, && and || are syntax errors —
    see "Windows PowerShell 5.1 Baseline".
  • Avoid backtick continuation ` — a trailing space after the backtick silently breaks
    the line. Use @() arrays or let the line break naturally after pipes, commas, or operators:

``powershell # Avoid Get-ChildItem -Path C:\Temp
-Recurse

# Prefer — continue after a pipe, comma, or operator
Get-ChildItem -Path C:\Temp |
Where-Object { $_.Length -gt 1MB }
```

  • Avoid --% (Stop-Parsing) — it disables parsing for the remainder of the line. Use it
    only for fixed literal native commands that need raw argument passthrough.

6. Strings and Quoting

  • 'single quotes' are literal. "double quotes" expand $variables and $(subexpressions).
  • Use ${name} for variable boundaries and $($obj.prop) for properties:

powershell "${name}_suffix" "length is $($obj.Length)"

  • Avoid Bash-style escaping such as "\"q\"". Use '"q"', or backtick-escape inside a
    double-quoted string: ""q"".

7. Here-Strings, Literal Text, and JSON

  • Here-strings: @'...'@ (literal) or @"..."@ (expanded).
  • The opening delimiter must be last on its line; the closing delimiter must be alone at
    the start of a line
    .
  • No Bash heredocs: python - <<'PY' is invalid in PowerShell.
  • Prefer ConvertTo-Json over manual JSON escaping:

powershell $obj = [ordered]@{ name = 'demo'; count = 3 } $json = $obj | ConvertTo-Json -Depth 5 Set-Content -LiteralPath out.json -Value $json -Encoding utf8

8. Native Executables and Argument Passing

  • Native arguments: & $exe @argList.
  • Do not use $args — it is an automatic variable and will not behave as an argument list.
  • An omitted argument, '', and $null are distinct values; do not treat them as equivalent.
  • Capture $LASTEXITCODE immediately after the native call — capture it before piping,
    because $LASTEXITCODE may not be set once native output is piped into a cmdlet:

powershell & $exe @argList $code = $LASTEXITCODE if ($code -ne 0) { throw "exe failed with exit code $code" }

  • $LASTEXITCODE holds the exit code of the last native command; $? is $true if the last
    command succeeded.

9. Environment Variables

  • Read/write session-scoped values with $env:NAME.
  • Persist values with [Environment]::SetEnvironmentVariable('NAME', 'value', 'Scope').
  • Resolution priority: Process > User > Machine.
  • List them with Get-ChildItem Env:.
  • Append to PATH instead of overwriting, and check for duplicates first:

powershell if ($env:PATH -notlike '*C:\tools*') { $env:PATH += ';C:\tools' }

  • Do not use %NAME% inside PowerShell — that is cmd.exe syntax and is taken literally.
  • Child process changes do not propagate back to the parent process.

10. Parameter Binding

  • Parameter value expressions must be parenthesized:
    -Index (100..120), not -Index 100..120.
  • Use -LiteralPath (not -Path) whenever a path may contain wildcard characters [ ] * ?.

11. Windows PowerShell 5.1 Baseline

Assume Windows PowerShell 5.1 for compatibility unless the target is explicitly PowerShell 7+.
On 5.1 the following are unavailable or syntax errors:

  • && and || chaining — use ; plus explicit if ($?) { ... }, or -ErrorAction.
  • Ternary ?:, null-coalescing ??, null-conditional ?..
  • -Parallel on ForEach-Object, Get-Error, Test-Json, and other 7+-only cmdlets.

If 7+ is confirmed available, these constructs become legal — but prefer the 5.1-compatible
form when the edition is unknown.

12. Pre-Output Self-Check Checklist

Verify every item before emitting PowerShell code. Fix any failure, then re-check.

  • [ ] No %NAME% environment-variable syntax.
  • [ ] No Bash heredoc (<<'PY', <<EOF).
  • [ ] No backtick line continuation; line breaks occur after pipes, commas, or operators.
  • [ ] No --% unless the command is a fixed literal native invocation.
  • [ ] No piped foreach (...) { } statement.
  • [ ] No $args used as a native argument list.
  • [ ] No Bash-style escaping ("\"q\""); use '"q"' or backtick escaping.
  • [ ] $($obj.prop) used for properties inside double-quoted strings; ${name} used for
    variable boundaries.
  • [ ] $LASTEXITCODE captured immediately, before piping native output.
  • [ ] Range expressions passed as parameters are parenthesized.
  • [ ] -LiteralPath used for user- or data-supplied paths.
  • [ ] && / || / ?: / ?? / ?. absent unless PowerShell 7+ is confirmed.
  • [ ] @'...'@ / @"..."@ delimiters: opener last on its line, closer alone at line start.
  • [ ] JSON produced via ConvertTo-Json, not manual string escaping.
  • [ ] scripts/check_ps_syntax.py run on any non-trivial snippet, with zero violations.

Resources

references/extended-examples.md

Extended correct/incorrect worked examples covering file operations, pipeline shaping,
environment variables, native executables, JSON generation, and 5.1-vs-7 compatibility.
Load this file when writing non-trivial scripts or when debugging a syntax failure.

scripts/check_ps_syntax.py

Static rule checker for PowerShell snippets: a deterministic enforcement pass over the rules in
Sections 5–11 plus the extended common Bash-ism set. Run it on any non-trivial snippet before
emitting code.

"C:\Users\Seele Vollerei\.workbuddy\binaries\python\versions\3.13.12\python.exe" \
  "<skill-dir>/scripts/check_ps_syntax.py" --file draft.ps1

Also accepts --text "<snippet>" and stdin. Exit code 0 means clean, 1 means violations,
2 means usage/IO error. --ps-version 7 allows 7+-only syntax; --strict fails on warnings;
--json emits machine-readable output.

Rule index:

Rule Detects
PS001 %NAME% cmd.exe variable syntax (also inside quoted strings)
PS002 Bash heredoc <<EOF / <<'PY'
PS003 --% Stop-Parsing
PS004 $args used as a native argument list
PS005 Bash-style escaping (backslash-quote)
PS006 CMD-style 2>nul redirect
PS007 Bash export VAR=value
PS008 Bash if [ ... ] test syntax
PS009 Unix tools (grep/sed/awk) invoked as cmdlets
PS010 Unparenthesized range passed as a parameter value
PS011 Backtick line continuation, incl. the trailing-space break
PS012 Piped foreach (...) { } statement
PS013 $LASTEXITCODE read after native output was piped
PS014 Here-string opener with content on the same line
PS015 Indented here-string closing delimiter
PS016 -Path given a literal containing [ ] * ?
PS017 Set-Content/Out-File without -Encoding (5.1 ANSI default)
PS101–105 && \|\| ?? ?. ?: used on the 5.1 baseline

常见问题

5 问
答案由本站依据条目字段整理
PowerShell格式强化怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_57ad3ca3/powershell-authoring-rules。安装方式为未标注。装完刷新技能列表或重开客户端。

PowerShell格式强化支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

PowerShell格式强化权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

PowerShell格式强化收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

PowerShell格式强化用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。