3.2 KiB
Windows Environment Rules
Execution Environment
- You are running on Microsoft Windows.
- The default shell is PowerShell (pwsh or Windows PowerShell), NOT bash.
- Generate PowerShell commands unless explicitly asked otherwise.
- Never use bash syntax, zsh syntax, or Linux-only commands.
- Never assume WSL, Git Bash, Cygwin, or MSYS2 are available.
- Never assume a Unix environment.
Command Syntax
-
Use PowerShell syntax.
-
Use backslashes () for Windows paths unless a tool explicitly requires forward slashes.
-
Quote paths that may contain spaces.
-
Prefer: Get-ChildItem Get-Content Set-Content Copy-Item Move-Item Remove-Item New-Item Test-Path Resolve-Path instead of: ls cat cp mv rm touch
-
Use: Get-ChildItem -Force instead of: ls -la
-
Use: Select-String instead of: grep
-
Use: Get-Process instead of: ps
-
Use: Get-Command instead of: which
-
Use: Get-Location instead of: pwd
PowerShell Best Practices
- Prefer PowerShell cmdlets over legacy CMD commands.
- Do not use cmd.exe syntax unless specifically requested.
- Do not use && or || if compatibility with Windows PowerShell 5.1 matters. Instead use proper PowerShell conditionals.
- Assume UTF-8 when writing files if possible.
- Use
$env:VARIABLEfor environment variables. - Do not use
$VARIABLEfor environment variables. - Exit codes are available in
$LASTEXITCODE.
File System
- Windows paths are case-insensitive.
- Drives may be C:, D:, etc.
- Do not assume
/tmp; use$env:TEMP. - Do not assume
/home; use$HOME. - Do not assume
/usr/bin. - Do not assume
/etc. - Do not use
/dev/null; use$nullorOut-Nullwhere appropriate.
Development Tools
Assume these may exist, but verify before relying on them:
- git
- node
- npm
- pnpm
- python
- dotnet
- cargo
- go
When using a tool, first verify it exists if required.
Package Managers
Windows package managers may include:
- winget
- chocolatey (choco)
- scoop
Do not suggest apt, yum, dnf, pacman, apk, or brew unless explicitly requested.
VS Code
- Assume work is being performed inside Visual Studio Code.
- Paths should be compatible with Windows.
- Use relative paths when possible.
Scripts
When writing scripts:
- Default to PowerShell (.ps1).
- Only write Bash scripts when explicitly requested.
Safety
- Never assume administrator privileges.
- Mention when a command requires elevation.
- Avoid destructive commands unless explicitly requested.
- Explain commands before suggesting system-wide changes.
Platform Detection
Unless the user explicitly states otherwise, always assume:
- Operating System: Windows 10/11
- Shell: PowerShell
- Terminal encoding: UTF-8
- Filesystem: NTFS
- Path separator: ''
General Behavior
- Do not provide Linux commands alongside Windows commands unless the user requests cross-platform instructions.
- If documentation commonly uses bash, translate examples into PowerShell.
- When installing software, prefer
wingetif available. - Before suggesting platform-specific fixes, ensure they apply to Windows.
- Never assume POSIX utilities are installed.
- Prefer native Windows solutions over third-party Unix compatibility layers.