WSL Shell Reliability
Use this skill to maximize terminal command success on Windows.
This skill does not force WSL.
It enforces a reliability-first policy:
- pick the shell with lower failure risk,
- preserve command intent across fallback,
- never switch shells silently.
Trigger conditions
- Any terminal execution task on Windows.
- AI-generated commands that look bash/POSIX-oriented.
- Repeated failures caused by quoting/path/shell mismatch.
One-screen decision table
| Question |
If Yes |
If No |
| Windows-native task/tool? |
Use PowerShell/CMD |
Next question |
| POSIX/bash semantics required? |
Use WSL/bash |
Next question |
| Need Linux-first parity? |
Prefer WSL/bash |
Next question |
| High Windows-shell parse risk? |
Prefer WSL/bash |
Next question |
| Both paths low risk? |
Pick shell with fewer moving parts |
N/A |
Examples:
- Windows-native:
winget, reg, netsh, .exe/.msi, service/system ops.
- POSIX-heavy:
rm -rf, export, ./script.sh, grep/sed/awk, complex pipes.
Rule priority (conflict resolution)
Apply rules in this priority order when guidance appears to conflict:
- Windows-native exclusions (must use PowerShell/CMD).
- Decision table hard signals (POSIX dependence, high parse risk).
- Fallback policy + intent preservation.
- Convenience preferences (tool availability, fewer steps).
If still ambiguous, choose the shell with lower execution-failure risk.
Windows-native exclusions (prefer PowerShell/CMD)
winget, scoop, choco
- PowerShell cmdlets and registry/service/system commands
.msi/.exe installer flows
- Windows-targeted
msbuild/.NET packaging chains
Execution protocol
- Select shell with the decision table.
- Generate syntax for that shell (do not mix grammar).
- Execute command.
- If failure is shell-related, fallback to the other shell.
- Preserve intent exactly; only translate syntax.
- State fallback explicitly.
Shell-aware generation rules
- WSL/bash: POSIX syntax allowed.
- PowerShell: PowerShell-native quoting/escaping.
- CMD: use only when required by task/tool.
Do not run bash syntax directly in PowerShell/CMD.
WSL templates
wsl.exe -e bash --noprofile --norc -lc "<command>"
wsl.exe -e bash --noprofile --norc -lc "cd /mnt/<drive>/<path> && <command>"
Quick translation hints (bash -> PowerShell)
export FOO=bar -> $env:FOO = "bar"
rm -rf <path> -> Remove-Item -Recurse -Force <path>
cp -r a b -> Copy-Item a b -Recurse
mv a b -> Move-Item a b
cat file -> Get-Content file
Use translations only when fallback requires them.
Guardrails
- Never silently switch shells.
- Never change command semantics when switching shells.
- Never install tools just to enforce one-shell purity.
- Prefer existing toolchain in the selected shell first.
Fallback policy
Fallback to the other shell when:
- WSL is unavailable or unstable,
- the tool cannot be resolved in current shell,
- task is clearly Windows-native,
- command fails due to shell parsing/quoting mismatch.
When falling back, report:
- what failed,
- why shell changed,
- equivalent command intent preserved.
Known limitations
- Some enterprise environments disable WSL installation/execution.
- VPN/proxy/DNS policies may break package/network operations in one shell.
- Cross-filesystem operations can have inconsistent performance.
- Security policies may block execution scripts in PowerShell.
In these cases, prefer explicit fallback and report constraints clearly.
References
Deep technical notes and examples:
- references/REFERENCE.md
- references/SCENARIOS.md
1---2name: wsl-shell-reliability3description: Reliability-first shell selection policy for AI agents on Windows. Choose WSL or PowerShell based on execution risk, not preference.4license: MIT5---67# WSL Shell Reliability89Use this skill to maximize terminal command success on Windows.1011This skill does **not** force WSL.12It enforces a reliability-first policy:1314- pick the shell with lower failure risk,15- preserve command intent across fallback,16- never switch shells silently.1718## Trigger conditions1920- Any terminal execution task on Windows.21- AI-generated commands that look bash/POSIX-oriented.22- Repeated failures caused by quoting/path/shell mismatch.2324## One-screen decision table2526| Question | If Yes | If No |27| --- | --- | --- |28| Windows-native task/tool? | Use **PowerShell/CMD** | Next question |29| POSIX/bash semantics required? | Use **WSL/bash** | Next question |30| Need Linux-first parity? | Prefer **WSL/bash** | Next question |31| High Windows-shell parse risk? | Prefer **WSL/bash** | Next question |32| Both paths low risk? | Pick shell with fewer moving parts | N/A |3334Examples:3536- Windows-native: `winget`, `reg`, `netsh`, `.exe/.msi`, service/system ops.37- POSIX-heavy: `rm -rf`, `export`, `./script.sh`, `grep/sed/awk`, complex pipes.3839## Rule priority (conflict resolution)4041Apply rules in this priority order when guidance appears to conflict:42431. **Windows-native exclusions** (must use PowerShell/CMD).442. **Decision table hard signals** (POSIX dependence, high parse risk).453. **Fallback policy + intent preservation**.464. **Convenience preferences** (tool availability, fewer steps).4748If still ambiguous, choose the shell with lower execution-failure risk.4950## Windows-native exclusions (prefer PowerShell/CMD)5152- `winget`, `scoop`, `choco`53- PowerShell cmdlets and registry/service/system commands54- `.msi`/`.exe` installer flows55- Windows-targeted `msbuild`/`.NET` packaging chains5657## Execution protocol58591. Select shell with the decision table.602. Generate syntax for that shell (do not mix grammar).613. Execute command.624. If failure is shell-related, fallback to the other shell.635. Preserve intent exactly; only translate syntax.646. State fallback explicitly.6566## Shell-aware generation rules6768- **WSL/bash**: POSIX syntax allowed.69- **PowerShell**: PowerShell-native quoting/escaping.70- **CMD**: use only when required by task/tool.7172Do not run bash syntax directly in PowerShell/CMD.7374## WSL templates7576- `wsl.exe -e bash --noprofile --norc -lc "<command>"`77- `wsl.exe -e bash --noprofile --norc -lc "cd /mnt/<drive>/<path> && <command>"`7879## Quick translation hints (bash -> PowerShell)8081- `export FOO=bar` -> `$env:FOO = "bar"`82- `rm -rf <path>` -> `Remove-Item -Recurse -Force <path>`83- `cp -r a b` -> `Copy-Item a b -Recurse`84- `mv a b` -> `Move-Item a b`85- `cat file` -> `Get-Content file`8687Use translations only when fallback requires them.8889## Guardrails9091- Never silently switch shells.92- Never change command semantics when switching shells.93- Never install tools just to enforce one-shell purity.94- Prefer existing toolchain in the selected shell first.9596## Fallback policy9798Fallback to the other shell when:99100- WSL is unavailable or unstable,101- the tool cannot be resolved in current shell,102- task is clearly Windows-native,103- command fails due to shell parsing/quoting mismatch.104105When falling back, report:1061071. what failed,1082. why shell changed,1093. equivalent command intent preserved.110111## Known limitations112113- Some enterprise environments disable WSL installation/execution.114- VPN/proxy/DNS policies may break package/network operations in one shell.115- Cross-filesystem operations can have inconsistent performance.116- Security policies may block execution scripts in PowerShell.117118In these cases, prefer explicit fallback and report constraints clearly.119120## References121122Deep technical notes and examples:123124- [references/REFERENCE.md](references/REFERENCE.md)125- [references/SCENARIOS.md](references/SCENARIOS.md)