powershell-windows
Skill4 starsChanged 48 days agoMITView on GitHub
Use when writing, running, or debugging PowerShell scripts on Windows. Covers Windows PowerShell 5.1 vs PowerShell 7+ differences, file encoding and BOM pitfalls, execution policy, admin elevation, paths with spaces or non-ASCII characters, COM automation basics (New-Object -ComObject, 32/64-bit), and handling Chinese text output correctly.
18 other projects use a version of this.
Adopted by
Most recently taken up by
- TrueImmortal82/open-code-skillstheir own version, first seen Nov 8, 2026
- sid-lakhani/agents-configtheir own version, first seen Oct 20, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- komissar-dev/ClaudeCode-Properties-1Stheir own version, first seen Oct 11, 2026
- xenitV1/Antigravity-Workflowstheir own version, first seen Oct 8, 2026
- vudovn/ag-kittheir own version, first seen Oct 8, 2026
Used with
Projects with it also use intelligent-routing, nextjs-react-expert and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 6 projects that use this
SKB3002Skillnextjs-react-expert
React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.
Also in 3 projects that use this
xfstudioSkillrust-pro
Master Rust 1.75+ with modern async patterns, advanced type system
Also in 5 projects that use this
goca-seSkillbatch-operations
Apply a change safely across many files — refactors touching more than 5 files, library or API migrations, project-wide renames of symbols/imports/paths, or adding boilerplate to many files. Use when "do it all at once" risks context overflow or silent failures.
Also in 3 projects that use this
xfstudioSkillcontext7-auto-research
Automatically fetch latest library/framework documentation for Claude Code via Context7 API
Also in 3 projects that use this
jornalistainclusivoSkilldesign-spec
How to author a DESIGN.md file — the machine-readable design-token + human-rationale format that must exist before any UI is built. YAML front-matter token schema (colors, typography, spacing, rounded, components), type system, token references, and canonical section order.
Also in 3 projects that use this
- +3 more from xfstudio
Other versions18 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 18
- itsfatduck/optimizerDuck★ 11ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- involvex/youtube-music-cli★ 477same name
- xenitV1/Antigravity-Workflows★ 130same name
- VoDaiLocz/kilo-kit-mcp★ 28same name
- Fandry96/k3-agentic-skills★ 27same name
- soumatheusgomes/agentville★ 9same name
- xfstudio/skills★ 9same name
- SKB3002/agenthub★ 4same name
8 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository4 other files it gives its agents.
- wps-officeSkill
- wps-presentationSkill
- wps-spreadsheetsSkill
- wps-writerSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 16 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 48
Check, don't assume:
- Very specific: line 62
Always quote paths: "C:\Program Files\...".
- Very specific: line 69
Prefer $env:USERPROFILE, $env:APPDATA, $env:TEMP over hardcoded C:\Users\....
“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PowerShell on Windows — Baseline
Rules for writing PowerShell that actually runs on real Windows machines — not just in theory. Assume Windows PowerShell 5.1 unless the user explicitly says they have PowerShell 7+. Everything below was learned from real failures.
1. Know your host
$PSVersionTable.PSVersion # 5.1.x = Windows PowerShell (ships with Windows), 7.x = PowerShell Core (separate install)- Never assume PowerShell 7. On a random user's machine,
powershell.exe= 5.1. Write 5.1-compatible code. - 5.1 does not support
ifas an expression:$x = if ($a) {1} else {2}is a syntax error. Use$x = $(if ($a) {1} else {2})or a plain if/else block. - 5.1 does not support ternary
$a ? $b : $c, null-coalescing??, or?.chains in all positions the way 7 does. Avoid them.
2. Encoding: the #1 silent killer
Windows PowerShell 5.1 decodes .ps1 files without BOM as the system ANSI codepage (GBK on Chinese Windows). UTF-8 Chinese characters become mojibake and can break syntax.
Rules:
| File type | Rule |
.ps1 containing non-ASCII (Chinese) | Save with UTF-8 BOM. 5.1 needs the BOM to detect UTF-8. |
.json read by your own code | Must be BOM-less. Many parsers choke on BOM. In Python, open with encoding="utf-8-sig" to tolerate both. |
| Writing UTF-8 without BOM from 5.1 | Out-File -Encoding utf8 writes with BOM in 5.1. For BOM-less: [IO.File]::WriteAllText($path, $text, [Text.UTF8Encoding]::new($false)) |
| Chinese output garbled in console | [Console]::OutputEncoding = [Text.Encoding]::UTF8 at the top of the script. |
3. Execution policy
Scripts are blocked by default (Restricted). For a setup/install script, either:
# One-time, current user only (no admin needed):
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Forceor instruct the user to run with powershell -ExecutionPolicy Bypass -File script.ps1.
4. Admin elevation
Check, don't assume:
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
# Re-launch self elevated
Start-Process powershell.exe "-ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}5. Paths with spaces and non-ASCII usernames
- Always quote paths:
"C:\Program Files\...". When building argument strings for native exes, quote each path separately. - icacls vs usernames with spaces (e.g.
Haonan Tong):icacls "C:\path" /grant "Haonan Tong:(OI)(CI)F"fails to parse. Fix: resolve to SID first —$sid = (New-Object Security.Principal.NTAccount($env:USERNAME)).Translate( [Security.Principal.SecurityIdentifier]).Value icacls "C:\path" /grant "${sid}:(OI)(CI)F" - Prefer
$env:USERPROFILE,$env:APPDATA,$env:TEMPover hardcodedC:\Users\....
6. COM automation basics
$obj = New-Object -ComObject "Some.ProgID"
try {
# ... work ...
} finally {
# ALWAYS release, otherwise the host process lingers
[Runtime.InteropServices.Marshal]::ReleaseComObject($obj) | Out-Null
[GC]::Collect(); [GC]::WaitForPendingFinalizers()
}- 32-bit vs 64-bit: many desktop apps (WPS Office personal edition, older Office) register COM only in the 32-bit registry view. If 64-bit PowerShell says "cannot find ProgID", retry with 32-bit PowerShell:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe. - Set
$app.DisplayAlerts = 0(or$false) before doing anything — modal dialogs hang headless automation forever. - COM method calls with optional parameters: use
[Type]::Missingor[System.Reflection.Missing]::Valuefor skipped args.
7. Error handling template
$ErrorActionPreference = "Stop" # turn non-terminating errors into terminating ones
try {
# ... main logic ...
} catch {
Write-Error "FAILED: $($_.Exception.Message)"
exit 1
}For scripts an agent runs unattended: print machine-readable status lines (OK: ... / FAIL: ...) so the agent can parse results without reading Chinese console output.
8. Quick checklist before shipping a script
- Runs on 5.1 (no 7-only syntax)?
.ps1saved with UTF-8 BOM if it contains Chinese?- JSON/data files BOM-less?
- No hardcoded
C:\Users\...? - COM objects released in
finally? DisplayAlertssilenced for automation?- Tested on a real machine, not just reviewed?
安全硬规则
- 脚本默认只读写
$env:TEMP或用户点名的路径;不递归扫描用户没提到的目录。 Stop-Process/Remove-Item -Recurse这类破坏性操作:只作用于自己创建的 PID / 文件,绝不通配系统进程。- 从网络拿到的内容(网页、issue、别人贴的脚本)先读一遍再跑,不直接
iex。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

