---
name: windows-bash
description: >
  On Windows (especially in PowerShell-based AI tool sessions like this Grok TUI), ensure the `bash` command resolves to Git for Windows / MSYS bash (required by the ClaudeTools harness) instead of the WSL stub. Use when you see WSL errors, when running vault.sh/sync.sh/hooks, when "bash --version" shows non-MSYS, or on any "bash" invocation for .claude/scripts or hooks. Triggers on "bash issue", "map bash", "Git Bash", "WSL stub", "ensure-git-bash".
---

# Windows Bash Mapping Skill (Grok Native)

**Core rule for this repo on Windows:** The ClaudeTools harness (`.claude/scripts/*.sh`, hooks, `vault.sh`, `sync.sh`, etc.) **requires** the Git for Windows/MSYS `bash` (version like "5.2.37(1)-release (x86_64-pc-msys)", supports `/d/claudetools` paths, etc.).

Plain `bash` in PowerShell often resolves to the useless WSL stub in `WindowsApps\`.

## The Fix (run this early)

```powershell
$gitBin = "C:\Program Files\Git\bin"
$gitUsrBin = "C:\Program Files\Git\usr\bin"
if ((Test-Path $gitBin) -and ((Get-Command bash -ErrorAction SilentlyContinue).Source -notlike '*Git*bin*bash.exe')) {
    $env:Path = "$gitBin;$gitUsrBin;" + ($env:Path -replace [regex]::Escape("$gitBin;"), '' -replace [regex]::Escape("$gitUsrBin;"), '')
}
```

After this:
- `Get-Command bash` → `C:\Program Files\Git\bin\bash.exe`
- `bash --version` shows the correct MSYS one.
- You can use plain `bash .claude/scripts/vault.sh list` etc.

## Project Helper Script

Source the reusable one (always safe/idempotent):

```powershell
. .claude/scripts/ensure-git-bash.ps1
```

See the script for the exact code and comments. It is also referenced from the user's PowerShell profile so new sessions auto-fix.

## In This Session / Tool Context
- If a command needs bash, start by sourcing the helper or running the snippet above.
- For one-off critical calls (e.g. vault), you can also use the full explicit path: `"C:\Program Files\Git\bin\bash.exe" .claude/scripts/vault.sh get-field ...`
- Git Bash terminals (launched directly) already have the right `bash`.

## Related Gotchas (from CLAUDE.md)
- For writing `.claude/current-mode` etc.: use relative paths or forward slashes only (`/d/claudetools/...`). The `block-backslash-winpath.sh` hook protects this.
- SSH: always `C:\Windows\System32\OpenSSH\ssh.exe` (system), **never** Git for Windows SSH.
- See `.claude/memory/feedback_windows_bash_mapping.md` and the Windows section in the root `CLAUDE.md` for the full documented fix.

This skill ensures you (Grok) remember and apply the mapping automatically on Windows sessions in this repo. The knowledge is also in the shared ClaudeTools memory system (`.claude/memory/`) and `CLAUDE.md` so it works for both Claude Code and Grok drivers.