powershell-performance-review
Skill24 starsChanged 4 days agoMITView on GitHub
Find and fix performance problems in PowerShell code by measuring it. Use when asked to optimize, speed up, profile, or analyze the performance of PowerShell code.
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .claude/rules/powershell-standards/copilot-instructions.mdCopilot instructions
- .github/copilot-instructions.mdCopilot instructions
- powershell-ci-pipelineSkill
- powershell-credential-scanSkill
- powershell-loggingSkill
- powershell-module-helpSkill
- powershell-new-functionSkill
- powershell-new-moduleSkill
- powershell-performance-reviewSkill
- powershell-reviewSkill
- powershell-security-reviewSkill
- powershell-write-testsSkill
- powershell-ci-pipelineSkill
- powershell-credential-scanSkill
- powershell-loggingSkill
- powershell-module-helpSkill
- powershell-new-functionSkill
- powershell-new-moduleSkill
- powershell-performance-reviewSkill
- powershell-reviewSkill
- powershell-security-reviewSkill
- powershell-write-testsSkill
- powershell-ci-pipelineSkill
- powershell-credential-scanSkill
- powershell-loggingSkill
- powershell-module-helpSkill
- powershell-new-functionSkill
- powershell-new-moduleSkill
- powershell-reviewSkill
- powershell-security-reviewSkill
- powershell-write-testsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Ask what is slow and how large the real input is, if the user has not said.
- Distinctive: line 18
Look for the causes that usually dominate:
- Very specific: line 29
Do not trade correctness or clarity for a small gain, and do not add parallelism (ForEach-Object -Parallel, thread jobs) unless the work is …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Performance review of PowerShell code
The collection and string rules are in .github/instructions/powershell-style.instructions.md
(STY-22, STY-40 to STY-45, and STY-50). Read them first, unless that file is already loaded.
Steps
- Ask what is slow and how large the real input is, if the user has not said. An improvement that matters at 100,000 items can be noise at 100.
- Measure before changing anything. Use
Measure-Commandaround the code with realistic input, and repeat the run several times. If you cannot run the code, say so and present your suggestions as unmeasured. - Look for the causes that usually dominate:
- An array grown with
+=inside a loop, or a string extended with+=about 100 times or more. Below that,+=on a string is fine (STY-22); do not report it. - A command called once for each item when it accepts all items at once, or a remote or disk call inside a loop that could be made once outside it.
- Filtering with
Where-Objectwhat the source command could have filtered. - A lookup that scans a collection inside a loop, where a hashtable built once would do.
ForEach-Objectover a large collection that is already in memory.- Output piped to
Out-Nullin a tight loop.
- An array grown with
- Change one thing at a time and measure again with the same input. Keep a change only if it is faster and the output is the same.
- Do not trade correctness or clarity for a small gain, and do not add parallelism
(
ForEach-Object -Parallel, thread jobs) unless the work is slow per item and the items are independent.
Report
Give the measurements before and after, with the input size and the PowerShell version, for each change you kept. Performance figures MUST come from runs you made; do not estimate percentages. List what you tried that did not help.
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.

