CtrlK
BlogDocsLog inGet started
Tessl Logo

windows-shell-reliability

Reliable command execution on Windows: paths, encoding, and common binary pitfalls.

52

Quality

58%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Fix and improve this skill with Tessl

tessl review fix ./plugins/AI-Agents-Safe-Coding-Skills-claude/skills/windows-shell-reliability/SKILL.md

The canonical home for this skill is windows-shell-reliability in administrakt0r/AI-Agents-Safe-Coding-Skills

SKILL.md
Quality
Evals
Security

Windows Shell Reliability Patterns

Best practices for running commands on Windows via PowerShell and CMD.

When to Use

Use this skill when developing or debugging scripts and automation that run on Windows systems, especially when involving file paths, character encoding, or standard CLI tools.


1. Encoding & Redirection

CRITICAL: Redirection Differences Across PowerShell Versions

Older Windows PowerShell releases can rewrite native-command output in ways that break later processing. PowerShell 7.4+ preserves the byte stream when redirecting stdout, so only apply the UTF-8 conversion workaround when you are dealing with older shell behavior or a log file that is already unreadable.

ProblemSymptomSolution
dotnet > log.txtview_file fails in older Windows PowerShell`Get-Content log.txt
npm run > log.txtNeed a UTF-8 text log with errors included`npm run ... 2>&1

Rule: Prefer native redirection as-is on PowerShell 7.4+, and use explicit UTF-8 conversion only when older Windows PowerShell redirection produces an unreadable log.


2. Handling Paths & Spaces

CRITICAL: Quoting

Windows paths often contain spaces.

❌ Wrong✅ Correct
dotnet build src/my project/file.fsprojdotnet build "src/my project/file.fsproj"
& C:\Path With Spaces\bin.exe& "C:\Path With Spaces\bin.exe"

Rule: Always quote absolute and relative paths that may contain spaces.

The Call Operator (&)

In PowerShell, if an executable path starts with a quote, you MUST use the & operator.

Pattern:

& "C:\Program Files\dotnet\dotnet.exe" build ...

3. Common Binary & Cmdlet Pitfalls

Action❌ CMD Style✅ PowerShell Choice
Deletedel /f /q fileRemove-Item -Force file
Copycopy a bCopy-Item a b
Movemove a bMove-Item a b
Make Dirmkdir folderNew-Item -ItemType Directory -Path folder

Tip: Using CLI aliases like ls, cat, and cp in PowerShell is usually fine, but using full cmdlets in scripts is more robust.


4. Dotnet CLI Reliability

Build Speed & Consistency

ContextCommandWhy
Fast Iterationdotnet build --no-restoreSkips redundant nuget restore.
Clean Builddotnet build --no-incrementalEnsures no stale artifacts.
BackgroundStart-Process dotnet -ArgumentList 'run' -RedirectStandardOutput output.txt -RedirectStandardError error.txtLaunches the app without blocking the shell and keeps logs.

5. Environment Variables

ShellSyntax
PowerShell$env:VARIABLE_NAME
CMD%VARIABLE_NAME%

6. Long Paths

Windows has a 260-character path limit by default.

Fix: If you hit long path errors, use the extended path prefix: \\?\C:\Very\Long\Path\...


7. Troubleshooting Shell Errors

ErrorLikely CauseFix
The term 'xxx' is not recognizedPath not in $env:PATHUse absolute path or fix PATH.
Access to the path is deniedFile in use or permissionsStop process or run as Admin.
Encoding mismatchOlder shell redirection rewrote the outputRe-export the file as UTF-8 or capture with `2>&1

Repository
administrakt0r/AI-Agents-Safe-Coding-Skills
Last updated
First committed

Canonical home

administrakt0r/AI-Agents-Safe-Coding-Skills
In sync

since Aug 19, 2026

Also appears in

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.