1.2 KiB
1.2 KiB
description, globs
| description | globs |
|---|---|
| High-density PowerShell script generation rules for minimal token usage | *.ps1, *.psm1 |
PowerShell Token Optimization
- Use Short Aliases: Use short aliases instead of full cmdlet names to drastically cut output tokens:
- Use
gcinstead ofGet-Content - Use
gciinstead ofGet-ChildItem - Use
%instead ofForEach-Object - Use
?instead ofWhere-Object - Use
measureinstead ofMeasure-Object
- Use
- Pipeline Over Loops: Prefer pipeline chains (
gci | % { ... }) over multi-lineforeach ($item in $items) { ... }blocks. - No Help/Comments: Do not generate
.SYNOPSIS,.DESCRIPTION, or comment-based help at the top of scripts. - Omit Parameter Names: Drop explicit parameter names where positional arguments are clear (e.g., use
gc file.txtinstead ofGet-Content -Path file.txt). - Silent Execution: Do not add verbose logging,
Write-Host, orWrite-Outputunless explicitly asked to create UI/logs. - Preserve CLI Arguments: Do not duplicate full multi-line
yt-dlpcommand-line arguments, format strings, or output templates if they are not the subject of the modifications. Use placeholders or variable references.