josiahsiegel avatar

Powershell Shell Detection

If you're shipping scripts or automation that needs to run across PowerShell, Git Bash, and cmd on Windows, this gives you the detection logic and compatibility patterns to stop guessing. It covers the priority order for shell detection (PSModulePath first, then MSYSTEM), the path conversion gotchas in Git Bash that silently break things, and how to call PowerShell from bash and vice versa. The real value is in the specifics: when MSYS_NO_PATHCONV matters, why environment variable syntax breaks cross-shell, and which detection method actually works reliably. Use it when you're tired of scripts that work in your shell but fail in CI or on a teammate's machine.

skills.sh installs
209
GitHub stars
61
last updated
Aug 21, 2026

Install

$ npx -y skills add josiahsiegel/claude-plugin-marketplace --skill powershell-shell-detection --agent claude-code

Installs into .claude/skills of the current project.

Files

PowerShell Shell Detection & Cross-Shell Compatibility

Critical guidance for distinguishing between PowerShell and Git Bash/MSYS2 shells on Windows, with shell-specific path handling and compatibility notes.

Shell Detection Priority (Windows)

When working on Windows, correctly identifying the shell environment is crucial for proper path handling and command execution.

Detection Order (Most Reliable First)

  1. process.env.PSModulePath (PowerShell specific)
  2. process.env.MSYSTEM (Git Bash/MinGW specific)
  3. process.env.WSL_DISTRO_NAME (WSL specific)
  4. uname -s output (Cross-shell, requires execution)

PowerShell Detection

Primary Indicators

PSModulePath (Most Reliable):

# PowerShell detection
if ($env:PSModulePath) {
    Write-Host "Running in PowerShell"
    # PSModulePath contains 3+ paths separated by semicolons
    $env:PSModulePath -split ';'
}

# Check PowerShell version
$PSVersionTable.PSVersion
# Output: 7.5.4 (PowerShell 7) or 5.1.x (Windows PowerShell)

Sponsors

Details

Repository
github.com/josiahsiegel/claude-plugin-marketplace
Categories
Git & Pull Requests, Automation & Workflows, Marketing & SEO, CLI & Terminal
First seen
Jun 3, 2026

More from josiahsiegel/claude-plugin-marketplace

All 26
1jorgealves avatarpython-async-advisorjorgealves/agent_skillsReview asynchronous Python code to identify race conditions, deadlocks, and inefficient patterns. Use when working with asyncio, aiohttp, or FastAPI.208skills.sh installs
2nexu-io avatarhtml-pptnexu-io/open-designFor consulting delivery work: turn diagnosis, frameworks, and project work into a client-adoptable action plan. Built around the core query "consulting-final-de208skills.sh installs
3tw93 avatarwazatw93/wazaEngineering skills for Claude: think (architecture), design (UI), check (code review), hunt (debugging), write (prose), learn (research), read (URL/PDF fetch), 208skills.sh installs
4anthropics avatarcomplianceanthropics/knowledge-work-pluginsNavigate privacy regulations (GDPR, CCPA), review DPAs, and handle data subject requests. Use when reviewing data processing agreements, responding to data subj207skills.sh installs
5samhvw8 avatarui-ux-designsamhvw8/dot-claudeUI/UX design reference database. 50+ styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Ta207skills.sh installs
6yonatangross avataraudit-fullyonatangross/orchestkitSingle-pass codebase analysis leveraging a 1M-token context window for comprehensive security scanning, architecture review, and dependency auditing. Loads enti206skills.sh installs